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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [verif/] [tb/] [tb_top.v] - Blame information for rev 27

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

Line No. Rev Author Line
1 15 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////                                                              ////
4
////  This file is part of the Turbo 8051 cores project           ////
5
////  http://www.opencores.org/cores/turbo8051/                   ////
6
////                                                              ////
7
////  Description                                                 ////
8
////  Turbo 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
`timescale  1ns/1ps
45
 
46
`include "tb_defines.v"
47
 
48
module tb_top;
49
 
50
//--------------------------------------------------------------
51
// Target ID Mapping
52
// 4'b0100 -- MAC core
53
// 4'b0011 -- UART
54
// 4'b0010 -- SPI core
55
// 4'b0001 -- External RAM
56
// 4'b0000 -- External ROM
57
//--------------------------------------------------------------
58
`define ADDR_SPACE_MAC  4'b0100
59
`define ADDR_SPACE_UART 4'b0011
60
`define ADDR_SPACE_SPI  4'b0010
61
`define ADDR_SPACE_RAM  4'b0001
62
`define ADDR_SPACE_ROM  4'b0000
63
 
64
reg    reset_n;
65
reg    reset;
66
reg    xtal_clk;
67
reg    ref_clk_125;
68
wire   app_clk;
69
reg    ref_clk_50;
70
reg    uart_clk_16x;
71
 
72
 
73
parameter XTAL_CLK_PERIOD = 40; // 25Mhz
74
parameter APP_CLK_PERIOD = 10;
75
parameter REF_CLK_125_PERIOD = 8;
76
parameter REF_CLK_50_PERIOD = 20;
77
parameter UART_REF_CLK_PERIOD = 20;
78
 
79
reg[31:0] events_log;
80
 
81
initial
82
begin
83
        reset_n = 1;
84
   #100 reset_n = 0;
85
   #100 reset_n = 1;
86
end
87
 
88
 
89
initial begin
90
  xtal_clk = 1'b0;
91
  forever #(XTAL_CLK_PERIOD/2.0) xtal_clk = ~xtal_clk;
92
end
93
 
94
 
95
//initial begin
96
//  app_clk = 1'b0;
97
//  forever #(APP_CLK_PERIOD/2.0) app_clk = ~app_clk;
98
//end
99
 
100
initial begin
101
  ref_clk_125 = 1'b0;
102
  forever #(REF_CLK_125_PERIOD/2.0) ref_clk_125 = ~ref_clk_125;
103
end
104
 
105
initial begin
106
  ref_clk_50 = 1'b0;
107
  forever #(REF_CLK_50_PERIOD/2.0) ref_clk_50 = ~ref_clk_50;
108
end
109
 
110
 
111
initial begin
112
  uart_clk_16x = 1'b0;
113
  forever #(UART_REF_CLK_PERIOD/2.0) uart_clk_16x = ~uart_clk_16x;
114
end
115
 
116
 
117
wire [7:0]   phy_txd            ;
118
wire [7:0]   phy_rxd            ;
119
 
120
//---------------------------------
121
// Reg Bus Interface Signal
122
//---------------------------------
123
reg                reg_cs     ;
124
reg [3:0]          reg_id     ;
125
reg                reg_wr         ;
126
reg  [12:0]        reg_addr       ;
127
reg  [31:0]        reg_wdata      ;
128
reg  [3:0]         reg_be         ;
129
 
130
// Outputs
131
wire  [31:0]        reg_rdata      ;
132
wire                reg_ack        ;
133
 
134
 
135
 
136
wire         spi_sck            ;
137
wire         spi_so             ;
138
wire         spi_si             ;
139
wire [3:0]   spi_cs_n           ;
140
 
141
wire         clkout             ;
142
wire         reset_out_n        ;
143
 
144
//----------------------------------------
145
// 8051 core ROM related signals
146
//---------------------------------------
147
wire  [15:0]   wb_xrom_adr       ; // instruction address
148
wire           wb_xrom_ack       ; // instruction acknowlage
149
wire           wb_xrom_err       ; // instruction error
150
wire           wb_xrom_wr        ; // instruction error
151
wire    [31:0] wb_xrom_rdata     ; // rom data input
152
wire   [31:0]  wb_xrom_wdata     ; // rom data input
153
 
154
wire           wb_xrom_stb       ; // instruction strobe
155
wire           wb_xrom_cyc       ; // instruction cycle
156
 
157
 
158
//----------------------------------------
159
// 8051 core RAM related signals
160
//---------------------------------------
161
wire   [15:0] wb_xram_adr        ; // data-ram address
162
wire          wb_xram_ack        ; // data-ram acknowlage
163
wire          wb_xram_err        ; // data-ram error
164
wire          wb_xram_wr         ; // data-ram error
165
wire   [7:0]  wb_xram_rdata      ; // ram data input
166
wire   [7:0]  wb_xram_wdata      ; // ram data input
167
 
168
wire          wb_xram_stb        ; // data-ram strobe
169
wire          wb_xram_cyc        ; // data-ram cycle
170
 
171
//----------------------------------------
172
 
173
core  u_core (
174
 
175
             . reset_n             (reset_n            ),
176
             . fastsim_mode        (1'b1               ),
177 27 dinesha
 
178
          `ifdef INTERNAL_ROM
179
             . mastermode          (1'b1               ),
180
          `elsif EXTERNAL_ROM
181
             . mastermode          (1'b1               ),
182
          `else
183
             . mastermode          (1'b0               ),
184
          `endif
185
 
186 15 dinesha
             . xtal_clk            (xtal_clk           ),
187
             . clkout              (app_clk            ),
188
             . reset_out_n         (reset_out_n        ),
189
 
190
        // Reg Bus Interface Signal
191
             . ext_reg_cs          (reg_cs             ),
192
             . ext_reg_tid         (reg_id             ),
193
             . ext_reg_wr          (reg_wr             ),
194
             . ext_reg_addr        (reg_addr[12:0]     ),
195
             . ext_reg_wdata       (reg_wdata          ),
196
             . ext_reg_be          (reg_be             ),
197
 
198
            // Outputs
199
             . ext_reg_rdata       (reg_rdata          ),
200
             . ext_reg_ack         (reg_ack            ),
201
 
202
 
203
          // Line Side Interface TX Path
204
             .phy_tx_en            (phy_tx_en          ),
205
             .phy_txd              (phy_txd            ),
206
             .phy_tx_clk           (phy_tx_clk         ),
207
 
208
          // Line Side Interface RX Path
209
             .phy_rx_clk           (phy_rx_clk         ),
210
             .phy_rx_dv            (phy_rx_dv          ),
211
             .phy_rxd              (phy_rxd            ),
212
 
213
          //MDIO interface
214
             .MDC                  (MDC                ),
215
             .MDIO                 (MDIO               ),
216
 
217
 
218
       // UART Line Interface
219
             .si                   (si                 ),
220
             .so                   (so                 ),
221
 
222
 
223
             .spi_sck              (spi_sck            ),
224
             .spi_so               (spi_so             ),
225
             .spi_si               (spi_si             ),
226
             .spi_cs_n             (spi_cs_n           ),
227
 
228
         // External ROM interface
229
               .wb_xrom_adr        (wb_xrom_adr        ),
230
               .wb_xrom_ack        (wb_xrom_ack        ),
231
               .wb_xrom_err        (wb_xrom_err        ),
232
               .wb_xrom_wr         (wb_xrom_wr         ),
233
               .wb_xrom_rdata      (wb_xrom_rdata      ),
234
               .wb_xrom_wdata      (wb_xrom_wdata      ),
235
 
236
               .wb_xrom_stb        (wb_xrom_stb        ),
237
               .wb_xrom_cyc        (wb_xrom_cyc        ),
238
 
239
         // External RAM interface
240
               .wb_xram_adr        (wb_xram_adr        ),
241
               .wb_xram_ack        (wb_xram_ack        ),
242
               .wb_xram_err        (wb_xram_err        ),
243
               .wb_xram_wr         (wb_xram_wr         ),
244
               .wb_xram_rdata      (wb_xram_rdata      ),
245
               .wb_xram_wdata      (wb_xram_wdata      ),
246
 
247
               .wb_xram_stb        (wb_xram_stb        ),
248
               .wb_xram_cyc        (wb_xram_cyc        ),
249
 
250
             `ifdef INTERNAL_ROM
251
               .ea_in              (1'b1               ) // internal ROM
252
             `else
253
               .ea_in              (1'b0               ) // external ROM
254
             `endif
255
 
256
        );
257
 
258
 
259
  oc8051_xrom oc8051_xrom1
260
      (
261
             .rst                ( !reset_n         ),
262
             .clk                ( app_clk          ),
263
             .addr               ( wb_xrom_adr      ),
264
             .data               ( wb_xrom_rdata    ),
265
             .stb_i              ( wb_xrom_stb      ),
266
             .cyc_i              ( wb_xrom_cyc      ),
267
             .ack_o              ( wb_xrom_ack      )
268
      );
269
 
270
   defparam oc8051_xrom1.DELAY = 0;
271
 
272
 
273
//
274
// external data ram
275
//
276
oc8051_xram oc8051_xram1 (
277
          .clk               (app_clk       ),
278
          .rst               (!reset_n      ),
279
          .wr                (wb_xram_wr    ),
280
          .addr              (wb_xram_adr   ),
281
          .data_in           (wb_xram_wdata ),
282
          .data_out          (wb_xram_rdata ),
283
          .ack               (wb_xram_ack   ),
284
          .stb               (wb_xram_stb   )
285
      );
286
 
287
 
288
defparam oc8051_xram1.DELAY = 2;
289
 
290
 
291
 
292
 
293
tb_eth_top u_tb_eth (
294
 
295
               . REFCLK_50_MHz     (ref_clk_50         ), // 50 MHz Reference clock input
296
               . REFCLK_125_MHz    (ref_clk_125        ), // 125 MHz reference clock
297
               . transmit_enable   (1'b1               ), // transmit enable for testbench
298
 
299
          // Separate interfaces for each MII port type
300
 
301
          // Full MII, 4-bit interface
302
          // Transmit interface
303
               . MII_RXD           (phy_rxd[3:0]       ), // Receive data (output)
304
               . MII_RX_CLK        (phy_rx_clk         ), // Receive clock for MII (output)
305
               . MII_CRS           (phy_crs            ), // carrier sense (output)
306
               . MII_COL           (                   ), // Collision signal for MII (output)
307
               . MII_RX_DV         (phy_rx_dv          ), // Receive data valid for MII (output)
308
 
309
          // Receive interface
310
               . MII_TXD           (phy_txd[3:0]       ), // Transmit data (input)
311
               . MII_TX_EN         (phy_tx_en          ), // Tx enable (input)
312
               . MII_TX_CLK        (phy_tx_clk         ), // Transmit clock (output)
313
 
314
          // Reduced MII, 2-bit interface
315
          // Transmit interface
316
               . RMII_RXD          (                   ), // Receive data (output)
317
               . RMII_CRS_DV       (                   ), // carrier sense (output)
318
          // Receive interface
319
               . RMII_TXD          (                   ), // Transmit data (input)
320
               . RMII_TX_EN        (                   ), // Tx enable (input)
321
 
322
          // Serial MII interface
323
               . SMII_RXD          (                   ), // Receive data (output)
324
               . SMII_TXD          (                   ), // Transmit data (input)
325
               . SMII_SYNC         (                   ), // SMII SYNC signal (input)                
326
 
327
          // GMII, 8-bit/10-bit interface
328
          // Transmit interface
329
               . GMII_RXD          (                   ), // Receive data (output)
330
               . GMII_RX_CLK       (                   ), // Receive clock for MII (output)
331
               . GMII_CRS          (                   ), // carrier sense (output)
332
               . GMII_COL          (                   ), // Collision signal for MII (output)
333
               . GMII_RX_DV        (                   ), // Receive data valid for MII (output)
334
 
335
          // Receive interface
336
               . GMII_TXD          (                   ), // Transmit data (input)
337
               . GMII_TX_EN        (                   ), // Tx enable (input)
338
               . GMII_TX_CLK       (                   ), // Transmit clock (output)
339
               . GMII_GTX_CLK      (                   ), // Gigabit Tx clock (input), 125 MHz
340
 
341
              // MII management interface
342
               .MDIO               (MDC                ), // serial I/O data
343
               .MDC                (MDC                )  // clock
344
 
345
 
346
 
347
 
348
      );
349
 
350
 uart_agent tb_uart (
351
               . test_clk          (uart_clk_16x       ),
352
               . sin               (si                 ),
353
               . dsr_n             (                   ),
354
               . cts_n             (                   ),
355
               . dcd_n             (                   ),
356
 
357
               . sout              (so                 ),
358
               . dtr_n             (1'b0               ),
359
               . rts_n             (1'b0               ),
360
               . out1_n            (1'b0               ),
361
               . out2_n            (1'b0               )
362
       );
363
 
364
 
365
//----------------------- SPI Agents
366
 
367
m25p20 i_m25p20_0 (
368
               .c                  (spi_sck            ),
369
               .s                  (spi_cs_n[0]        ), // Include selection logic
370
               .w                  (1'b1               ), // Write protect is always disabled
371
               .hold               (1'b1               ), // Hold support not used
372
               .data_in            (spi_so             ),
373
               .data_out           (spi_si             )
374
             );
375
 
376
 
377
AT45DB321 i_AT45DB321_0 (
378
               .CSB                (spi_cs_n[1]        ),
379
               .SCK                (spi_sck            ),
380
               .SI                 (spi_so             ),
381
               .WPB                (1'b1               ),
382
               .RESETB             (1'b1               ),
383
               .RDY_BUSYB          (                   ),
384
               .SO                 (spi_si             )
385
      );
386
/***************
387
spi_agent_3120 spi_agent_3120_0 (
388
               .cs_b               (spi_cs_n[2]        ),
389
               .spi_din            (spi_si             ),
390
               .spi_dout           (spi_so             ),
391
               .spi_clk            (spi_sck            )
392
       );
393
 
394
spi_agent_3120 spi_agent_3120_1 (
395
               .cs_b               (spi_cs_n[3]        ),
396
               .spi_din            (spi_si             ),
397
               .spi_dout           (spi_so             ),
398
               .spi_clk            (spi_sck            )
399
       );
400
*****************/
401
 
402
tb_glbl  tb_glbl ();
403
 
404
 
405
initial begin
406
   if ( $test$plusargs("DUMP") ) begin
407
          $fsdbDumpfile("../dump/test_1.fsdb");
408
      $fsdbDumpvars;
409
      $fsdbDumpon;
410
   end
411
end
412
 
413
initial begin
414
 
415
  `TB_GLBL.init;
416
   #1000 wait(reset_out_n == 1);
417
 
418
   if ( $test$plusargs("gmac_test_1") )
419
       gmac_test1();
420
   else if ( $test$plusargs("uart_test_1") )
421
       uart_test1();
422
   else if ( $test$plusargs("spi_test_1") )
423
       spi_test1();
424
   else begin
425
     // 8051 Test Cases
426
     #80000000
427
     $display("time ",$time, "\n faulire: end of time\n \n");
428
   end
429
 
430
   `TB_GLBL.test_stats;
431
   `TB_GLBL.test_finish;
432
   #1000 $finish;
433
end
434
 
435
wire [7:0] p2_out = u_core.u_8051_core.p2_o;
436
wire [7:0] p3_out = u_core.u_8051_core.p3_o;
437
always @(p2_out or p3_out)
438
begin
439
  if((p2_out == 8'haa) &&      // fib.c
440
     (p3_out == 8'haa )) begin
441
      $display("################################");
442
      $display("time ",$time, " Passed");
443
      $display("################################");
444
      #100
445
      $finish;
446
  end else if(p2_out == 8'h55) begin     // fib.c
447
      $display("");
448
      $display("time ",$time," Error: %h", p3_out);
449
      $display("");
450
      #100
451
      $finish;
452
  end
453
end
454
 
455
 
456
 
457
 
458
`include "gmac_test1.v"
459
`include "uart_test1.v"
460
`include "spi_test1.v"
461
`include "tb_tasks.v"
462
`include "spi_tasks.v"
463
 
464
 
465
endmodule
466
`include "tb_glbl.v"

powered by: WebSVN 2.1.0

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