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

Subversion Repositories mips789

[/] [mips789/] [tags/] [v001/] [tools_source_code/] [gensim.c] - Blame information for rev 4

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

Line No. Rev Author Line
1 4 mcupro
#include "stdio.h" 
2
main(int file_no,char*file_name[])
3
{
4
    int j=4,i=0 ;
5
    int cntr ;
6
    char str1[100],str2[111];
7
   /*
8
    FILE*ff=fopen(file_name[1],"r");
9
    FILE*ft=fopen(file_name[2],"w");
10
    */
11
    FILE*ff=fopen("code.txt","r");
12
    FILE*ft=fopen("sim_ram.v","w");
13
    for(j=0;j<4;++j)
14
    {
15
        cntr = -10;
16
        fprintf(ft,"module sim_syn_ram%d(\n",j);
17
        fprintf(ft,"        data,\n");
18
        fprintf(ft,"        wraddress,\n");
19
        fprintf(ft,"        rdaddress_a,\n");
20
        fprintf(ft,"        rdaddress_b,\n");
21
        fprintf(ft,"        wren,\n");
22
        fprintf(ft,"        clock,\n");
23
        fprintf(ft,"        qa,\n");
24
        fprintf(ft,"        qb);\n\n");
25
        fprintf(ft,"    input   [7:0]  data;\n");
26
        fprintf(ft,"    input   [10:0]  wraddress;\n");
27
        fprintf(ft,"    input   [10:0]  rdaddress_a;\n");
28
        fprintf(ft,"    input   [10:0]  rdaddress_b;\n");
29
        fprintf(ft,"    input     wren;\n");
30
        fprintf(ft,"    reg [7:0]  r_data;\n");
31
        fprintf(ft,"    reg [10:0]  r_wraddress;\n");
32
        fprintf(ft,"    reg [10:0]  r_rdaddress_a;\n");
33
        fprintf(ft,"    reg [10:0]  r_rdaddress_b;\n");
34
        fprintf(ft,"    reg   r_wren;\n");
35
        fprintf(ft,"    input     clock;\n");
36
        fprintf(ft,"    output  [7:0]  qa;\n");
37
        fprintf(ft,"    output  [7:0]  qb;\n");
38
        fprintf(ft,"    reg [7:0] mem_bank  [0:2047]  ;\n");
39
 
40
        fprintf(ft,"      initial begin   \n       ");
41
        rewind(ff);
42
        i=-1 ;
43
 
44
        while(fgets(str2,100,ff))
45
        {
46
            ++i ;
47
            if(3==j)
48
            {
49
                str2[2]=0 ;
50
                fprintf(ft,"mem_bank[%d] = 'h%s ; ",i,&str2[0]);
51
                ++cntr ;
52
                if(!(cntr%10))
53
                {
54
                    cntr==0 ;
55
                    fprintf(ft,"\n       ");
56
                }
57
            }
58
            else
59
            if(2==j)
60
            {
61
                str2[4]=0 ;
62
 
63
                fprintf(ft,"mem_bank[%d] = 'h%s ; ",i,&str2[2]);
64
 
65
                ++cntr ;
66
                if(!(cntr%10))
67
                {
68
                    cntr==0 ;
69
                    fprintf(ft,"\n       ");
70
                }
71
            }
72
            else
73
            if(1==j)
74
            {
75
                str2[6]=0 ;
76
                fprintf(ft,"mem_bank[%d] = 'h%s ; ",i,&str2[4]);
77
 
78
                ++cntr ;
79
                if(!(cntr%10))
80
                {
81
                    cntr==0 ;
82
                    fprintf(ft,"\n       ");
83
                }
84
            }
85
            else
86
            if(0==j)
87
            {
88
                str2[8]=0 ;
89
                fprintf(ft,"mem_bank[%d] = 'h%s ; ",i,&str2[6]);
90
 
91
                ++cntr ;
92
                if(!(cntr%10))
93
                {
94
                    cntr==0 ;
95
                    fprintf(ft,"\n       ");
96
                }
97
            }
98
        }
99
        fprintf(ft,"    \n       end\n");
100
        fprintf(ft,"    always @ (posedge clock) if (r_wren) mem_bank[r_wraddress]<=r_data;\n");
101
        fprintf(ft,"    always @ (posedge clock)\n");
102
        fprintf(ft,"    begin\n");
103
        fprintf(ft,"        r_data<=data;\n");
104
        fprintf(ft,"        r_wraddress<=wraddress;\n");
105
        fprintf(ft,"        r_rdaddress_a<=rdaddress_a;\n");
106
        fprintf(ft,"        r_rdaddress_b<=rdaddress_b;\n");
107
        fprintf(ft,"        r_wren<=wren;\n");
108
        fprintf(ft,"    end\n");
109
        fprintf(ft,"    assign qa =mem_bank[r_rdaddress_a];\n");
110
        fprintf(ft,"    assign qb =mem_bank[r_rdaddress_b];\n");
111
        fprintf(ft,"endmodule\n\n\n\n");
112
    }
113
}

powered by: WebSVN 2.1.0

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