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

Subversion Repositories mips789

[/] [mips789/] [branches/] [avendor/] [tools/] [genmif.c] - Blame information for rev 60

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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