两种脚本方法:

1:tcl

# X_to_A_mif_conversion.tcl
# This script will convert a Xilinx mif file to an Intel PSG (Altera) mif file
# mif files are often used as initialization files for FPGA RAM implementations
# 
# usage from a tcl console window in Quartus or from a tcl shell
# > X_to_A_mif_conversion.tcl
#  No arguments will print out all options needed for the script
#  X_to_A_mif_conversion.tcl <depth> <width> <input_file> <output_file>
#
# Example
# > X_to_A_mif_conversion.tcl 1024 16 X_1024x16.mif a_1024x16.mif
#
if {$argc == 0} {
 puts ""
 puts "Usage:"
 puts "X_to_A_mif_conversion.tcl <depth> <width> <input_file> <output_file>"
 puts ""
 exit
} elseif {$argc != 4} {
 puts ""
 puts "Incorrect number of arguments"
 puts "X_to_A_mif_conversion.tcl <depth> <width> <input_file> <output_file>"
 puts ""
 exit
}

set depth  [lindex $argv 0]
set width  [lindex $argv 1]
set filein [lindex $argv 2]
set fileout [lindex $argv 3]if {[file exists $filein] == 0} {
 puts "input file $filein does not exist"
 exit
} set fin [open $filein r]
set fout [open $fileout w]set timestamp_decimal [clock format [clock seconds] -format {%Y %m %d %H %M %S}]puts $fout "-- Created by X_to_A_mif_conversion.tcl"
puts $fout "-- MIF CREATION TIMESTAMP = $timestamp_decimal"
puts $fout "DEPTH = $depth;                  -- The size of memory in words"
puts $fout "WIDTH = $width;                   -- The size of data in bits"
puts $fout "ADDRESS_RADIX = DEC;         -- The radix for address values"
puts $fout "DATA_RADIX = BIN;            -- The radix for data values"
puts $fout "CONTENT                      -- start of (address : data pairs)"
puts $fout "BEGIN"
puts $fout ""set i 0
while { [gets $fin data] >= 0 } {
  puts $fout "$i : $data;"
  incr i
}

puts $fout "END;"

close $fin
close $fout

2:Python

#Convert Xilinx Mif to Altera MIF
#Ex of How to run Script for a 16x8 (16 bit wide, 8 deep) Xilinx Block RAM:
#python X_altera_mif_conversion.py -d 8 -w 16 -i Xilinx_mif.mif -o intel_mif.mif
#If your Xilinx MIF (Xilinx_mif.mif) is a 8x16 (dxw) MIF generated in Vivado/ISE,
#the command above will generate a intel MIF file intel_mif.mif in the correct
#format that will pass Quartus synthesis. 
import sys, getopt, struct

def convert_mif(ifile, ofile, depth, width):
               fp_out=open(ofile, "w")
               fp_out.write("DEPTH = " + str(depth) + ";" + "\n" + "\n")
               fp_out.write("WIDTH = " + str(width) + ";" + "\n" + "\n" + "\n")
               fp_out.write("ADDRESS_RADIX = DEC;\n")
               fp_out.write("DATA_RADIX = BIN;\n\n\n")
               fp_out.write("CONTENT\n")
               fp_out.write("BEGIN\n")
               fp_in=open(ifile, "r")
               lines = fp_in.readlines()
               i=0
               for line in lines:
                               fp_out.write(str(i) + " : " + line.rstrip() + ";" + "\n")
                               i = i+1
               fp_out.write("END;")
               fp_in.close()
               fp_out.close()
               print("Converted Xilinx MIF: " + ifile + " To Intel PSG MIF: " + ofile) def main(argv):
               inputfile = ''
               outputfile = ''
               depth = 0
               width = 0
               try:
                               opts, args = getopt.getopt(argv,"hd:w:i:o:")
               except getopt.GetoptError:
                               print 'X_altera_mif_conversion.py -d <depth> -w <width> -i <inputfile> -o <outputfile>'
                               sys.exit(2)
               for opt, arg in opts:
                               if opt == '-h':
                                               print 'X_altera_mif_conversion.py -d <depth> -w <width> -i <inputfile> -o <outputfile>'
                                               sys.exit()
                               elif opt == '-d':
                                               depth = arg
                               elif opt == '-w':
                                               width = arg
                               elif opt == "-i":
                                               inputfile = arg
                               elif opt == "-o":
                                               outputfile = arg
               print 'Input file is ', inputfile
               print 'Output file is ', outputfile
               print 'depth is ', depth
               print 'width is ', width
               convert_mif(inputfile, outputfile, depth, width)

if __name__ == "__main__":
  main(sys.argv[1:])

Xilinx coe 与 Intel(Altera) mif 文件转化脚本相关推荐

  1. 利用MATLAB将图片转换成coe文件、TXT文件、mif文件、bin文件

    利用MATLAB将图片转换成coe文件.TXT文件.mif文件 利用MATLAB将图片转换成coe文件 利用MATLAB将图片转换成txt文件 利用MATLAB将图片转换成mif文件 利用MATLAB ...

  2. COE文件与MIF文件使用方法

    在FPGA开发中,COE文件和MIF文件是常用的存储器初始化文件.COE文件和MIF文件都用于导入存储器ROM或RAM的存储数据,但是它们的格式和语法有些不同.本文将介绍COE文件和MIF文件的使用方 ...

  3. 简谈 Intel altera 和 Xilinx 的 FPGA 区别

    大侠好,欢迎来到FPGA技术江湖,江湖偌大,相见即是缘分.大侠可以关注FPGA技术江湖,在"闯荡江湖"."行侠仗义"栏里获取其他感兴趣的资源,或者一起煮酒言欢. ...

  4. matlab读mif文件,MATLAB将mif文件转换成coe文件(原创)

    在网上下载project的source文件夹,原始coe数据被直接生成转换为了mif文件,不能直接加在到rom的ip核内,所以需要进行文件格式的转变,其中又涉及到数据量庞大时需要借助MATLAB这一强 ...

  5. MATLAB将mif文件转换成coe文件(原创)

    在网上下载project的source文件夹,原始coe数据被直接生成转换为了mif文件,不能直接加在到rom的ip核内,所以需要进行文件格式的转变,其中又涉及到数据量庞大时需要借助MATLAB这一强 ...

  6. verilog将像素数据写入txt_FPGA仿真必备(1)——Matlab生成.mif文件/.txt文件

    1. mif 文件 MIF(Memory Initialization File),内存初始化文件,用于 Altera / Intel 的 FPGA 器件的 RAM 或 ROM 配置. 例如: (1) ...

  7. XIlinx FPGA 和 Intel FPGA的区别

    目录 一 FPGA简介 什么是FPGA呢 ? FPGA的内部结构有什么呢? 为什么要开发FPGA? FPGA的发展历程? FPGA用于做什么? FPGA的优缺点? 二 Xilinx FPGA和Inte ...

  8. matlab如何写mif文件,matlab产生mif文件

    MIF 文件是 MapInfo 通用数据交换格式,这种格式是 ASCⅡ码,可以编辑,容易生成,且可以工作 在 MapInfo 支持的所有平台上. 它将 MapInfo 数据保存在两个文件中: .... ...

  9. matlab地址数据类型uns,使用matlab生成sine波mif文件

    使用matlab生成sine波mif文件 作者:lee神 在使用altera 的FPGA中的rom過程中常常會使用到.mif文件或.hex文件.對於初學者,無論mif還是hex都是很令人疑惑的東西,這 ...

最新文章

  1. gnome mysql client_configure: error: Not found mysqlclient library
  2. Linux服务器Zookeeper+Dubbo环境搭建
  3. 请举例说明如何在Spring 中注入一个Java 集合?
  4. Jenkins+GitLab+Docker+SpringCloud+Kubernetes实现可持续自动化微服务
  5. laravel order 按时间升序_Cache and Related Part3: Coherence amp; Order
  6. 利用ajaxSubmit()方法实现Form提交表单后回调
  7. oracle手动锁表和解锁_Oracle锁表查询和解锁方法
  8. LaTeX快速入门(超详细~)
  9. java excel 加边框_java通过poi来设置表格边框
  10. 服务器装系统鼠标键盘用不了怎么办,教你重装系统鼠标键盘不能用怎么解决?...
  11. 云痕大数据 家长登录_云痕大数据——苏州云痕教育科技有限公司
  12. 不会比这更详细的前端工程化的入门教程了
  13. Flash 101-第1部分:锤子和凿子
  14. 腾讯T-Star高校挑战赛
  15. 正则改造VS Code里React类组件的自定义snippet
  16. java项目实体类方法找不到_报错,居然找不到实体类
  17. 高防cdn对网站防护有什么作用
  18. Jetpack架构组件 (一)-- Android Jetpack 简介
  19. 图形化开发(六)01-Three.js之导入模型——3dmax和SketchUp-editor编辑器导出json文件,在创建模型initMesh中外部的JSON文件
  20. 安装冒险岛出现计算机丢失文件夹,冒险岛老更新失败?

热门文章

  1. java8 新特性精心整理(全)——新 Date/Time API
  2. 【良心】C语言零基础学习,C语言初学者入门基础知识讲解
  3. 拉勾教育管理系统(下)【笔记】
  4. Android Things:用户驱动-输入驱动
  5. 新能源汽车充电硬件接口标准
  6. 入侵服务器挖矿和诈骗事件频发 | 零时科技区块链安全周报
  7. 详谈NVMe over Fabric技术发展简史
  8. 【问】SQL安装时提示“安装程序配置服务器失败”?
  9. golang与面向接口编程
  10. mysql查询至少学过学号为“s001”同学所有课的其他同学学号和姓名