程序是在Crazy_body_01此大佬基础上修改的(感谢),增加了浮点数导出16进制IEEE754格式的功能 https://www.cnblogs.com/zhouzheng/p/5793146.html
#include <stdio.h>
#include <math.h>
#define PI 3.141592
#define DEPTH 255
#define WIDTH 32
int main(void)
{
int i;
float s;
FILE *fp;
fp = fopen("C:/Users/15183/Desktop/FFT/FFT_Quart/TestMif.mif","w");
if(NULL==fp)
printf("Can not creat file!\r\n");
else
{
printf("File created successfully!\n");
fprintf(fp,"WIDTH = %d;\n",WIDTH);
fprintf(fp,"DEPTH = %d;\n",DEPTH);
fprintf(fp,"ADDRESS_RADIX = UNS;\n");
fprintf(fp,"DATA_RADIX = HEX;\n");
fprintf(fp,"CONTENT BEGIN\n");
for(i=0;i<DEPTH;i++)
{
s = cos(PI*i/64);
fprintf(fp," %d : %x;\n",i,*((int *)&s));
}
fprintf(fp,"END;\n");
fclose(fp);
}
}
在这里插入代码片
|