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

Subversion Repositories test_project

[/] [test_project/] [trunk/] [bench/] [verilog/] [orpsoc_testbench.v] - Blame information for rev 54

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  ORPSoC Testbench                                            ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  ORPSoC Testbench file                                       ////
7
////                                                              ////
8
////  To Do:                                                      ////
9
////                                                              ////
10 54 julius
////                                                              ////
11 26 julius
////  Author(s):                                                  ////
12
////      - jb, jb@orsoc.se                                       ////
13
////                                                              ////
14
////                                                              ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                              ////
17
//// Copyright (C) 2009 Authors and OPENCORES.ORG                 ////
18
////                                                              ////
19
//// This source file may be used and distributed without         ////
20
//// restriction provided that this copyright statement is not    ////
21
//// removed from the file and that any derivative work contains  ////
22
//// the original copyright notice and the associated disclaimer. ////
23
////                                                              ////
24
//// This source file is free software; you can redistribute it   ////
25
//// and/or modify it under the terms of the GNU Lesser General   ////
26
//// Public License as published by the Free Software Foundation; ////
27
//// either version 2.1 of the License, or (at your option) any   ////
28
//// later version.                                               ////
29
////                                                              ////
30
//// This source is distributed in the hope that it will be       ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
33
//// PURPOSE.  See the GNU Lesser General Public License for more ////
34
//// details.                                                     ////
35
////                                                              ////
36
//// You should have received a copy of the GNU Lesser General    ////
37
//// Public License along with this source; if not, download it   ////
38
//// from http://www.opencores.org/lgpl.shtml                     ////
39
////                                                              ////
40
//////////////////////////////////////////////////////////////////////
41
 
42
`include "timescale.v"
43
`include "orpsoc_testbench_defines.v"
44
 
45
module orpsoc_testbench();
46
 
47
 
48
   reg clk;
49
   reg rst;
50
 
51
   // Setup global clock. Period defined in orpsoc_testbench_defines.v
52
   initial
53
     begin
54
        clk <= 0;
55
        rst <= 1;
56
     end
57
 
58
   always
59
     begin
60
        #((`CLOCK_PERIOD)/2) clk <= ~clk;
61
     end
62
 
63
   // Assert rst and then bring it low again
64
   initial
65
     begin
66
        repeat (2) @(negedge clk);
67
        rst <= 0;
68
        repeat (16) @(negedge clk);
69
        rst <= 1;
70
     end
71
 
72
 
73
   // Wires for the dut
74
   wire spi_sd_sclk_o;
75
   wire spi_sd_ss_o;
76
   wire spi_sd_miso_i;
77
   wire spi_sd_mosi_o;
78 46 julius
`ifdef USE_SDRAM
79 26 julius
   wire [15:0] mem_dat_io;
80
   wire [12:0] mem_adr_o;
81
   wire [1:0]  mem_dqm_o;
82
   wire [1:0]  mem_ba_o;
83
   wire        mem_cs_o;
84
   wire        mem_ras_o;
85
   wire        mem_cas_o;
86
   wire        mem_we_o;
87
   wire        mem_cke_o;
88 46 julius
   wire        spi_flash_sclk_o;
89
   wire        spi_flash_ss_o;
90
   wire        spi_flash_miso_i;
91
   wire        spi_flash_mosi_o;
92
   wire        spi_flash_w_n_o;
93
   wire        spi_flash_hold_n_o;
94
`endif //  `ifdef USE_SDRAM
95
 
96
`ifdef USE_ETHERNET
97
   wire [1:1]  eth_sync_o;
98 26 julius
   wire [1:1] eth_tx_o;
99
   wire [1:1] eth_rx_i;
100
   wire       eth_clk_i;
101
   wire [1:1] eth_md_io;
102
   wire [1:1] eth_mdc_o;
103 46 julius
`endif
104
 
105 26 julius
   wire       spi1_mosi_o;
106
   wire       spi1_miso_i;
107
   wire       spi1_ss_o;
108
   wire       spi1_sclk_o;
109
   wire [8-1:0] gpio_a_io;
110
   wire         uart0_srx_i;
111
   wire         uart0_stx_o;
112
   wire         dbg_tdi_i;
113
   wire         dbg_tck_i;
114
   wire         dbg_tms_i;
115
   wire         dbg_tdo_o;
116
   wire         rst_i;
117
   wire         rst_o;
118
   wire         clk_i;
119
 
120
 
121
   assign clk_i = clk;
122
   assign rst_i = rst;
123
 
124 46 julius
   // Tie off some inputs   
125 26 julius
   assign spi1_miso_i = 0;
126
   assign uart0_srx_i = 1;
127
   assign dbg_tdi_i = 1;
128
   assign dbg_tck_i = 0;
129
   assign dbg_tms_i = 1;
130
 
131
 
132 40 julius
   orpsoc_top dut
133 26 julius
     (
134
      // Outputs
135
      .spi_sd_sclk_pad_o                        (spi_sd_sclk_o),
136
      .spi_sd_ss_pad_o                  (spi_sd_ss_o),
137
      .spi_sd_mosi_pad_o                        (spi_sd_mosi_o),
138
      .spi1_mosi_pad_o                  (spi1_mosi_o),
139
      .spi1_ss_pad_o                    (spi1_ss_o),
140
      .spi1_sclk_pad_o                  (spi1_sclk_o),
141
      .uart0_stx_pad_o                  (uart0_stx_o),
142
      .dbg_tdo_pad_o                    (dbg_tdo_o),
143
      .rst_pad_o                                (rst_o),
144
      .gpio_a_pad_io                    (gpio_a_io[8-1:0]),
145
      // Inputs
146
      .spi_sd_miso_pad_i                        (spi_sd_miso_i),
147
      .spi1_miso_pad_i                  (spi1_miso_i),
148
      .uart0_srx_pad_i                  (uart0_srx_i),
149
      .dbg_tdi_pad_i                    (dbg_tdi_i),
150
      .dbg_tck_pad_i                    (dbg_tck_i),
151
      .dbg_tms_pad_i                    (dbg_tms_i),
152 46 julius
`ifdef USE_ETHERNET
153
      // Ethernet ports
154
      .eth_md_pad_io                    (eth_md_io[1:1]),
155
      .eth_sync_pad_o                   (eth_sync_o[1:1]),
156
      .eth_tx_pad_o                     (eth_tx_o[1:1]),
157
      .eth_mdc_pad_o                    (eth_mdc_o[1:1]),
158
      .eth_rx_pad_i                     (eth_rx_i[1:1]),
159
      .eth_clk_pad_i                    (eth_clk_i),
160
`endif  //  `ifdef USE_ETHERNET      
161
      // SDRAM and flash memory ports
162
`ifdef USE_SDRAM
163
      .mem_dat_pad_io                   (mem_dat_io[15:0]),
164
      .mem_adr_pad_o                    (mem_adr_o[12:0]),
165
      .mem_dqm_pad_o                    (mem_dqm_o[1:0]),
166
      .mem_ba_pad_o                     (mem_ba_o[1:0]),
167
      .mem_cs_pad_o                     (mem_cs_o),
168
      .mem_ras_pad_o                    (mem_ras_o),
169
      .mem_cas_pad_o                    (mem_cas_o),
170
      .mem_we_pad_o                     (mem_we_o),
171
      .mem_cke_pad_o                    (mem_cke_o),
172
      .spi_flash_sclk_pad_o             (spi_flash_sclk_o),
173
      .spi_flash_ss_pad_o                       (spi_flash_ss_o),
174
      .spi_flash_mosi_pad_o             (spi_flash_mosi_o),
175
      .spi_flash_w_n_pad_o                      (spi_flash_w_n_o),
176
      .spi_flash_hold_n_pad_o           (spi_flash_hold_n_o),
177
      .spi_flash_miso_pad_i             (spi_flash_miso_i),
178
`endif
179 26 julius
      .rst_pad_i                                (rst_i),
180
      .clk_pad_i                                (clk_i));
181
 
182 46 julius
   // External memories, if enabled
183 45 julius
`ifdef USE_SDRAM
184 26 julius
   // SPI Flash
185
   AT26DFxxx spi_flash
186
     (
187
      // Outputs
188
      .SO                                       (spi_flash_miso_i),
189
      // Inputs
190
      .CSB                                      (spi_flash_ss_o),
191
      .SCK                                      (spi_flash_sclk_o),
192
      .SI                                       (spi_flash_mosi_o),
193
      .WPB                                      (spi_flash_w_n_o)
194
      //.HOLDB                          (spi_flash_hold_n_o)
195
      );
196
 
197
   // SDRAM
198
   mt48lc16m16a2 sdram
199
     (
200
      // Inouts
201
      .Dq                                       (mem_dat_io),
202
      // Inputs
203
      .Addr                             (mem_adr_o),
204
      .Ba                                       (mem_ba_o),
205
      .Clk                                      (clk_i),
206
      .Cke                                      (mem_cke_o),
207
      .Cs_n                             (mem_cs_o),
208
      .Ras_n                            (mem_ras_o),
209
      .Cas_n                            (mem_cas_o),
210
      .We_n                             (mem_we_o),
211
      .Dqm                                      (mem_dqm_o));
212
 
213 45 julius
`endif // !`ifdef USE_SDRAM
214
 
215
 
216 26 julius
initial
217
  begin
218 34 julius
     $display("\nStarting RTL simulation of %s test\n", `TEST_NAME_STRING);
219 46 julius
`ifdef USE_SDRAM
220
     $display("Using SDRAM - loading application from SPI flash memory\n");
221
`endif
222
 
223 31 julius
`ifdef VCD
224 34 julius
     $display("VCD in %s\n", {`TEST_RESULTS_DIR,`TEST_NAME_STRING,".vcd"});
225
     $dumpfile({`TEST_RESULTS_DIR,`TEST_NAME_STRING,".vcd"});
226
     $dumpvars(0);
227 26 julius
`endif
228 34 julius
  end
229 26 julius
 
230 43 julius
   // Instantiate the monitor
231
   or1200_monitor monitor();
232 54 julius
 
233
   // If we're using UART for printf output, include the
234
   // UART decoder
235
`ifdef UART_PRINTF
236
   // Define the UART's txt line for it to listen to
237
 `define UART_TX_LINE uart0_stx_o
238
 `define UART_BAUDRATE 115200
239
 `include "uart_decoder.v"
240
`endif
241
 
242 26 julius
endmodule // orpsoc_testbench
243
 
244
// Local Variables:
245
// verilog-library-files:("../../rtl/verilog/orp_soc.v")
246
// verilog-library-directories:("." "../../rtl/verilog")
247
// End:

powered by: WebSVN 2.1.0

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