天气: 晴朗

心情: 高兴

function mif_Gen(filename,var,width,depth)

%       function miffile(filename,var,width,depth)

%       It creates a 'mif' file called filename,which be written with var.

%       The 'mif' file is a kind of file formats which is uesed in Altera's

%       EDA tool,like maxplus II ,quartus II,to initialize the memory

%       models,just like cam,rom,ram.

%       Using this function,you can easily produce the 'mif' file written

%       with  all kinds of your data.

%       If the size of 'var' is shorter than 'depth',0 will be written for the

%       lefts.If the size of 'var' is greater than 'depth',than only 'depth' former

%       data of 'var' will be written;

%       the radix of address and data is hex

%       filename --the name of the file to be created,eg,"a.mif",string;

%       var ----the data to be writed to the file, can be 3D or less ,int or other fittable;

%       width --the word size of the data,width>=1,int;

%       depth --the number of the data to be writed,int;

%

%       because matlab read the matrix is colum first,if you want to write

%       the 'var' data in row first mode, just set var to var';

%

%       example:

%             a=uint8(rand(16,16)*256);

%             miffile('randnum.mif',a,8,256);

if(nargin~=4) %% be tired to do more inupts check!

error('Need 4 parameters! Use help miffile for help!');

end,

fh=fopen(filename,'w+');

fprintf(fh,'--Created by VICTOR\r\n');

fprintf(fh,'--violet701@126.com\r\n');

fprintf(fh,'--%s\r\n',datestr(now));

fprintf(fh,'WIDTH=%d;\r\n',width);

fprintf(fh,'DEPTH=%d;\r\n',depth);

fprintf(fh,'ADDRESS_RADIX=HEX;\r\n');

fprintf(fh,'DATA_RADIX=HEX;\r\n');

fprintf(fh,'CONTENT BEGIN\r\n');

%%%%%%

%%%%%%

var=rem(var,2^width);%% clip to fit the width;

[sx,sy,sz]=size(var);%% can only fit 3D or less;

value=var(1,1,1);

sametotal=1;

idepth=0;

addrlen=1;

temp=16;

while(temp

temp=temp*16;

addrlen=addrlen+1;

end,

datalen=1;

while(temp

temp=temp*16;

datalen=datalen+1;

end,

for k=1:sz,

for j=1:sy,

for i=1:sx,

if(~((i==1 ) &&( j==1) &&( k==1)))

if(idepth

idepth=idepth+1;

if(value==var(i,j,k))

sametotal=sametotal+1;

continue;

else

if(sametotal==1)

fprintf(fh,['\t%' num2str(addrlen) 'X:%' num2str(datalen) 'X;\r\n'],idepth-1,value);

else

fprintf(fh,['\t[%' num2str(addrlen) 'X..%' num2str(addrlen) 'X]:%' num2str(datalen) 'X;\r\n'],idepth-sametotal,idepth-1,value);

end,

sametotal=1;

value=var(i,j,k);

end,

else

break;

end,

end,

end,

end,

end,

if(idepth

if(sametotal==1)

fprintf(fh,['\t%' num2str(addrlen) 'X:%' num2str(datalen) 'X;\r\n'],idepth,value);

else

fprintf(fh,['\t[%' num2str(addrlen) 'X..%' num2str(addrlen) 'X]:%' num2str(datalen) 'X;\r\n'],idepth-sametotal+1,idepth,value);

end,

end,

if(idepth

if(idepth==(depth-2))

fprintf(fh,['\t%' num2str(addrlen) 'X:%' num2str(datalen) 'X;\r\n'],idepth+1,0);

else

fprintf(fh,['\t[%' num2str(addrlen) 'X..%' num2str(addrlen) 'X]:%' num2str(datalen) 'X;\r\n'],idepth+1,depth-1,0);

end,

end,

%%%%%%%%%%

%%%%%%%%%%

fprintf(fh,'END;\r\n');

fclose(fh);

matlab产生mif 文件,生成.mif文件的matlab程序相关推荐

  1. 使用Matlab把图片集合生成视频流文件

    上一次在写过<使用Matlab读取视频流文件>博客,地址:https://blog.csdn.net/lingyunxianhe/article/details/83543282 这次是: ...

  2. [MATLAB]将.m文件生成dll文件

    环境:VS2017+MATLAB R2017a ①配置编译环境 在命令行窗口中输入"mbuild -setup"(横线前有一个空格),如果出现如下图所示的提示信息即为成功. 如果提 ...

  3. Matlab.m文件生成.exe文件之旅

    Matlab.m文件生成.exe文件之旅 Matlab中.m文件生成.exe文件之旅 作为算法工程师,有时需要测试人员帮忙测试算法模型,故需要向其发布一个算法工具,也是就是.exe文件.由于近期有利用 ...

  4. Python将py文件生成exe文件

    使用PyCham软件运行生成可执行文件后,最完美的就是将py文件生成exe文件,这样可以任意复制移植到其他电脑上,供他人共享. 由于新手初步尝试,自己一个人摸索,遇到了很多坑.这里先给出最简单有效的方 ...

  5. python生成表格文件_python 读取excel文件生成sql文件实例详解

    python 读取excel文件生成sql文件实例详解 学了python这么久,总算是在工作中用到一次.这次是为了从excel文件中读取数据然后写入到数据库中.这个逻辑用java来写的话就太重了,所以 ...

  6. 使用Cython库包对python的py文件(源码)进行加密,把python的.py文件生成.so文件并调用

    文章目录: 1 准备环境 2 调用`Cython库包`把python的`.py`文件生成`.so`文件 2.1 写源码文件 2.2 调用源码接口 2.3 调用Cython库把`.py`源码生成`.so ...

  7. Sandcastle是微软提供的一个根据XML注释和DLL文件生成帮助文件的工具

    2019独角兽企业重金招聘Python工程师标准>>> Sandcastle是微软提供的一个根据XML注释和DLL文件生成帮助文件的工具,目前是在CodePlex上的一个开源项目,可 ...

  8. 由.def文件生成lib文件[转]

    最近在学习curl库时,碰到一个问题,从官网上下载了一个lib版的,却发现只有.dll,没有lib文件,感觉很奇怪,google了之后才知道,原来库作者的用意是让用户自己生成lib文件,下载到的lib ...

  9. ActiveX: 如何用.inf和.ocx文件生成cab文件

    ActiveX: 如何用.inf和.ocx文件生成cab文件 转载于:https://www.cnblogs.com/time-is-life/p/5977962.html

  10. AD 22 如何从SchDoc文件生成PcbDoc文件,进行布局和走线?

    AD 22 如何从SchDoc文件生成PcbDoc文件,进行布局和走线? 请参考这个视频: Defining the Board Shape in Altium Designer | Altium D ...

最新文章

  1. filco蓝牙不好用_最新黑科技感应式音箱!无需接口不用蓝牙,放上手机 1s畅享动听音乐~...
  2. [转载]:合并两个已排序好的int数组,并排序返回c#实现
  3. java多线程之:SynchronousQueue队列
  4. 2012服务器系统安装iis,Windows Server 2012服务器管理系统安装配置IIS8.5教程
  5. 显示图片_Pycharm图片独立显示与imshow()无法显示
  6. Atitit 教育学体系 教育学主要内容多语言,教学论,心理学,体育 高等教育学 职业技术教育学 教育史
  7. mysql数据库引擎事务_代码配置都没问题,为什么事务不回滚(了解Mysql数据库引擎)...
  8. 富勒wms系统里的定时器id_WMS项目实施,该如何调研?
  9. Java 杨辉三角形
  10. C++11线程的生命周期
  11. 支持iphone的打印服务器,MAC苹果电脑系统 如何添加网络打印机(适用于Mac OS)
  12. dell台式计算机恢复出厂设置,戴尔电脑如何恢复出厂设置
  13. 二十一世纪大学英语读写教程(第二册)学习笔记(原文)——5 - Holding Onto a Dream(坚持梦想)
  14. linux关闭云锁服务器,安全软件之linux系统下云锁简单的安装方法
  15. Python爬虫开发从入门到实战
  16. 计算机数值方法知识,计算机数值方法.pdf
  17. RockyLinux9.0系统在VMware虚拟机上【保姆级】安装步骤,并修改网络配置,使用固定IP进行SSH连接【47张过程图】
  18. 告别难记的长域名!我的博客全新短域名上线
  19. OpenCV实现影像畸变矫正GPU
  20. 数据结构-3 堆积木

热门文章

  1. 目标检测特殊层:ROI Align层详解
  2. caffe之特征图可视化及特征提取
  3. Faster R-CNN论文详解
  4. 批处理中setlocal enabledelayedexpansion的作用详细整理
  5. Linux内核文档翻译
  6. Kubernetes基础文档(链接,下载,安装,架构)
  7. 开平推进智慧城市等领域信息化建设及公共数据资源共享
  8. html5 app开发重大消息-腾讯在技术端推进Html5生态发展
  9. asp.net 连接字符串的多种写法
  10. 禁用Cookie在web浏览器中读取/写入c#应用程序