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

Subversion Repositories thor

[/] [thor/] [trunk/] [bench/] [Thor_tb.v] - Blame information for rev 27

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

Line No. Rev Author Line
1 2 robfinch
 
2
module Thor_tb();
3
parameter DBW=32;
4
reg rst;
5
reg clk;
6
reg nmi;
7
reg p100Hz;
8 21 robfinch
reg p1000Hz;
9 2 robfinch
wire [2:0] cti;
10
wire cpu_clk;
11
wire cyc;
12
wire stb;
13
wire we;
14
wire [7:0] sel;
15
wire br_ack;
16
wire [31:0] adr;
17 21 robfinch
wire [DBW+6:0] br_dato;
18 2 robfinch
wire scr_ack;
19
wire [63:0] scr_dato;
20 21 robfinch
reg [31:0] rammem [0:1048575];
21
wire err1,err2;
22 2 robfinch
 
23
wire cpu_ack;
24
wire [DBW-1:0] cpu_dati;
25
wire [DBW-1:0] cpu_dato;
26
wire pic_ack,irq;
27
wire [31:0] pic_dato;
28
wire [7:0] vecno;
29 21 robfinch
wire baud16;
30
wire uart_rxd;
31
wire uart_ack;
32
wire uart_irq;
33
wire [7:0] uart_dato;
34 2 robfinch
wire LEDS_ack;
35
 
36
initial begin
37
        #0 rst = 1'b0;
38
        #0 clk = 1'b0;
39
        #0 nmi = 1'b0;
40
        #0 p100Hz = 1'b0;
41 21 robfinch
        #0 p1000Hz = 1'b1;
42 2 robfinch
        #10 rst = 1'b1;
43
        #50 rst = 1'b0;
44 21 robfinch
        #20800 nmi = 1'b1;
45 2 robfinch
        #20 nmi = 1'b0;
46
end
47
 
48
always #5 clk = ~clk;
49
always #10000 p100Hz = ~p100Hz;
50 21 robfinch
always #3000 p1000Hz = ~p1000Hz;
51 2 robfinch
 
52 21 robfinch
wire ram_cs = cyc && stb && adr[31:28]==4'd0 && adr[31:14]!= 18'h0000;
53
wire [31:0] ramo = ram_cs ? rammem[adr[21:2]] : 32'd0;
54
always @(posedge clk)
55
    if (ram_cs & we) begin
56
        if (sel[0]) rammem[adr[21:2]][7:0] <= cpu_dato[7:0];
57
        if (sel[1]) rammem[adr[21:2]][15:8] <= cpu_dato[15:8];
58
        if (sel[2]) rammem[adr[21:2]][23:16] <= cpu_dato[23:16];
59
        if (sel[3]) rammem[adr[21:2]][31:24] <= cpu_dato[31:24];
60
    end
61
 
62 2 robfinch
assign LEDS_ack = cyc && stb && adr[31:8]==32'hFFDC06;
63
always @(posedge clk)
64
        if (LEDS_ack)
65
                $display("LEDS: %b", cpu_dato[7:0]);
66
 
67 21 robfinch
always @(posedge clk)
68
    if ((err1|err2)&&$time > 11000)
69
        $stop;
70
 
71 2 robfinch
wire tc1_ack, tc2_ack;
72
wire kbd_ack;
73
wire [31:0] tc1_dato, tc2_dato;
74
wire [7:0] kbd_dato;
75
 
76
//wire cs0 = cyc&& stb && adr[31:16]==16'h0000;
77
 
78
assign cpu_ack =
79
        LEDS_ack |
80
        scr_ack |
81
        br_ack |
82
        tc1_ack | tc2_ack |
83 21 robfinch
        kbd_ack | pic_ack |
84
        ram_cs | uart_ack
85 2 robfinch
        ;
86
assign cpu_dati =
87
        scr_dato |
88
        br_dato |
89
        tc1_dato | tc2_dato |
90
        {4{kbd_dato}} |
91 21 robfinch
        pic_dato |
92
        ramo |
93
        {4{uart_dato}}
94 2 robfinch
        ;
95
 
96 21 robfinch
rtfSerialTxSim ussim1
97
(
98
    .rst(rst),
99
    .baud16(baud16),
100
    .txd(uart_rxd)
101
);
102
 
103
rtfSimpleUart uuart1
104
(
105
        // WISHBONE Slave interface
106
        .rst_i(rst),                // reset
107
        .clk_i(clk),        // eg 100.7MHz
108
        .cyc_i(cyc),            // cycle valid
109
        .stb_i(stb),            // strobe
110
        .we_i(we),                      // 1 = write
111
        .adr_i(adr),            // register address
112
        .dat_i(cpu_dato[7:0]),   // data input bus
113
        .dat_o(uart_dato),          // data output bus
114
        .ack_o(uart_ack),               // transfer acknowledge
115
        .vol_o(),                       // volatile register selected
116
    .irq_o(uart_irq),           // interrupt request
117
        //----------------
118
        .cts_ni(1'b0),          // clear to send - active low - (flow control)
119
        .rts_no(),      // request to send - active low - (flow control)
120
        .dsr_ni(1'b0),          // data set ready - active low
121
        .dcd_ni(1'b0),          // data carrier detect - active low
122
        .dtr_no(),      // data terminal ready - active low
123
        .rxd_i(uart_rxd),       // serial data in
124
        .txd_o(),                       // serial data out
125
    .data_present_o(),
126
    .baud16_clk(baud16)
127
);
128
 
129 2 robfinch
Ps2Keyboard_sim ukbd
130
(
131
    .rst_i(rst),
132
    .clk_i(cpu_clk),
133
    .cyc_i(cyc),
134
    .stb_i(stb),
135
    .ack_o(kbd_ack),
136
    .we_i(we),
137
    .adr_i(adr),
138
    .dat_i(cpu_dato),
139
    .dat_o(kbd_dato),
140
    .kclk(),
141
    .kd(),
142
    .irq_o()
143
);
144
 
145
rtfTextController3 #(.num(1), .pTextAddress(32'hFFD00000))  tc1
146
(
147
        .rst_i(rst),
148
        .clk_i(cpu_clk),
149
        .cyc_i(cyc),
150
        .stb_i(stb),
151
        .ack_o(tc1_ack),
152
        .we_i(we),
153
        .adr_i(adr),
154
        .dat_i(cpu_dato),
155
        .dat_o(tc1_dato),
156
        .lp(),
157
        .curpos(),
158
        .vclk(),
159
        .hsync(),
160
        .vsync(),
161
        .blank(),
162
        .border(),
163
        .rgbIn(),
164
        .rgbOut()
165
);
166
 
167 21 robfinch
rtfTextController3 #(.num(1), .pTextAddress(32'hFFD10000), .pRegAddress(32'hFFDA0040))  tc2
168 2 robfinch
(
169
        .rst_i(rst),
170
        .clk_i(cpu_clk),
171
        .cyc_i(cyc),
172
        .stb_i(stb),
173
        .ack_o(tc2_ack),
174
        .we_i(we),
175
        .adr_i(adr),
176
        .dat_i(cpu_dato),
177
        .dat_o(tc2_dato),
178
        .lp(),
179
        .curpos(),
180
        .vclk(),
181
        .hsync(),
182
        .vsync(),
183
        .blank(),
184
        .border(),
185
        .rgbIn(),
186
        .rgbOut()
187
);
188
 
189
scratchmem32 #(DBW) uscrm1
190
(
191
        .rst_i(rst),
192
        .clk_i(cpu_clk),
193
        .cyc_i(cyc),
194
        .stb_i(stb),
195
        .ack_o(scr_ack),
196
        .we_i(we),
197
        .sel_i(sel),
198
        .adr_i({32'd0,adr}),
199
        .dat_i(cpu_dato),
200
        .dat_o(scr_dato)
201
);
202
 
203
bootrom #(DBW) ubr1
204
(
205
        .rst_i(rst),
206
        .clk_i(cpu_clk),
207
        .cti_i(cti),
208
        .cyc_i(cyc),
209
        .stb_i(stb),
210
        .ack_o(br_ack),
211
        .adr_i(adr),
212
        .dat_o(br_dato),
213 21 robfinch
        .perr(),
214
        .err1(err1),
215
        .err2(err2)
216 2 robfinch
);
217
 
218
wire nmio;
219
Thor_pic upic1
220
(
221
        .rst_i(rst),            // reset
222
        .clk_i(cpu_clk),        // system clock
223
        .cyc_i(cyc),    // cycle valid
224
        .stb_i(stb),    // strobe
225
    .ack_o(pic_ack),    // transfer acknowledge
226
        .we_i(we),              // write
227
        .adr_i(adr),    // address
228
        .dat_i(cpu_dato),
229
        .dat_o(pic_dato),
230
        .vol_o(),               // volatile register selected
231 21 robfinch
        .i1(p1000Hz),
232 2 robfinch
        .i2(p100Hz),
233
        .i3(),
234
        .i4(),
235
        .i5(),
236
        .i6(),
237 21 robfinch
        .i7(uart_irq),
238 2 robfinch
        .i8(),
239
        .i9(),
240
        .i10(),
241
        .i11(),
242
        .i12(),
243
        .i13(),
244
        .i14(),
245
        .i15(),
246
        .irqo(irq),     // normally connected to the processor irq
247
        .nmii(nmi),             // nmi input connected to nmi requester
248
        .nmio(nmio),    // normally connected to the nmi of cpu
249
        .vecno(vecno)
250
);
251
 
252
Thor #(DBW) uthor1
253
(
254
        .rst_i(rst),
255
        .clk_i(clk),
256
        .clk_o(cpu_clk),
257
        .nmi_i(nmio),
258
        .irq_i(irq),
259
        .vec_i(vecno),
260
        .bte_o(),
261
        .cti_o(cti),
262
        .bl_o(),
263
        .cyc_o(cyc),
264
        .stb_o(stb),
265
        .ack_i(cpu_ack),
266
        .err_i(1'b0),
267
        .we_o(we),
268
        .sel_o(sel),
269
        .adr_o(adr),
270
        .dat_i(cpu_dati),
271
        .dat_o(cpu_dato)
272
);
273
 
274
endmodule

powered by: WebSVN 2.1.0

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