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

Subversion Repositories embedded_risc

[/] [embedded_risc/] [trunk/] [Test_Bench_Verilog/] [Top_level_tb.tf] - Blame information for rev 27

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 hosseinami
/************************************************************
2
 MODULE:                Top Level Test Bench for System On A Chip Design
3
 
4
 FILE NAME:     Top_level_tb.tf
5
 DATE:          May 28th, 2002
6
 AUTHOR:                Hossein Amidi
7
 COMPANY:
8
 CODE TYPE:     Behavioral Transfer Level
9
 
10
 DESCRIPTION:   This module is the top level Behavioral code of System On a Chip Testbench in
11
 Verilog code.
12
 
13
 It will instantiate the following blocks in the ASIC:
14
 
15
 1)   SOC
16
 2)     SDRAM Behavioral Model
17
 
18
 Hossein Amidi
19
 (C) May 2002
20
 
21
*********************************************************/
22
 
23
// DEFINES
24
`timescale 1ns / 10ps
25
 
26
module testbench;
27
 
28
// Parameter
29
`include        "parameter.v"
30
 
31
// Inputs
32
reg clk;
33
reg reset;
34
reg irq;
35
reg ser_rxd;
36
wire [flash_size - 1 : 0]flash_datain;
37
 
38
// Outputs
39
wire [add_size - 1 : 0]addr;
40
wire [cs_size  - 1 : 0]cs;
41
wire ras;
42
wire cas;
43
wire we;
44
wire [dqm_size - 1 : 0]dqm;
45
wire cke;
46
wire [ba_size - 1 : 0]ba;
47
wire pllclk;
48
wire halted;
49
wire ser_txd;
50
wire flash_cle;
51
wire flash_ale;
52
wire flash_ce;
53
wire flash_re;
54
wire flash_we;
55
wire flash_wp;
56
wire flash_rb;
57
wire flash_irq;
58
wire [flash_size - 1 : 0]flash_dataout;
59
 
60
 
61
// Bidirs
62
wire [data_size - 1 : 0]dq;
63
 
64
// Internal wires
65
integer i;
66
wire [flash_size - 1 : 0]wflash_dataout;
67
 
68
reg     pre;
69
reg     vdd;
70
 
71
wire pll_lock;
72
 
73
wire [data_size - 1 : 0]mem_dataout;
74
wire [data_size - 1 : 0]mem_datain;
75
wire [padd_size - 1 : 0]mem_addr;
76
wire memreq;
77
wire rdwrbar;
78
 
79
 
80
 
81
/*---------------------------------Instantiation of Modules-------------------------*/
82
 
83
MEM Memory ( // Input
84
                                        .DataIn(mem_dataout),
85
                                        .Address(mem_addr),
86
                                        .MemReq(memreq),
87
                                        .RdWrBar(rdwrbar),
88
                                        .clock(pllclk),
89
//                                      .pll_lock(pll_lock),
90
                                        // Output
91
                                        .DataOut(mem_datain)
92
                                        );
93
 
94
 
95
k9f1g08u0m  flash_0(    // Input
96
                                                        .ceb(flash_ce),
97
                                                        .cle(flash_cle),
98
                                                        .ale(flash_ale),
99
                                                        .web(flash_we),
100
                                                        .reb(flash_re),
101
                                                        .io(wflash_dataout),
102
                                                        .wpb(flash_wp),
103
                                                        .rbb(flash_rb),
104
                                                        .pre(pre),
105
                                                        .vdd(vdd)
106
                                                        );
107
 
108
 
109
sdram sdram_0(// Inputs
110
                                .Addr(addr),
111
                           .Ba(ba),
112
                           .Clk(pllclk),
113
                                .Cke(cke),
114
                                .Cs_n(cs[0]),
115
                                .Ras_n(ras),
116
                                .Cas_n(cas),
117
                                .We_n(we),
118
                                .Dqm(dm),
119
                                // Inouts
120
                                .Dq(dq[7:0])
121
                                );
122
 
123
 
124
sdram sdram_1(// Inputs
125
                                .Addr(addr),
126
                           .Ba(ba),
127
                           .Clk(pllclk),
128
                                .Cke(cke),
129
                                .Cs_n(cs[0]),
130
                                .Ras_n(ras),
131
                                .Cas_n(cas),
132
                                .We_n(we),
133
                                .Dqm(dm),
134
                                // Inouts
135
                                .Dq(dq[15:8])
136
                                );
137
 
138
sdram sdram_2(// Inputs
139
                                .Addr(addr),
140
                           .Ba(ba),
141
                           .Clk(pllclk),
142
                                .Cke(cke),
143
                                .Cs_n(cs[0]),
144
                                .Ras_n(ras),
145
                                .Cas_n(cas),
146
                                .We_n(we),
147
                                .Dqm(dm),
148
                                // Inouts
149
                                .Dq(dq[23:16])
150
                                );
151
 
152
 
153
sdram sdram_3(// Inputs
154
                                .Addr(addr),
155
                           .Ba(ba),
156
                           .Clk(pllclk),
157
                                .Cke(cke),
158
                                .Cs_n(cs[0]),
159
                                .Ras_n(ras),
160
                                .Cas_n(cas),
161
                                .We_n(we),
162
                                .Dqm(dm),
163
                                // Inouts
164
                                .Dq(dq[31:24])
165
                                );
166
 
167
soc soc_0 (// Input
168
                .clk(clk),
169
                .reset(reset),
170
                .irq(irq),
171
                .ser_rxd(ser_rxd),
172
                          .flash_datain(flash_datain),
173
                          .mem_datain(mem_datain),
174
                          // Output
175
                          .pll_lock(pll_lock),
176
                          .addr(addr),
177
                          .cs(cs),
178
                .ras(ras),
179
                .cas(cas),
180
                .we(we),
181
                          .dqm(dqm),
182
                .cke(cke),
183
                          .ba(ba),
184
                .pllclk(pllclk),
185
                .halted(halted),
186
                .ser_txd(ser_txd),
187
                .flash_cle(flash_cle),
188
                .flash_ale(flash_ale),
189
                .flash_ce(flash_ce),
190
                .flash_re(flash_re),
191
                .flash_we(flash_we),
192
                .flash_wp(flash_wp),
193
                .flash_rb(flash_rb),
194
                .flash_irq(flash_irq),
195
                          .flash_dataout(flash_dataout),
196
                          .mem_dataout(mem_dataout),
197
                          .mem_addr(mem_addr),
198
                          .mem_req(memreq),
199
                          .mem_rdwr(rdwrbar),
200
                          // Inout
201
                          .dq(dq)
202
                );
203
 
204
 
205
 
206
 
207
 
208
initial begin
209
   clk = 0;
210
   reset = 0;
211
   irq = 0;
212
   ser_rxd = 0;
213
        pre = 0;
214
        vdd = 0;
215
        i = 0;
216
end
217
 
218
always
219
begin
220
        #10 clk <= ~clk;
221
end
222
 
223
always
224
begin
225
        #40 ser_rxd <= ~ser_rxd;
226
end
227
 
228
 
229
task init;
230
begin
231
  #10  $display("Reset in process, at time %t",$time);
232
  #40  reset = 1'b1;
233
                 $display("Reset is %d, at time %t",reset,$time);
234
  #20  reset = 1'b0;
235
                 $display("Reset is %d, at time %t",reset,$time);
236
                 $display("PLL Lock is %d, at time %t",soc_0.dll_0.pll_lock,$time);
237
  #150 $display ("Wait for PLL's to Locks, at time %t ", $time);
238
  #80    $display("PLL Lock is %d, at time %t",soc_0.dll_0.pll_lock,$time);
239
  #50  $display ("Setting internal Register of Sub Modules, at time %t", $time);
240
 
241
  #40  $display("Initializing the Memory ..., at time %t",$time);
242
                 for( i = 0 ; i < 31; i = i + 1)
243
                        Memory.MEM_Data[i] = 32'h0;
244
                 for(i = 0; i < 31; i = i + 1)
245
                        $display("memory [%0d] = %h ", i, Memory.MEM_Data[i]);
246
  #40  $display("Memory Initialized to known value , at time %t",$time);
247
 
248
end
249
endtask
250
 
251
 
252
task cpu;
253
begin
254
        #50
255
        $display ("RISC CPU 32-bit Version 1.0. This is the BASIC CONFIDENCE TEST.");
256
   $display ("Loading program memory with %s", "program.txt");
257
   $readmemb("program.txt",Memory.MEM_Data);
258
        $display ("Memory loading is done ... ");
259
 
260
        for(i = 0; i < 80; i = i + 1)
261
                $display("memory [%0d] = %h ", i, Memory.MEM_Data[i]);
262
end
263
endtask
264
 
265
initial
266
begin
267
        init;
268
        cpu;
269
   $display ("End of Simulation, at time %t", $time);
270
        #2750
271
   $stop;
272
   $finish;
273
end
274
 
275
 
276
endmodule
277
 

powered by: WebSVN 2.1.0

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