集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2431|回复: 2

请问有人会用C语言生成.mif文件么?

[复制链接]
I2C 发表于 2010-8-10 16:18:33 | 显示全部楼层 |阅读模式
请问有人会用C语言生成.mif文件么?
 楼主| I2C 发表于 2010-8-10 16:19:33 | 显示全部楼层
打开vc6.0,新建win30 console application工程输入以下代码,编译,运行。

#include "string.h"
#include "stdlib.h"
#include "stdio.h"
#include "math.h"

main()
{
double  PI=3.1415926535;
double i;
    int x,y;
    char a,b;
    char *c;
char d[10];
    FILE *fp;
   
    fp=fopen("c:\\sin.mif","wt+");
   
    c="-- Copyright (C) 1991-2005 Altera Corporation\n";
    fprintf(fp,c);
    c="-- Your use of Altera Corporation's design tools, logic functions\n";
    fprintf(fp,c);
    c="-- and other software and tools, and its AMPP partner logic\n";
    fprintf(fp,c);
    c="-- functions, and any output files any of the foregoing\n";
    fprintf(fp,c);
    c="-- (including device programming or simulation files), and any\n";
    fprintf(fp,c);
    c="-- associated documentation or information are expressly subject\n";
    fprintf(fp,c);
    c="-- to the terms and conditions of the Altera Program License\n";
    fprintf(fp,c);
    c="-- Subscription Agreement, Altera MegaCore Function License\n";
    fprintf(fp,c);
    c="-- Agreement, or other applicable license agreement, including,\n";
    fprintf(fp,c);
    c="-- without limitation, that your use is for the sole purpose of\n";
    fprintf(fp,c);
    c="-- programming logic devices manufactured by Altera and sold by\n";
    fprintf(fp,c);
    c="-- Altera or its authorized distributors. Please refer to the\n";
    fprintf(fp,c);
    c="-- applicable agreement for further details.\n\n";
    fprintf(fp,c);
    c="-- Quartus II generated Memory Initialization File (.mif)\n\n";
    fprintf(fp,c);
   
    c="WIDTH=8;\nDEPTH=1024;\n\nADDRESS_RADIX=UNS;\nDATA_RADIX=UNS;\n\nCONTENT BEGIN\n";
    fprintf(fp,c);
   
    for(i=0;i<=1023;i=i+1)
    {
       fprintf(fp,"\t");
       x=i;
       itoa(x,d,10);
       fprintf(fp,d);
       fprintf(fp,"\t:\t");
       y=(sin(2*PI*x/1024)+1)*255/2;
       itoa(y,d,10);
       fprintf(fp,d);

     fprintf(fp,";");
     fprintf(fp,"\n");
    }
    fprintf(fp,"END;\n");
    fclose(fp);
    printf("\n\t\tcreate sin.mif successfully!\n\n\t\tpress any key to exit!");
    getch();
    exit(0);
}
Esmiamor 发表于 2015-7-22 16:47:24 | 显示全部楼层
打开vc6.0,新建win30 console application工程输入以下代码,编译,运行
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-5-6 14:27 , Processed in 0.058055 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表