OpenCores
URL https://opencores.org/ocsvn/mips789/mips789/trunk

Subversion Repositories mips789

[/] [mips789/] [branches/] [mcupro/] [tools_source_code/] [genmif.c] - Blame information for rev 51

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 mcupro
#include "stdio.h"
2
#include "stdlib.h"
3
#define DEFAULT_LEN "2048"
4
void main(int argc,char *argv[])
5
{
6
    int j=4,i=0 ;
7
    char str1[100],str2[111];
8
    FILE*ff=fopen("code.txt","r");
9
    FILE*ft ;
10
    for(j=0;j<4;++j)
11
    {
12
        if(j==0)
13
        ft=fopen("qu2_ram0.mif","w");
14
        else if(j==1)
15
        ft=fopen("qu2_ram1.mif","w");
16
        else if(j==2)
17
        ft=fopen("qu2_ram2.mif","w");
18
        else if(j==3)
19
        ft=fopen("qu2_ram3.mif","w");
20
        fprintf(ft,"WIDTH=8;\n");
21
        fprintf(ft,"DEPTH=%s;\n\n",(NULL!=argv[1])?argv[1]:DEFAULT_LEN);
22
        fprintf(ft,"ADDRESS_RADIX=HEX;\n");
23
        fprintf(ft,"DATA_RADIX=HEX;\n\n");
24
        fprintf(ft,"CONTENT BEGIN \n");
25
        rewind(ff);
26
        i=-1 ;
27
        while(fgets(str2,100,ff))
28
        {
29
            ++i ;
30
            if(3==j)
31
            {
32
                str2[2]=0 ;
33
                fprintf(ft,"   %X  :    %s;\n  ",i,&str2[0]);
34
            }
35
            else if(2==j)
36
            {
37
                str2[4]=0 ;
38
                fprintf(ft,"   %X  :    %s;\n  ",i,&str2[2]);
39
            }
40
            else if(1==j)
41
            {
42
                str2[6]=0 ;
43
                fprintf(ft,"   %X  :    %s;\n  ",i,&str2[4]);
44
            }
45
            else if(0==j)
46
            {
47
                str2[8]=0 ;
48
                fprintf(ft,"   %X  :    %s;\n  ",i,&str2[6]);
49
            }
50
        }
51
        fprintf(ft,"END;");
52
    }
53
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.