I2C 发表于 2010-8-10 16:18:33

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

请问有人会用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()
{
doublePI=3.1415926535;
double i;
    int x,y;
    char a,b;
    char *c;
char d;
    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]
查看完整版本: 请问有人会用C语言生成.mif文件么?