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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [verilog/] [orpsoc_testbench.v] - Blame information for rev 863

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 julius
//////////////////////////////////////////////////////////////////////
2 360 julius
///                                                               //// 
3
/// ORPSoC testbench                                              ////
4
///                                                               ////
5
/// Instantiate ORPSoC, monitors, provide stimulus                ////
6
///                                                               ////
7
/// Julius Baxter, julius@opencores.org                           ////
8
///                                                               ////
9 6 julius
//////////////////////////////////////////////////////////////////////
10
////                                                              ////
11 360 julius
//// Copyright (C) 2009, 2010 Authors and OPENCORES.ORG           ////
12 6 julius
////                                                              ////
13
//// This source file may be used and distributed without         ////
14
//// restriction provided that this copyright statement is not    ////
15
//// removed from the file and that any derivative work contains  ////
16
//// the original copyright notice and the associated disclaimer. ////
17
////                                                              ////
18
//// This source file is free software; you can redistribute it   ////
19
//// and/or modify it under the terms of the GNU Lesser General   ////
20
//// Public License as published by the Free Software Foundation; ////
21
//// either version 2.1 of the License, or (at your option) any   ////
22
//// later version.                                               ////
23
////                                                              ////
24
//// This source is distributed in the hope that it will be       ////
25
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
26
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
27
//// PURPOSE.  See the GNU Lesser General Public License for more ////
28
//// details.                                                     ////
29
////                                                              ////
30
//// You should have received a copy of the GNU Lesser General    ////
31
//// Public License along with this source; if not, download it   ////
32
//// from http://www.opencores.org/lgpl.shtml                     ////
33
////                                                              ////
34
//////////////////////////////////////////////////////////////////////
35
 
36 360 julius
`include "orpsoc-defines.v"
37
`include "orpsoc-testbench-defines.v"
38
`include "test-defines.v"
39
 
40 6 julius
`include "timescale.v"
41
 
42 360 julius
module orpsoc_testbench;
43
 
44
   reg clk = 0;
45
   reg rst_n = 1; // Active LOW
46 6 julius
 
47 360 julius
   always
48 403 julius
     #((`BOARD_CLOCK_PERIOD)/2) clk <= ~clk;
49 6 julius
 
50 360 julius
   // Reset, ACTIVE LOW
51 6 julius
   initial
52
     begin
53 360 julius
        #1;
54
        repeat (32) @(negedge clk)
55
          rst_n <= 1;
56
        repeat (32) @(negedge clk)
57
          rst_n <= 0;
58
        repeat (32) @(negedge clk)
59
          rst_n <= 1;
60 6 julius
     end
61
 
62 360 julius
`include "orpsoc-params.v"
63 6 julius
 
64 360 julius
`ifdef JTAG_DEBUG
65
   wire                      tdo_pad_o;
66
   wire                      tck_pad_i;
67
   wire                      tms_pad_i;
68
   wire                      tdi_pad_i;
69
`endif
70
`ifdef UART0
71
   wire                      uart0_stx_pad_o;
72
   wire                      uart0_srx_pad_i;
73 6 julius
`endif
74
 
75 360 julius
   orpsoc_top dut
76
     (
77
      .clk_pad_i                        (clk),
78
`ifdef JTAG_DEBUG
79
      .tms_pad_i                        (tms_pad_i),
80
      .tck_pad_i                        (tck_pad_i),
81
      .tdi_pad_i                        (tdi_pad_i),
82
      .tdo_pad_o                        (tdo_pad_o),
83
`endif
84
`ifdef UART0
85
      .uart0_stx_pad_o                  (uart0_stx_pad_o),
86
      .uart0_srx_pad_i                  (uart0_srx_pad_i),
87
`endif
88
      .rst_n_pad_i                      (rst_n)
89
      );
90 6 julius
 
91 360 julius
   //
92
   // Instantiate OR1200 monitor
93
   //
94 863 olof
   or1200_monitor
95
     #(.TEST_NAME_STRING (`TEST_NAME_STRING),
96
       .LOG_DIR("../out"))
97
   monitor();
98 6 julius
 
99 360 julius
`ifndef SIM_QUIET
100
 `define CPU_ic_top or1200_ic_top
101
 `define CPU_dc_top or1200_dc_top
102 403 julius
   wire ic_en = orpsoc_testbench.dut.or1200_top0.or1200_ic_top.ic_en;
103 360 julius
   always @(posedge ic_en)
104
     $display("Or1200 IC enabled at %t", $time);
105 6 julius
 
106 403 julius
   wire dc_en = orpsoc_testbench.dut.or1200_top0.or1200_dc_top.dc_en;
107 360 julius
   always @(posedge dc_en)
108
     $display("Or1200 DC enabled at %t", $time);
109
`endif
110 6 julius
 
111
 
112 360 julius
`ifdef JTAG_DEBUG
113
 `ifdef VPI_DEBUG
114 40 julius
   // Debugging interface
115 360 julius
   vpi_debug_module vpi_dbg
116 6 julius
     (
117 360 julius
      .tms(tms_pad_i),
118
      .tck(tck_pad_i),
119
      .tdi(tdi_pad_i),
120
      .tdo(tdo_pad_o)
121 6 julius
      );
122 360 julius
 `else
123
   // If no VPI debugging, tie off JTAG inputs
124
   assign tdi_pad_i = 1;
125
   assign tck_pad_i = 0;
126
   assign tms_pad_i = 1;
127
 `endif // !`ifdef VPI_DEBUG_ENABLE
128
`endif //  `ifdef JTAG_DEBUG
129 44 julius
 
130
 
131 360 julius
   initial
132
     begin
133
`ifndef SIM_QUIET
134 403 julius
        $display("\n* Starting simulation of ORPSoC RTL.\n* Test: %s\n",
135 360 julius
                 `TEST_NAME_STRING );
136
`endif
137 44 julius
 
138 360 julius
`ifdef VCD
139
 `ifdef VCD_DELAY
140
        #(`VCD_DELAY);
141
 `endif
142 44 julius
 
143 360 julius
        // Delay by x insns
144
 `ifdef VCD_DELAY_INSNS
145
        #10; // Delay until after the value becomes valid
146
        while (monitor.insns < `VCD_DELAY_INSNS)
147
          @(posedge clk);
148
 `endif
149
 
150
 `ifdef SIMULATOR_MODELSIM
151
        // Modelsim can GZip VCDs on the fly if given in the suffix
152
  `define VCD_SUFFIX   ".vcd.gz"
153
 `else
154
  `define VCD_SUFFIX   ".vcd"
155
 `endif
156
 
157
`ifndef SIM_QUIET
158
        $display("* VCD in %s\n", {"../out/",`TEST_NAME_STRING,`VCD_SUFFIX});
159
`endif
160
        $dumpfile({"../out/",`TEST_NAME_STRING,`VCD_SUFFIX});
161
 `ifndef VCD_DEPTH
162
  `define VCD_DEPTH 0
163
 `endif
164
        $dumpvars(`VCD_DEPTH);
165 44 julius
`endif
166 360 julius
 
167
   end // initial begin
168 44 julius
 
169 360 julius
`ifdef END_TIME
170
   initial begin
171
      #(`END_TIME);
172
`ifndef SIM_QUIET
173
      $display("* Finish simulation due to END_TIME being set at %t", $time);
174
`endif
175
      $finish;
176
   end
177 6 julius
`endif
178
 
179 360 julius
`ifdef END_INSNS
180
   initial begin
181
      #10
182
        while (monitor.insns < `END_INSNS)
183
          @(posedge clk);
184
 `ifndef SIM_QUIET
185
      $display("* Finish simulation due to END_INSNS count (%d) reached at %t",
186
               `END_INSNS, $time);
187
 `endif
188
      $finish;
189
   end
190
`endif
191
 
192
`ifdef UART0
193
   //   
194
   // UART0 decoder
195
   //   
196 354 julius
   uart_decoder
197
     #(
198 360 julius
        .uart_baudrate_period_ns(8680) // 115200 baud = period 8.68uS
199
        )
200 354 julius
   uart0_decoder
201
     (
202
      .clk(clk),
203 360 julius
      .uart_tx(uart0_stx_pad_o)
204 354 julius
      );
205 6 julius
 
206 360 julius
   // UART0 stimulus
207 397 julius
   /*
208 360 julius
   uart_stim
209
     #(
210
        .uart_baudrate_period_ns(8680) // 115200 baud = period 8.68uS
211
        )
212
   uart0_stim
213
     (
214
      .clk(clk),
215
      .uart_rx(uart0_srx_pad_i)
216
      );
217 397 julius
    */
218
   // UART0 is looped back for now
219
   assign uart0_srx_pad_i = uart0_stx_pad_o;
220
 
221 360 julius
`endif //  `ifdef UART0
222
 
223 6 julius
endmodule // orpsoc_testbench
224
 
225
// Local Variables:
226 360 julius
// verilog-library-directories:("." "../../rtl/verilog/orpsoc_top")
227
// verilog-library-files:()
228
// verilog-library-extensions:(".v" ".h")
229 49 julius
// End:
230 360 julius
 

powered by: WebSVN 2.1.0

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