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

Subversion Repositories mips789

[/] [mips789/] [branches/] [avendor/] [tools/] [gensim.c] - Blame information for rev 59

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

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

powered by: WebSVN 2.1.0

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