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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [verif/] [tb/] [tb_top.v] - Blame information for rev 11

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

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////                                                              ////
4
////  This file is part of the OMS 8051 cores project             ////
5
////  http://www.opencores.org/cores/oms8051/                     ////
6
////                                                              ////
7
////  Description                                                 ////
8
////  OMS 8051 definitions.                                       ////
9
////                                                              ////
10
////  To Do:                                                      ////
11
////    nothing                                                   ////
12
////                                                              ////
13
////  Author(s):                                                  ////
14
////      - Dinesh Annayya, dinesha@opencores.org                 ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
 
43
 
44
 
45
`include "tb_defines.v"
46
 
47
module tb_top;
48
 
49
 
50
reg    reset_n;
51
reg    reset;
52
reg    xtal_clk;
53
reg    ref_clk_125;
54
wire   app_clk;
55
reg    ref_clk_50;
56
reg    uart_clk_16x;
57
 
58
 
59
parameter XTAL_CLK_PERIOD = 10; // 100MHZ 40; // 25Mhz
60
parameter APP_CLK_PERIOD = 10;
61
parameter REF_CLK_125_PERIOD = 8;
62
parameter REF_CLK_50_PERIOD = 20;
63
parameter UART_REF_CLK_PERIOD = 20;
64
 
65
reg[31:0] events_log;
66
 
67
initial
68
begin
69
        reset_n = 1;
70
   #100 reset_n = 0;
71
   #100 reset_n = 1;
72
end
73
 
74
 
75
initial begin
76
  xtal_clk = 1'b0;
77
  forever #(XTAL_CLK_PERIOD/2.0) xtal_clk = ~xtal_clk;
78
end
79
 
80
 
81
//initial begin
82
//  app_clk = 1'b0;
83
//  forever #(APP_CLK_PERIOD/2.0) app_clk = ~app_clk;
84
//end
85
 
86
initial begin
87
  ref_clk_125 = 1'b0;
88
  forever #(REF_CLK_125_PERIOD/2.0) ref_clk_125 = ~ref_clk_125;
89
end
90
 
91
initial begin
92
  ref_clk_50 = 1'b0;
93
  forever #(REF_CLK_50_PERIOD/2.0) ref_clk_50 = ~ref_clk_50;
94
end
95
 
96
 
97
initial begin
98
  uart_clk_16x = 1'b0;
99
  forever #(UART_REF_CLK_PERIOD/2.0) uart_clk_16x = ~uart_clk_16x;
100
end
101
 
102
 
103
wire [3:0]   phy_txd            ;
104
wire [3:0]   phy_rxd            ;
105
 
106
//---------------------------------
107
// Reg Bus Interface Signal
108
//---------------------------------
109 11 dinesha
reg                reg_cs        ;
110
reg [3:0]          reg_id        ;
111
reg                reg_wr        ;
112
reg  [14:0]        reg_addr      ;
113
reg  [7:0]         reg_wdata     ;
114
reg                reg_be        ;
115 2 dinesha
 
116
// Outputs
117 11 dinesha
wire  [7:0]        reg_rdata     ;
118
wire               reg_ack       ;
119 2 dinesha
 
120 11 dinesha
reg                master_mode   ;
121
reg                ea_in         ;   // 1--> Internal Memory
122 2 dinesha
 
123 11 dinesha
 
124
wire               spi_sck       ;
125
wire               spi_so        ;
126
wire               spi_si        ;
127
wire [3:0]         spi_cs_n      ;
128 2 dinesha
 
129 11 dinesha
wire               clkout        ;
130
wire               reset_out_n   ;
131 2 dinesha
 
132
//----------------------------------------
133
 
134
digital_core  u_core (
135
 
136
             . reset_n             (reset_n            ),
137
             . fastsim_mode        (1'b1               ),
138
             . mastermode          (master_mode        ),
139
 
140
             . xtal_clk            (xtal_clk           ),
141
             . clkout              (app_clk            ),
142
             . reset_out_n         (reset_out_n        ),
143 10 dinesha
             . ea_in               (ea_in              ), // internal ROM
144 2 dinesha
 
145
        // Reg Bus Interface Signal
146
             . ext_reg_cs          (reg_cs             ),
147
             . ext_reg_tid         (reg_id             ),
148
             . ext_reg_wr          (reg_wr             ),
149
             . ext_reg_addr        (reg_addr[14:0]     ),
150
             . ext_reg_wdata       (reg_wdata          ),
151
 
152
            // Outputs
153
             . ext_reg_rdata       (reg_rdata          ),
154
             . ext_reg_ack         (reg_ack            ),
155
 
156
 
157
 
158
       // UART Line Interface
159
             .si                   (si                 ),
160
             .so                   (so                 ),
161
 
162
 
163
             .spi_sck              (spi_sck            ),
164
             .spi_so               (spi_so             ),
165
             .spi_si               (spi_si             ),
166 10 dinesha
             .spi_cs_n             (spi_cs_n           )
167 2 dinesha
 
168
 
169
        );
170
 
171
 
172
 uart_agent tb_uart (
173
               . test_clk          (uart_clk_16x       ),
174
               . sin               (si                 ),
175
               . dsr_n             (                   ),
176
               . cts_n             (                   ),
177
               . dcd_n             (                   ),
178
 
179
               . sout              (so                 ),
180
               . dtr_n             (1'b0               ),
181
               . rts_n             (1'b0               ),
182
               . out1_n            (1'b0               ),
183
               . out2_n            (1'b0               )
184
       );
185
 
186
 
187
//----------------------- SPI Agents
188
 
189
m25p20 i_m25p20_0 (
190
               .c                  (spi_sck            ),
191
               .s                  (spi_cs_n[0]        ), // Include selection logic
192
               .w                  (1'b1               ), // Write protect is always disabled
193
               .hold               (1'b1               ), // Hold support not used
194
               .data_in            (spi_so             ),
195
               .data_out           (spi_si             )
196
             );
197
 
198
 
199
AT45DB321 i_AT45DB321_0 (
200
               .CSB                (spi_cs_n[1]        ),
201
               .SCK                (spi_sck            ),
202
               .SI                 (spi_so             ),
203
               .WPB                (1'b1               ),
204
               .RESETB             (1'b1               ),
205
               .RDY_BUSYB          (                   ),
206
               .SO                 (spi_si             )
207
      );
208
/***************
209
spi_agent_3120 spi_agent_3120_0 (
210
               .cs_b               (spi_cs_n[2]        ),
211
               .spi_din            (spi_si             ),
212
               .spi_dout           (spi_so             ),
213
               .spi_clk            (spi_sck            )
214
       );
215
 
216
spi_agent_3120 spi_agent_3120_1 (
217
               .cs_b               (spi_cs_n[3]        ),
218
               .spi_din            (spi_si             ),
219
               .spi_dout           (spi_so             ),
220
               .spi_clk            (spi_sck            )
221
       );
222
*****************/
223
 
224
tb_glbl  tb_glbl ();
225
 
226
 
227
`ifdef DUMP_ENABLE
228
initial begin
229
   if ( $test$plusargs("DUMP") ) begin
230
          $fsdbDumpfile("../dump/test_1.fsdb");
231
      $fsdbDumpvars;
232
      $fsdbDumpon;
233
   end
234
end
235
`endif
236
 
237
initial begin //{
238
   $display ("--> Dumpping the design");
239
   $shm_open("simvision.shm");
240
   $shm_probe("AC");
241
end //}
242
 
243
 
244
initial begin
245
 
246
   if ( $test$plusargs("INTERNAL_ROM") )  begin
247
      ea_in       = 1;
248
      master_mode = 1;
249
   end else if ( $test$plusargs("EXTERNAL_ROM") ) begin
250
      ea_in       = 0;
251
      master_mode = 1;
252
   end else begin
253
      ea_in       = 0;
254
      master_mode = 0;
255
   end
256
 
257
  `TB_GLBL.init;
258
 
259
   #1000 wait(reset_out_n == 1);
260
 
261
   if ( $test$plusargs("uart_test_1") )
262
       uart_test1();
263
   else if ( $test$plusargs("spi_test_1") )
264
       spi_test1();
265
   else begin
266
     // 8051 Test Cases
267
     #80000000
268
     $display("time ",$time, "\n faulire: end of time\n \n");
269
   end
270
 
271
   `TB_GLBL.test_stats;
272
   `TB_GLBL.test_finish;
273
   #1000 $finish;
274
end
275
 
276
wire [7:0] p2_out = u_core.u_8051_core.p2_o;
277
wire [7:0] p3_out = u_core.u_8051_core.p3_o;
278
always @(p2_out or p3_out)
279
begin
280
  if((p2_out == 8'haa) &&      // fib.c
281
     (p3_out == 8'haa )) begin
282
      $display("################################");
283 4 dinesha
      $display("TEST STATUS : PASSED ");
284 2 dinesha
      $display("################################");
285
      #100
286
      $finish;
287
  end else if(p2_out == 8'h55) begin     // fib.c
288
      $display("");
289
      $display("time ",$time," Error: %h", p3_out);
290 4 dinesha
      $display("TEST STATUS : FAILED ");
291 2 dinesha
      $display("");
292
      #100
293
      $finish;
294
  end
295
end
296
 
297
 
298
 
299
 
300
`include "uart_test1.v"
301
`include "spi_test1.v"
302
`include "tb_tasks.v"
303
`include "spi_tasks.v"
304
 
305
 
306
endmodule
307
`include "tb_glbl.v"

powered by: WebSVN 2.1.0

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