日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab产生mif 文件,生成.mif文件的matlab程序

發布時間:2024/9/19 循环神经网络 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab产生mif 文件,生成.mif文件的matlab程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

天氣: 晴朗

心情: 高興

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程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。