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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [or1200/] [rtl/] [verilog/] [or1200.v] - Blame information for rev 203

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

Line No. Rev Author Line
1 161 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200 Top Level                                            ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  OR1200 Top Level                                            ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - make it smaller and faster                               ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 203 lampret
// Revision 1.4  2001/08/13 03:36:20  lampret
48
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
49
//
50 170 lampret
// Revision 1.3  2001/08/09 13:39:33  lampret
51
// Major clean-up.
52
//
53 168 lampret
// Revision 1.2  2001/07/22 03:31:54  lampret
54
// Fixed RAM's oen bug. Cache bypass under development.
55
//
56 166 lampret
// Revision 1.1  2001/07/20 00:46:21  lampret
57
// Development version of RTL. Libraries are missing.
58 161 lampret
//
59 166 lampret
//
60 161 lampret
 
61 203 lampret
// synopsys translate_off
62 168 lampret
`include "timescale.v"
63 203 lampret
// synopsys translate_on
64 168 lampret
`include "defines.v"
65 161 lampret
 
66
module or1200(
67 168 lampret
        // System
68 161 lampret
        clk, rst, pic_ints, clkdiv_by_2,
69
 
70
        // Instruction WISHBONE INTERFACE
71
        iwb_clk_i, iwb_rst_i, iwb_ack_i, iwb_err_i, iwb_rty_i, iwb_dat_i,
72
        iwb_cyc_o, iwb_adr_o, iwb_stb_o, iwb_we_o, iwb_sel_o, iwb_dat_o,
73
 
74
        // Data WISHBONE INTERFACE
75
        dwb_clk_i, dwb_rst_i, dwb_ack_i, dwb_err_i, dwb_rty_i, dwb_dat_i,
76
        dwb_cyc_o, dwb_adr_o, dwb_stb_o, dwb_we_o, dwb_sel_o, dwb_dat_o,
77
 
78
        // Trace
79
        tp_dir_in, tp_sel, tp_in, tp_out,
80
 
81
        // Power Management
82
        pm_clksd, pm_cpustall, pm_dc_gate, pm_ic_gate, pm_dmmu_gate,
83
        pm_immu_gate, pm_tt_gate, pm_cpu_gate, pm_wakeup, pm_lvolt
84
 
85
);
86
 
87
parameter dw = `OPERAND_WIDTH;
88
parameter aw = `OPERAND_WIDTH;
89
parameter ppic_ints = `PIC_INTS;
90
 
91
//
92 168 lampret
// I/O
93
//
94
 
95
//
96
// System
97
//
98
input                   clk;
99
input                   rst;
100
input                   clkdiv_by_2;
101
input   [ppic_ints-1:0]  pic_ints;
102
 
103
//
104 161 lampret
// Instruction WISHBONE interface
105
//
106
input                   iwb_clk_i;      // clock input
107
input                   iwb_rst_i;      // reset input
108
input                   iwb_ack_i;      // normal termination
109
input                   iwb_err_i;      // termination w/ error
110
input                   iwb_rty_i;      // termination w/ retry
111 168 lampret
input   [dw-1:0] iwb_dat_i;      // input data bus
112 161 lampret
output                  iwb_cyc_o;      // cycle valid output
113 168 lampret
output  [aw-1:0] iwb_adr_o;      // address bus outputs
114 161 lampret
output                  iwb_stb_o;      // strobe output
115
output                  iwb_we_o;       // indicates write transfer
116 168 lampret
output  [3:0]            iwb_sel_o;      // byte select outputs
117
output  [dw-1:0] iwb_dat_o;      // output data bus
118 161 lampret
 
119
//
120
// Data WISHBONE interface
121
//
122
input                   dwb_clk_i;      // clock input
123
input                   dwb_rst_i;      // reset input
124
input                   dwb_ack_i;      // normal termination
125
input                   dwb_err_i;      // termination w/ error
126
input                   dwb_rty_i;      // termination w/ retry
127 168 lampret
input   [dw-1:0] dwb_dat_i;      // input data bus
128 161 lampret
output                  dwb_cyc_o;      // cycle valid output
129 168 lampret
output  [aw-1:0] dwb_adr_o;      // address bus outputs
130 161 lampret
output                  dwb_stb_o;      // strobe output
131
output                  dwb_we_o;       // indicates write transfer
132 168 lampret
output  [3:0]            dwb_sel_o;      // byte select outputs
133
output  [dw-1:0] dwb_dat_o;      // output data bus
134 161 lampret
 
135
//
136 168 lampret
// Power Management
137 161 lampret
//
138
input                   pm_cpustall;
139 168 lampret
output                  pm_clksd;
140
output                  pm_dc_gate;
141
output                  pm_ic_gate;
142
output                  pm_dmmu_gate;
143
output                  pm_immu_gate;
144
output                  pm_tt_gate;
145
output                  pm_cpu_gate;
146
output                  pm_wakeup;
147
output                  pm_lvolt;
148 161 lampret
 
149 168 lampret
//
150
// Internal wires and regs
151
//
152
 
153
//
154 161 lampret
// DC to BIU
155 168 lampret
//
156 170 lampret
wire                    dcbiu_rdy;
157
wire    [dw-1:0]         dcbiu_from_biu;
158
wire    [dw-1:0]         dcbiu_to_biu;
159
wire    [aw-1:0]         dcbiu_addr;
160
wire                    dcbiu_read;
161
wire                    dcbiu_write;
162
wire    [3:0]            dcbiu_sel;
163 161 lampret
 
164 168 lampret
//
165 161 lampret
// IC to BIU
166 168 lampret
//
167 170 lampret
wire                    icbiu_rdy;
168
wire    [dw-1:0] icbiu_from_biu;
169
wire    [aw-1:0] icbiu_addr;
170
wire                    icbiu_read;
171
wire    [3:0]            icbiu_sel;
172 161 lampret
 
173 168 lampret
//
174 161 lampret
// CPU's SPR access to various RISC units (shared wires)
175 168 lampret
//
176 203 lampret
wire                    supv;
177 170 lampret
wire    [aw-1:0] spr_addr;
178
wire    [dw-1:0] spr_dat_cpu;
179
wire    [31:0]           spr_cs;
180 161 lampret
wire                    spr_we;
181
 
182 168 lampret
//
183 203 lampret
// DMMU and CPU
184
//
185
wire                    dmmu_en;
186
wire                    dmmuexcept_miss;
187
wire                    dmmuexcept_fault;
188
wire    [31:0]           spr_dat_dmmu;
189
 
190
//
191
// DMMU and DC
192
//
193
wire    [aw-1:0] dcdmmu_paddr;
194
 
195
//
196 161 lampret
// DC and CPU's LSU
197 168 lampret
//
198 170 lampret
wire                    dclsu_stall;
199 203 lampret
wire                    dclsu_unstall;
200 170 lampret
wire    [aw-1:0] dclsu_addr;
201
wire    [aw-1:0] dclsu_from_dc;
202
wire    [aw-1:0] dclsu_to_dc;
203
wire    [`LSUOP_WIDTH-1:0] dclsu_lsuop;
204 168 lampret
wire                    dc_en;
205 161 lampret
 
206 168 lampret
//
207 203 lampret
// IMMU and CPU
208
//
209
wire                    immu_en;
210
wire                    immuexcept_miss;
211
wire                    immuexcept_fault;
212
wire    [31:0]           spr_dat_immu;
213
 
214
//
215 161 lampret
// IC and CPU's ifetch
216 168 lampret
//
217 170 lampret
wire                    icfetch_stall;
218
wire    [aw-1:0] icfetch_addr;
219
wire    [dw-1:0] icfetch_dataout;
220 203 lampret
wire    [`FETCHOP_WIDTH-1:0] icfetch_op;
221 170 lampret
wire                    ic_en;
222 161 lampret
 
223 168 lampret
//
224 203 lampret
// IMMU and IC
225
//
226
wire    [aw-1:0] icimmu_paddr;
227
 
228
//
229 161 lampret
// Connection between CPU and PIC
230 168 lampret
//
231 170 lampret
wire    [dw-1:0] spr_dat_pic;
232
wire                    pic_wakeup;
233
wire                    int_low;
234
wire                    int_high;
235 161 lampret
wire                    int_high_tt;
236
 
237 168 lampret
//
238 161 lampret
// Connection between CPU and PM
239 168 lampret
//
240 170 lampret
wire    [dw-1:0] spr_dat_pm;
241 161 lampret
 
242 168 lampret
//
243 161 lampret
// CPU and TT
244 168 lampret
//
245 170 lampret
wire    [dw-1:0] spr_dat_tt;
246 161 lampret
wire                    tt_int;
247
 
248 168 lampret
//
249 161 lampret
// CPU and external Trace port
250 168 lampret
//
251 170 lampret
input                   tp_dir_in;
252
input   [1:0]            tp_sel;
253
input   [dw-1:0]         tp_in;
254
output  [dw-1:0] tp_out;
255 161 lampret
 
256 168 lampret
//
257 161 lampret
// Trace port and caches/MMUs
258 168 lampret
//
259 170 lampret
wire    [`TP2W_WIDTH-1:0] tp2w;
260
wire    [`TP3W_WIDTH-1:0] tp3w;
261 161 lampret
 
262
//
263
// Assignments
264
//
265
assign int_high_tt = int_high | tt_int;
266
 
267
//
268
// Instantiation of Instruction WISHBONE BIU
269
//
270
wb_biu iwb_biu(
271
        // WISHBONE interface
272
        .wb_clk_i(iwb_clk_i),
273
        .wb_rst_i(iwb_rst_i),
274
        .wb_ack_i(iwb_ack_i),
275
        .wb_err_i(iwb_err_i),
276
        .wb_rty_i(iwb_rty_i),
277
        .wb_dat_i(iwb_dat_i),
278
        .wb_cyc_o(iwb_cyc_o),
279
        .wb_adr_o(iwb_adr_o),
280
        .wb_stb_o(iwb_stb_o),
281
        .wb_we_o(iwb_we_o),
282
        .wb_sel_o(iwb_sel_o),
283
        .wb_dat_o(iwb_dat_o),
284
 
285
        // Internal RISC bus
286
        .biu_to_biu(32'b0),
287
        .biu_addr(icbiu_addr),
288
        .biu_read(icbiu_read),
289
        .biu_write(1'b0),
290
        .biu_rdy(icbiu_rdy),
291 166 lampret
        .biu_from_biu(icbiu_from_biu),
292 170 lampret
        .biu_sel(icbiu_sel)
293 161 lampret
);
294
 
295
//
296
// Instantiation of Data WISHBONE BIU
297
//
298
wb_biu dwb_biu(
299
        // WISHBONE interface
300
        .wb_clk_i(dwb_clk_i),
301
        .wb_rst_i(dwb_rst_i),
302
        .wb_ack_i(dwb_ack_i),
303
        .wb_err_i(dwb_err_i),
304
        .wb_rty_i(dwb_rty_i),
305
        .wb_dat_i(dwb_dat_i),
306
        .wb_cyc_o(dwb_cyc_o),
307
        .wb_adr_o(dwb_adr_o),
308
        .wb_stb_o(dwb_stb_o),
309
        .wb_we_o(dwb_we_o),
310
        .wb_sel_o(dwb_sel_o),
311
        .wb_dat_o(dwb_dat_o),
312
 
313
        // Internal RISC bus
314
        .biu_to_biu(dcbiu_to_biu),
315
        .biu_addr(dcbiu_addr),
316
        .biu_read(dcbiu_read),
317
        .biu_write(dcbiu_write),
318
        .biu_rdy(dcbiu_rdy),
319 166 lampret
        .biu_from_biu(dcbiu_from_biu),
320
        .biu_sel(dcbiu_sel)
321 161 lampret
);
322
 
323
//
324 203 lampret
// Instantiation of IMMU
325
//
326
immu immu(
327
        // Rst and clk
328
        .clk(clk),
329
        .rst(rst),
330
 
331
        // Fetch i/f
332
        .immu_en(immu_en),
333
        .supv(supv),
334
        .immufetch_vaddr(icfetch_addr),
335
        .immufetch_op(icfetch_op),
336
        .immufetch_stall(),
337
 
338
        // Except I/F
339
        .immuexcept_miss(immuexcept_miss),
340
        .immuexcept_fault(immuexcept_fault),
341
 
342
        // SPR access
343
        .spr_cs(spr_cs[`SPR_GROUP_IMMU]),
344
        .spr_write(spr_we),
345
        .spr_addr(spr_addr),
346
        .spr_dat_i(spr_dat_cpu),
347
        .spr_dat_o(spr_dat_immu),
348
 
349
        // IC i/f
350
        .icimmu_paddr(icimmu_paddr)
351
);
352
 
353
//
354 161 lampret
// Instantiation of Instruction Cache
355
//
356
ic ic(
357
        .clk(clk),
358
        .rst(rst),
359
        .clkdiv_by_2(clkdiv_by_2),
360
 
361
        // These connect IC to CPU's ifetch
362 203 lampret
        .icfetch_addr(icimmu_paddr),
363
        .icfetch_op(icfetch_op),
364 161 lampret
        .icfetch_dataout(icfetch_dataout),
365
        .icfetch_stall(icfetch_stall),
366 170 lampret
        .ic_en(ic_en),
367 161 lampret
 
368
        // These connect IC to BIU
369
        .icbiu_rdy(icbiu_rdy),
370
        .icbiu_datain(icbiu_from_biu),
371
        .icbiu_addr(icbiu_addr),
372
        .icbiu_read(icbiu_read),
373 170 lampret
        .icbiu_sel(icbiu_sel),
374 161 lampret
 
375
        // These connect IC to SPRS
376 168 lampret
        .spr_dat_i(spr_dat_cpu)
377 161 lampret
);
378
 
379
//
380
// Instantiation of Instruction Cache
381
//
382
cpu cpu(
383
        .clk(clk),
384
        .rst(rst),
385
 
386 203 lampret
        // Connection IC and IFETCHER inside CPU
387 161 lampret
        .ic_insn(icfetch_dataout),
388 203 lampret
        .ic_addr(icfetch_addr),
389 161 lampret
        .ic_stall(icfetch_stall),
390 203 lampret
        .ic_fetchop(icfetch_op),
391 170 lampret
        .ic_en(ic_en),
392 161 lampret
 
393 203 lampret
        // Connection CPU to external Trace port
394 161 lampret
        .tp_dir_in(tp_dir_in),
395
        .tp_sel(tp_sel),
396
        .tp_in(tp_in),
397
        .tp_out(tp_out),
398
 
399 203 lampret
        // Connection IMMU and CPU internally
400
        .immu_en(immu_en),
401
        .immuexcept_miss(immuexcept_miss),
402
        .immuexcept_fault(immuexcept_fault),
403
 
404
        // Connection DMMU and CPU internally
405
        .dmmu_en(dmmu_en),
406
        .dmmuexcept_miss(dmmuexcept_miss),
407
        .dmmuexcept_fault(dmmuexcept_fault),
408
 
409
        // Connection DC and CPU's LSU
410 161 lampret
        .dclsu_stall(dclsu_stall),
411 203 lampret
        .dclsu_unstall(dclsu_unstall),
412 161 lampret
        .dclsu_addr(dclsu_addr),
413
        .dclsu_datain(dclsu_from_dc),
414
        .dclsu_dataout(dclsu_to_dc),
415
        .dclsu_lsuop(dclsu_lsuop),
416 168 lampret
        .dc_en(dc_en),
417 161 lampret
 
418 203 lampret
        // Connection PIC and CPU's EXCEPT
419 161 lampret
        .int_high(int_high_tt),
420
        .int_low(int_low),
421
 
422
        // SPRs
423 203 lampret
        .supv(supv),
424 161 lampret
        .spr_addr(spr_addr),
425
        .spr_dataout(spr_dat_cpu),
426
        .spr_dat_pic(spr_dat_pic),
427
        .spr_dat_tt(spr_dat_tt),
428
        .spr_dat_pm(spr_dat_pm),
429 203 lampret
        .spr_dat_dmmu(spr_dat_dmmu),
430 161 lampret
        .spr_cs(spr_cs),
431
        .spr_we(spr_we),
432
 
433
        // These connect trace port to caches and MMUs
434
        .tp2w(tp2w),
435 168 lampret
        .tp3w(tp3w)
436 161 lampret
);
437
 
438
//
439 203 lampret
// Instantiation of DMMU
440
//
441
dmmu dmmu(
442
        // Rst and clk
443
        .clk(clk),
444
        .rst(rst),
445
 
446
        // LSU i/f
447
        .dmmu_en(dmmu_en),
448
        .supv(supv),
449
        .dmmulsu_vaddr(dclsu_addr),
450
        .dmmulsu_lsuop(dclsu_lsuop),
451
        .dmmulsu_stall(),
452
 
453
        // Except I/F
454
        .dmmuexcept_miss(dmmuexcept_miss),
455
        .dmmuexcept_fault(dmmuexcept_fault),
456
 
457
        // SPR access
458
        .spr_cs(spr_cs[`SPR_GROUP_DMMU]),
459
        .spr_write(spr_we),
460
        .spr_addr(spr_addr),
461
        .spr_dat_i(spr_dat_cpu),
462
        .spr_dat_o(spr_dat_dmmu),
463
 
464
        // DC i/f
465
        .dcdmmu_paddr(dcdmmu_paddr)
466
);
467
 
468
//
469 161 lampret
// Instantiation of Data Cache
470
//
471
dc dc(
472
        .clk(clk),
473
        .rst(rst),
474
        .clkdiv_by_2(clkdiv_by_2),
475
 
476
        // These connect DC to CPU's LSU
477 203 lampret
        .dclsu_addr(dcdmmu_paddr),
478 161 lampret
        .dclsu_lsuop(dclsu_lsuop),
479
        .dclsu_datain(dclsu_to_dc),
480
        .dclsu_dataout(dclsu_from_dc),
481
        .dclsu_stall(dclsu_stall),
482 203 lampret
        .dclsu_unstall(dclsu_unstall),
483 168 lampret
        .dc_en(dc_en),
484 161 lampret
 
485
        // These connect DC to BIU
486
        .dcbiu_rdy(dcbiu_rdy),
487
        .dcbiu_datain(dcbiu_from_biu),
488
        .dcbiu_dataout(dcbiu_to_biu),
489
        .dcbiu_addr(dcbiu_addr),
490
        .dcbiu_read(dcbiu_read),
491
        .dcbiu_write(dcbiu_write),
492 166 lampret
        .dcbiu_sel(dcbiu_sel),
493 161 lampret
 
494
        // Trace port
495 168 lampret
        .tp2w(tp2w)
496 161 lampret
);
497
 
498
//
499
// Programmable interrupt controller
500
//
501
pic pic(
502
        // RISC Internal Interface
503
        .clk(clk),
504
        .rst(rst),
505
        .spr_cs(spr_cs[`SPR_GROUP_PIC]),
506
        .spr_write(spr_we),
507
        .spr_addr(spr_addr),
508
        .spr_dat_i(spr_dat_cpu),
509
        .spr_dat_o(spr_dat_pic),
510
        .pic_wakeup(pic_wakeup),
511
        .int_low(int_low),
512
        .int_high(int_high),
513
 
514
        // PIC Interface
515
        .pic_int(pic_ints)
516
);
517
 
518
//
519
// Instantiation of Tick timer
520
//
521
tt tt(
522
        // RISC Internal Interface
523
        .clk(clk),
524
        .rst(rst),
525
        .spr_cs(spr_cs[`SPR_GROUP_TT]),
526
        .spr_write(spr_we),
527
        .spr_addr(spr_addr),
528
        .spr_dat_i(spr_dat_cpu),
529
        .spr_dat_o(spr_dat_tt),
530
        .int(tt_int)
531
);
532
 
533
//
534
// Instantiation of Power Management
535
//
536
pm pm(
537
        // RISC Internal Interface
538
        .clk(clk),
539
        .rst(rst),
540
        .pic_wakeup(pic_wakeup),
541
        .spr_write(spr_we),
542
        .spr_addr(spr_addr),
543
        .spr_dat_i(spr_dat_cpu),
544
        .spr_dat_o(spr_dat_pm),
545
 
546
        // Power Management Interface
547
        .pm_clksd(pm_clksd),
548
        .pm_cpustall(pm_cpustall),
549
        .pm_dc_gate(pm_dc_gate),
550
        .pm_ic_gate(pm_ic_gate),
551
        .pm_dmmu_gate(pm_dmmu_gate),
552
        .pm_immu_gate(pm_immu_gate),
553
        .pm_tt_gate(pm_tt_gate),
554
        .pm_cpu_gate(pm_cpu_gate),
555
        .pm_wakeup(pm_wakeup),
556
        .pm_lvolt(pm_lvolt)
557
);
558
 
559
 
560
endmodule

powered by: WebSVN 2.1.0

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