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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [bench/] [rtl_cm3/] [verilog/] [or1200_tb_cm3.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
///////////////////////////////////////////////
2
//      OR1200 Testbench Top Level for
3
//      Random Instruction Code Generator
4
//      and Hyper Pipelined OR1200 Core with
5
//      CMF = 3
6
///////////////////////////////////////////////
7
 
8
// synopsys translate_off
9
`include "timescale.v"
10
// synopsys translate_on
11
`include "or1200_defines.v"
12
 
13
module or1200_testbench_cm3();
14
 
15
 
16
parameter dw = `OR1200_OPERAND_WIDTH;
17
parameter aw = `OR1200_OPERAND_WIDTH;
18
parameter ppic_ints = `OR1200_PIC_INTS;
19
 
20
//
21
// I/O
22
//
23
 
24
//
25
// System
26
//
27
//reg                   clk_i;
28
//reg                   rst_i;
29
reg     [1:0]            clmode_i;       // 00 WB=RISC, 01 WB=RISC/2, 10 N/A, 11 WB=RISC/4
30
reg     [ppic_ints-1:0]  pic_ints_i;
31
 
32
//
33
// Instruction WISHBONE interface
34
//
35
//reg                   iwb_clk_i;      // clock input
36
//reg                   iwb_rst_i;      // reset input
37
wire                    iwb_ack_i;      // normal termination
38
reg                     iwb_err_i;      // termination w/ error
39
reg                     iwb_rty_i;      // termination w/ retry
40
wire    [dw-1:0] iwb_dat_i;      // input data bus
41
wire                    iwb_cyc_o;      // cycle valid output
42
wire    [aw-1:0] iwb_adr_o;      // address bus outputs
43
wire                    iwb_stb_o;      // strobe output
44
wire                    iwb_we_o;       // indicates write transfer
45
wire    [3:0]            iwb_sel_o;      // byte select outputs
46
wire    [dw-1:0] iwb_dat_o;      // output data bus
47
`ifdef OR1200_WB_CAB
48
wire                    iwb_cab_o;      // indicates consecutive address burst
49
`endif
50
`ifdef OR1200_WB_B3
51
wire    [2:0]            iwb_cti_o;      // cycle type identifier
52
wire    [1:0]            iwb_bte_o;      // burst type extension
53
`endif
54
 
55
//
56
// Data WISHBONE interface
57
//
58
//reg                   dwb_clk_i;      // clock input
59
//reg                   dwb_rst_i;      // reset input
60
reg                     dwb_ack_i;      // normal termination
61
reg                     dwb_err_i;      // termination w/ error
62
reg                     dwb_rty_i;      // termination w/ retry
63
reg     [dw-1:0] dwb_dat_i;      // input data bus
64
wire                    dwb_cyc_o;      // cycle valid output
65
wire    [aw-1:0] dwb_adr_o;      // address bus outputs
66
wire                    dwb_stb_o;      // strobe output
67
wire                    dwb_we_o;       // indicates write transfer
68
wire    [3:0]            dwb_sel_o;      // byte select outputs
69
wire    [dw-1:0] dwb_dat_o;      // output data bus
70
`ifdef OR1200_WB_CAB
71
wire                    dwb_cab_o;      // indicates consecutive address burst
72
`endif
73
`ifdef OR1200_WB_B3
74
wire    [2:0]            dwb_cti_o;      // cycle type identifier
75
wire    [1:0]            dwb_bte_o;      // burst type extension
76
`endif
77
 
78
//
79
// External Debug Interface
80
//
81
reg                     dbg_stall_i;    // External Stall Input
82
reg                     dbg_ewt_i;      // External Watchpoint Trigger Input
83
wire    [3:0]            dbg_lss_o;      // External Load/Store Unit Status
84
wire    [1:0]            dbg_is_o;       // External Insn Fetch Status
85
wire    [10:0]           dbg_wp_o;       // Watchpoints Outputs
86
wire                    dbg_bp_o;       // Breakpoint Output
87
reg                     dbg_stb_i;      // External Address/Data Strobe
88
reg                     dbg_we_i;       // External Write Enable
89
reg     [aw-1:0] dbg_adr_i;      // External Address Input
90
reg     [dw-1:0] dbg_dat_i;      // External Data Input
91
wire    [dw-1:0] dbg_dat_o;      // External Data Output
92
wire                    dbg_ack_o;      // External Data Acknowledge (not WB compatible)
93
 
94
`ifdef OR1200_BIST
95
//
96
// RAM BIST
97
//
98
reg mbist_si_i;
99
reg [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
100
wire mbist_so_o;
101
`endif
102
 
103
//
104
// Power Management
105
//
106
reg                     pm_cpustall_i;
107
wire    [3:0]            pm_clksd_o;
108
wire                    pm_dc_gate_o;
109
wire                    pm_ic_gate_o;
110
wire                    pm_dmmu_gate_o;
111
wire                    pm_immu_gate_o;
112
wire                    pm_tt_gate_o;
113
wire                    pm_cpu_gate_o;
114
wire                    pm_wakeup_o;
115
wire                    pm_lvolt_o;
116
 
117
 
118
/////////////////////////////////////////////////
119
//      Top Level Clocks, Reset and
120
//      Core Multiplier Level Selector
121
/////////////////////////////////////////////////
122
 
123
reg system_clk;
124
reg clk_i;
125
reg clk_i_cml_1;
126
reg clk_i_cml_2;
127
reg [1:0] cmls;
128
reg rst;
129
integer cnt = 0;
130
reg [2:0] core_off;
131
parameter turnOffTime_2nd = 8502;
132
parameter turnOffTime_3nd = 16502;
133
parameter turnOnTime_3nd = 24500;
134
parameter turnOnTime_2nd = 32501;
135
 
136
/////////////////////////////////////////////////
137
//      Initial
138
/////////////////////////////////////////////////
139
 
140
initial begin
141
        system_clk <= 0;
142
        clk_i <= 0;
143
        clk_i_cml_1 <= 0;
144
        clk_i_cml_2 <= 0;
145
        cmls <= 0;
146
        rst <= 1;
147
        core_off <= 0;
148
 
149
        clmode_i <= 0;   // 00 WB=RISC, 01 WB=RISC/2, 10 N/A, 11 WB=RISC/4
150
        pic_ints_i = 0;
151
        iwb_err_i = 0;   // termination w/ error
152
        iwb_rty_i = 0;   // termination w/ retry
153
        dwb_ack_i = 0;   // normal termination
154
        dwb_err_i = 0;   // termination w/ error
155
        dwb_rty_i = 0;   // termination w/ retry
156
        dwb_dat_i = 0;   // input data bus
157
        dbg_stall_i = 0; // External Stall Input
158
        dbg_ewt_i = 0;   // External Watchpoint Trigger Input
159
        dbg_stb_i = 0;      // External Address/Data Strobe
160
        dbg_we_i = 0;       // External Write Enable
161
        dbg_adr_i = 0;   // External Address Input
162
        dbg_dat_i = 0;   // External Data Input
163
        pm_cpustall_i = 0;
164
end
165
 
166
/////////////////////////////////////////////////
167
//      Clock Generator
168
/////////////////////////////////////////////////
169
 
170
always begin
171
        #(50)
172
        system_clk <= ~system_clk;
173
 
174
        // do not clock       when (core_off[1] and cmls == 0) or (core_off[2] and cmls == 1);
175
        clk_i       <= ~system_clk & (~(core_off[1] & (cmls == 0))) & (~(core_off[2] & (cmls == 1)));
176
 
177
        // do not clock cml_1 when (core_off[1] and cmls == 1) or (core_off[2] and cmls == 2);
178
        clk_i_cml_1 <= ~system_clk & (~(core_off[1] & (cmls == 1))) & (~(core_off[2] & (cmls == 2)));
179
 
180
        // do not clock cml_2 when (core_off[1] and cmls == 2) or (core_off[2] and cmls == 0);
181
        clk_i_cml_2 <= ~system_clk & (~(core_off[1] & (cmls == 2))) & (~(core_off[2] & (cmls == 0)));
182
end
183
 
184
/////////////////////////////////////////////////
185
//      Core Multiplier Level Selector
186
/////////////////////////////////////////////////
187
 
188
always @(posedge system_clk)
189
        if (cmls == 2)
190
                cmls <= 0;
191
        else
192
                cmls <= cmls + 1;
193
 
194
 
195
/////////////////////////////////////////////////
196
//      Reset Generator
197
/////////////////////////////////////////////////
198
 
199
initial begin
200
        repeat (20) @(negedge system_clk);
201
        rst <= 0;
202
        repeat (turnOnTime_3nd - 19) @(negedge system_clk);
203
        rst <= 1;
204
        #20; //@(negedge system_clk);
205
        rst <= 0;
206
        repeat (turnOnTime_2nd - (turnOnTime_3nd - 19) - 17) @(negedge system_clk);
207
        rst <= 1;
208
        #20; //@(negedge system_clk);
209
        rst <= 0;
210
end
211
 
212
/////////////////////////////////////////////////
213
//      Process turns off/on second core
214
/////////////////////////////////////////////////
215
 
216
always @ (posedge system_clk) begin
217
        if (cnt == turnOffTime_2nd) begin
218
                core_off[1] <= 1'b1;
219
        end
220
        if (cnt == turnOffTime_3nd) begin
221
                core_off[2] <= 1'b1;
222
        end
223
        if (cnt == turnOnTime_2nd - 1) begin
224
                core_off[1] <= 1'b0;
225
        end
226
        if (cnt == turnOnTime_3nd - 1) begin
227
                core_off[2] <= 1'b0;
228
        end
229
end
230
 
231
/////////////////////////////////////////////////
232
//      Count and Stop after 47000 Cycles
233
/////////////////////////////////////////////////
234
 
235
always @ (posedge system_clk)
236
begin
237
        cnt <= cnt + 1;
238
        if (cnt == 47000) begin
239
                $stop;
240
        end
241
end
242
 
243
 
244
/////////////////////////////////////////////////
245
//      Random Instruction Code Generator for 
246
//      3 Hyper Pipelined OR1200
247
/////////////////////////////////////////////////
248
 
249
random_rom_wb_cm3 random_rom_wb_cm3_i
250
        (
251
        .dat_o(iwb_dat_i),
252
        .adr_i(iwb_adr_o[25:2]),
253
        .sel_i(iwb_sel_o),
254
        .cyc_i(iwb_cyc_o),
255
        .stb_i(iwb_stb_o),
256
        .ack_o(iwb_ack_i),
257
        .clk_i(system_clk),
258
        .cmls(cmls),
259
        .rst_i(rst),
260
        .core_off(core_off) );
261
 
262
/////////////////////////////////////////////////
263
//      Instantiation of Hyper Pipelined OR1200
264
//      with CMF = 3
265
/////////////////////////////////////////////////
266
 
267
or1200_top_cm3 or1200_top_cm3_i
268
     (
269
        .clk_i_cml_2(clk_i_cml_2),
270
        .clk_i_cml_1(clk_i_cml_1),
271
        .cmls(cmls),
272
        // System
273
        .clk_i(clk_i),
274
        .rst_i(rst),
275
        .pic_ints_i(pic_ints_i),
276
        .clmode_i(clmode_i),
277
 
278
        // Instruction WISHBONE INTERFACE
279
        //.iwb_clk_i(clk), 
280
        //.iwb_rst_i(rst), 
281
        .iwb_ack_i(iwb_ack_i),
282
        .iwb_err_i(iwb_err_i),
283
        .iwb_rty_i(iwb_rty_i),
284
        .iwb_dat_i(iwb_dat_i),
285
        .iwb_cyc_o(iwb_cyc_o),
286
        .iwb_adr_o(iwb_adr_o),
287
        .iwb_stb_o(iwb_stb_o),
288
        .iwb_we_o(iwb_we_o),
289
        .iwb_sel_o(iwb_sel_o),
290
        .iwb_dat_o(iwb_dat_o),
291
`ifdef OR1200_WB_CAB
292
        .iwb_cab_o(iwb_cab_o),
293
`endif
294
`ifdef OR1200_WB_B3
295
        .iwb_cti_o(iwb_cti_o),
296
        .iwb_bte_o(iwb_bte_o),
297
`endif
298
        // Data WISHBONE INTERFACE
299
        //.dwb_clk_i(clk), 
300
        //.dwb_rst_i(rst), 
301
        .dwb_ack_i(dwb_ack_i),
302
        .dwb_err_i(dwb_err_i),
303
        .dwb_rty_i(dwb_rty_i),
304
        .dwb_dat_i(dwb_dat_i),
305
        .dwb_cyc_o(dwb_cyc_o),
306
        .dwb_adr_o(dwb_adr_o),
307
        .dwb_stb_o(dwb_stb_o),
308
        .dwb_we_o(dwb_we_o),
309
        .dwb_sel_o(dwb_sel_o),
310
        .dwb_dat_o(dwb_dat_o),
311
`ifdef OR1200_WB_CAB
312
        .dwb_cab_o(dwb_cab_o),
313
`endif
314
`ifdef OR1200_WB_B3
315
        .dwb_cti_o(dwb_cti_o),
316
        .dwb_bte_o(dwb_bte_o),
317
`endif
318
 
319
        // External Debug Interface
320
        .dbg_stall_i(dbg_stall_i),
321
        .dbg_ewt_i(dbg_ewt_i),
322
        .dbg_lss_o(dbg_lss_o),
323
        .dbg_is_o(dbg_is_o),
324
        .dbg_wp_o(dbg_wp_o),
325
        .dbg_bp_o(dbg_bp_o),
326
        .dbg_stb_i(dbg_stb_i),
327
        .dbg_we_i(dbg_we_i),
328
        .dbg_adr_i(dbg_adr_i),
329
        .dbg_dat_i(dbg_dat_i),
330
        .dbg_dat_o(dbg_dat_o),
331
        .dbg_ack_o(dbg_ack_o),
332
 
333
`ifdef OR1200_BIST
334
        // RAM BIST
335
        .mbist_si_i(mbist_si_i),
336
        .mbist_so_o(mbist_so_o),
337
        .mbist_ctrl_i(mbist_ctrl_i),
338
`endif
339
        // Power Management
340
        .pm_cpustall_i(pm_cpustall_i),
341
        .pm_clksd_o(pm_clksd_o),
342
        .pm_dc_gate_o(pm_dc_gate_o),
343
        .pm_ic_gate_o(pm_ic_gate_o),
344
        .pm_dmmu_gate_o(pm_dmmu_gate_o),
345
        .pm_immu_gate_o(pm_immu_gate_o),
346
        .pm_tt_gate_o(pm_tt_gate_o),
347
        .pm_cpu_gate_o(pm_cpu_gate_o),
348
        .pm_wakeup_o(pm_wakeup_o),
349
        .pm_lvolt_o(pm_lvolt_o)
350
);
351
 
352
 
353
 
354
endmodule

powered by: WebSVN 2.1.0

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