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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [behav/] [testbench/] [testbench.v] - Blame information for rev 114

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 fafa1971
/*
2 114 albert.wat
 * S1 Testbench
3 4 fafa1971
 *
4 114 albert.wat
 * (C) 2007 Fabrizio Fazzino
5 4 fafa1971
 *
6
 * LICENSE:
7
 * This is a Free Hardware Design; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * version 2 as published by the Free Software Foundation.
10
 * The above named program is distributed in the hope that it will
11
 * be useful, but WITHOUT ANY WARRANTY; without even the implied
12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 * See the GNU General Public License for more details.
14
 *
15
 * DESCRIPTION:
16
 * This is the testbench for the functional verification of the
17
 * S1 Core: it makes and instance of the S1 module to make it
18
 * possible to access one or more memory harnesses.
19
 */
20
 
21
`include "s1_defs.h"
22
 
23
module testbench ();
24
 
25
  /*
26
   * Wires
27
   */
28
 
29
  // Interrupt Requests
30
  wire[63:0] sys_irq;
31
 
32
  // Wishbone Master inputs / Wishbone Slave ouputs
33
  wire wb_ack;                                 // Ack
34
  wire[(`WB_DATA_WIDTH-1):0] wb_datain;        // Data In
35
 
36
  // Wishbone Master outputs / Wishbone Slave inputs
37
  wire wb_cycle;                               // Cycle Start
38
  wire wb_strobe;                              // Strobe Request
39 113 albert.wat
  wire wb_we;                                  // Write Enable
40 4 fafa1971
  wire[`WB_ADDR_WIDTH-1:0] wb_addr;            // Address Bus
41
  wire[`WB_DATA_WIDTH-1:0] wb_dataout;         // Data Out
42
  wire[`WB_DATA_WIDTH/8-1:0] wb_sel;           // Select Output
43
 
44 103 fafa1971
  // Separate Cycle, Strobe and Ack wires for ROM and RAM memory harnesses
45
  wire wb_cycle_ram;
46
  wire wb_cycle_rom;
47
  wire wb_strobe_ram;
48
  wire wb_strobe_rom;
49
  wire wb_ack_ram;
50
  wire wb_ack_rom;
51 4 fafa1971
 
52 103 fafa1971
  // Decode the address and select the proper memory bank
53 4 fafa1971
 
54 103 fafa1971
  assign wb_cycle_rom  = ( (wb_addr[39:12]==28'hFFF0000) ? wb_cycle : 0 );
55
  assign wb_strobe_rom = ( (wb_addr[39:12]==28'hFFF0000) ? wb_strobe : 0 );
56 4 fafa1971
 
57 103 fafa1971
  assign wb_cycle_ram  = ( (wb_addr[39:16]==24'h000004) ? wb_cycle : 0 );
58
  assign wb_strobe_ram = ( (wb_addr[39:16]==24'h000004) ? wb_strobe : 0 );
59
 
60
  assign wb_ack = wb_ack_ram | wb_ack_rom;
61
 
62 4 fafa1971
  /*
63
   * Registers
64
   */
65
 
66
  // System signals
67
  reg sys_clock;
68
  reg sys_reset;
69
 
70
  /*
71
   * Behavior
72
   */
73
 
74
  always #1 sys_clock = ~sys_clock;
75
  assign sys_irq = 64'b0;
76
 
77
  initial begin
78
 
79
    // Display start message
80 114 albert.wat
    $display("INFO: TBENCH: Starting S1 Core simulation...");
81 4 fafa1971
 
82
    // Create VCD trace file
83
    $dumpfile("trace.vcd");
84
    $dumpvars();
85
 
86
    // Run the simulation
87
    sys_clock <= 1'b1;
88
    sys_reset <= 1'b1;
89 103 fafa1971
    #1000
90 4 fafa1971
    sys_reset <= 1'b0;
91 103 fafa1971
    #49000
92 114 albert.wat
    $display("INFO: TBENCH: Completed S1 Core simulation!");
93 4 fafa1971
    $finish;
94
 
95
  end
96
 
97
  /*
98 103 fafa1971
   * Module instances
99 4 fafa1971
   */
100
 
101 114 albert.wat
  // S1 Core
102 4 fafa1971
  s1_top s1_top_0 (
103
 
104
    // System inputs
105
    .sys_clock_i(sys_clock),
106
    .sys_reset_i(sys_reset),
107
    .sys_irq_i(sys_irq),
108
 
109
    // Wishbone Master inputs
110
    .wbm_ack_i(wb_ack),
111
    .wbm_data_i(wb_datain),
112
 
113
    // Wishbone Master outputs
114
    .wbm_cycle_o(wb_cycle),
115
    .wbm_strobe_o(wb_strobe),
116
    .wbm_we_o(wb_we),
117
    .wbm_addr_o(wb_addr),
118
    .wbm_data_o(wb_dataout),
119
    .wbm_sel_o(wb_sel)
120
 
121
  );
122 103 fafa1971
 
123
  // Wishbone memory harness used as ROM
124
  mem_harness rom_harness (
125 4 fafa1971
 
126
    // System inputs
127
    .sys_clock_i(sys_clock),
128
    .sys_reset_i(sys_reset),
129
 
130
    // Wishbone Slave inputs
131
    .wbs_addr_i(wb_addr),
132
    .wbs_data_i(wb_dataout),
133 103 fafa1971
    .wbs_cycle_i(wb_cycle_rom),
134
    .wbs_strobe_i(wb_strobe_rom),
135 4 fafa1971
    .wbs_sel_i(wb_sel),
136
    .wbs_we_i(wb_we),
137
 
138
    // Wishbone Slave outputs
139
    .wbs_data_o(wb_datain),
140 103 fafa1971
    .wbs_ack_o(wb_ack_rom)
141 4 fafa1971
 
142
  );
143
 
144 103 fafa1971
  // Wishbone memory harness used as RAM
145
  mem_harness ram_harness (
146 4 fafa1971
 
147
    // System inputs
148
    .sys_clock_i(sys_clock),
149
    .sys_reset_i(sys_reset),
150
 
151
    // Wishbone Slave inputs
152
    .wbs_addr_i(wb_addr),
153
    .wbs_data_i(wb_dataout),
154 103 fafa1971
    .wbs_cycle_i(wb_cycle_ram),
155
    .wbs_strobe_i(wb_strobe_ram),
156 4 fafa1971
    .wbs_sel_i(wb_sel),
157
    .wbs_we_i(wb_we),
158
 
159
    // Wishbone Slave outputs
160
    .wbs_data_o(wb_datain),
161 103 fafa1971
    .wbs_ack_o(wb_ack_ram)
162 4 fafa1971
 
163
  );
164
 
165 103 fafa1971
  /*
166
   * Parameters for memory harnesses
167
   */
168 4 fafa1971
 
169 103 fafa1971
  // ROM has Physical Address range [0xFFF0000000:0xFFF0000FFF]
170
  // so size is 4 KByte and requires 12 address bits
171
  // 3 of which are ignored being a 64-bit memory => addr_bits=9
172
  // (it was section RED_SEC in the official OpenSPARC-T1 testbench)
173
  defparam rom_harness.addr_bits = 9;
174
  defparam rom_harness.memfilename = "rom_harness.hex";
175
  defparam rom_harness.memdefaultcontent = 64'h0100000001000000;
176 4 fafa1971
 
177 103 fafa1971
  // RAM has Physical Address range [0x0000040000:0x000004FFFF]
178
  // so size is 64 KByte and requires 16 address bits
179
  // 3 of which are ignored being a 64-bit memory => addr_bits=13
180
  // (it was section RED_EXT_SEC in the official OpenSPARC-T1 testbench)
181
  defparam ram_harness.addr_bits = 13;
182
  defparam ram_harness.memfilename = "ram_harness.hex";
183
  defparam ram_harness.memdefaultcontent = 64'h0100000001000000;
184
 
185 4 fafa1971
endmodule

powered by: WebSVN 2.1.0

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