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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_cpu.v] - Blame information for rev 855

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

Line No. Rev Author Line
1 10 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's CPU                                                ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6 185 julius
////  http://www.opencores.org/project,or1k                       ////
7 10 unneback
////                                                              ////
8
////  Description                                                 ////
9
////  Instantiation of internal CPU blocks. IFETCH, SPRS, FRZ,    ////
10
////  ALU, EXCEPT, ID, WBMUX, OPERANDMUX, RF etc.                 ////
11
////                                                              ////
12
////  To Do:                                                      ////
13
////   - make it smaller and faster                               ////
14
////                                                              ////
15
////  Author(s):                                                  ////
16
////      - Damjan Lampret, lampret@opencores.org                 ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE.  See the GNU Lesser General Public License for more ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
//
45 141 marcus.erl
// $Log: or1200_cpu.v,v $
46
// Revision 2.0  2010/06/30 11:00:00  ORSoC
47
// Major update: 
48
// Structure reordered and bugs fixed. 
49 10 unneback
 
50
// synopsys translate_off
51
`include "timescale.v"
52
// synopsys translate_on
53
`include "or1200_defines.v"
54
 
55
module or1200_cpu(
56
        // Clk & Rst
57
        clk, rst,
58
 
59
        // Insn interface
60
        ic_en,
61
        icpu_adr_o, icpu_cycstb_o, icpu_sel_o, icpu_tag_o,
62
        icpu_dat_i, icpu_ack_i, icpu_rty_i, icpu_err_i, icpu_adr_i, icpu_tag_i,
63
        immu_en,
64
 
65
        // Debug unit
66 141 marcus.erl
        id_void, id_insn, ex_void,
67
        ex_insn, ex_freeze, wb_insn, wb_freeze, id_pc, ex_pc, wb_pc, branch_op,
68
        spr_dat_npc, rf_dataw, ex_flushpipe,
69 258 julius
        du_stall, du_addr, du_dat_du, du_read, du_write, du_except_stop,
70
        du_except_trig, du_dsr, du_dmr1, du_hwbkpt, du_hwbkpt_ls_r, du_dat_cpu,
71
        du_lsu_store_dat, du_lsu_load_dat,
72 141 marcus.erl
        abort_mvspr, abort_ex,
73 10 unneback
 
74
        // Data interface
75
        dc_en,
76 258 julius
        dcpu_adr_o, dcpu_cycstb_o, dcpu_we_o, dcpu_sel_o, dcpu_tag_o,
77
        dcpu_dat_o, dcpu_dat_i, dcpu_ack_i, dcpu_rty_i, dcpu_err_i, dcpu_tag_i,
78
        sb_en, dmmu_en, dc_no_writethrough,
79 10 unneback
 
80 141 marcus.erl
        // SR Interface
81
        boot_adr_sel_i,
82
 
83 10 unneback
        // Interrupt & tick exceptions
84
        sig_int, sig_tick,
85
 
86
        // SPR interface
87
        supv, spr_addr, spr_dat_cpu, spr_dat_pic, spr_dat_tt, spr_dat_pm,
88 258 julius
        spr_dat_dmmu, spr_dat_immu, spr_dat_du, spr_cs, spr_we, mtspr_dc_done
89 10 unneback
);
90
 
91
parameter dw = `OR1200_OPERAND_WIDTH;
92
parameter aw = `OR1200_REGFILE_ADDR_WIDTH;
93 813 olof
parameter boot_adr = `OR1200_BOOT_ADR;
94 10 unneback
 
95
//
96
// I/O ports
97
//
98
 
99
//
100
// Clk & Rst
101
//
102
input                           clk;
103
input                           rst;
104
 
105
//
106
// Insn (IC) interface
107
//
108
output                          ic_en;
109
output  [31:0]                   icpu_adr_o;
110
output                          icpu_cycstb_o;
111
output  [3:0]                    icpu_sel_o;
112
output  [3:0]                    icpu_tag_o;
113
input   [31:0]                   icpu_dat_i;
114
input                           icpu_ack_i;
115
input                           icpu_rty_i;
116
input                           icpu_err_i;
117
input   [31:0]                   icpu_adr_i;
118
input   [3:0]                    icpu_tag_i;
119
 
120
//
121
// Insn (IMMU) interface
122
//
123
output                          immu_en;
124
 
125
//
126
// Debug interface
127
//
128 141 marcus.erl
output                          id_void;
129
output  [31:0]                   id_insn;
130
output                          ex_void;
131 10 unneback
output  [31:0]                   ex_insn;
132
output                          ex_freeze;
133 141 marcus.erl
output  [31:0]                   wb_insn;
134
output                          wb_freeze;
135 10 unneback
output  [31:0]                   id_pc;
136 141 marcus.erl
output  [31:0]                   ex_pc;
137
output  [31:0]                   wb_pc;
138
output                          ex_flushpipe;
139 10 unneback
output  [`OR1200_BRANCHOP_WIDTH-1:0]     branch_op;
140
 
141
input                           du_stall;
142
input   [dw-1:0]         du_addr;
143
input   [dw-1:0]         du_dat_du;
144
input                           du_read;
145
input                           du_write;
146
input   [`OR1200_DU_DSR_WIDTH-1:0]       du_dsr;
147 141 marcus.erl
input   [24:0]                   du_dmr1;
148 10 unneback
input                           du_hwbkpt;
149 141 marcus.erl
input                           du_hwbkpt_ls_r;
150 185 julius
output  [13:0]                   du_except_trig;
151
output  [13:0]                   du_except_stop;
152 10 unneback
output  [dw-1:0]         du_dat_cpu;
153
output  [dw-1:0]         rf_dataw;
154 141 marcus.erl
output  [dw-1:0]         du_lsu_store_dat;
155
output  [dw-1:0]         du_lsu_load_dat;
156 10 unneback
 
157
//
158
// Data (DC) interface
159
//
160
output  [31:0]                   dcpu_adr_o;
161
output                          dcpu_cycstb_o;
162
output                          dcpu_we_o;
163
output  [3:0]                    dcpu_sel_o;
164
output  [3:0]                    dcpu_tag_o;
165
output  [31:0]                   dcpu_dat_o;
166
input   [31:0]                   dcpu_dat_i;
167
input                           dcpu_ack_i;
168
input                           dcpu_rty_i;
169
input                           dcpu_err_i;
170
input   [3:0]                    dcpu_tag_i;
171
output                          dc_en;
172 258 julius
output                          dc_no_writethrough;
173
 
174 10 unneback
//
175
// Data (DMMU) interface
176
//
177 141 marcus.erl
output                          sb_en;
178 10 unneback
output                          dmmu_en;
179 141 marcus.erl
output                          abort_ex;
180
output                          abort_mvspr;
181 10 unneback
 
182
//
183 141 marcus.erl
// SR Interface 
184
//
185
input                           boot_adr_sel_i;
186
 
187
//
188 10 unneback
// SPR interface
189
//
190
output                          supv;
191
input   [dw-1:0]         spr_dat_pic;
192
input   [dw-1:0]         spr_dat_tt;
193
input   [dw-1:0]         spr_dat_pm;
194
input   [dw-1:0]         spr_dat_dmmu;
195
input   [dw-1:0]         spr_dat_immu;
196
input   [dw-1:0]         spr_dat_du;
197
output  [dw-1:0]         spr_addr;
198
output  [dw-1:0]         spr_dat_cpu;
199
output  [dw-1:0]         spr_dat_npc;
200
output  [31:0]                   spr_cs;
201
output                          spr_we;
202 258 julius
input                           mtspr_dc_done;
203
 
204 10 unneback
//
205
// Interrupt exceptions
206
//
207
input                           sig_int;
208
input                           sig_tick;
209
 
210
//
211
// Internal wires
212
//
213
wire    [31:0]                   if_insn;
214 141 marcus.erl
wire                            saving_if_insn;
215 10 unneback
wire    [31:0]                   if_pc;
216
wire    [aw-1:0]         rf_addrw;
217
wire    [aw-1:0]                 rf_addra;
218
wire    [aw-1:0]                 rf_addrb;
219
wire                            rf_rda;
220
wire                            rf_rdb;
221 141 marcus.erl
wire    [dw-1:0]         id_simm;
222
wire    [dw-1:2]                id_branch_addrtarget;
223
wire    [dw-1:2]                ex_branch_addrtarget;
224 10 unneback
wire    [`OR1200_ALUOP_WIDTH-1:0]        alu_op;
225 401 julius
wire    [`OR1200_ALUOP2_WIDTH-1:0]       alu_op2;
226 10 unneback
wire    [`OR1200_COMPOP_WIDTH-1:0]       comp_op;
227 141 marcus.erl
wire    [`OR1200_BRANCHOP_WIDTH-1:0]     pre_branch_op;
228 10 unneback
wire    [`OR1200_BRANCHOP_WIDTH-1:0]     branch_op;
229 141 marcus.erl
wire    [`OR1200_LSUOP_WIDTH-1:0]        id_lsu_op;
230 10 unneback
wire                            genpc_freeze;
231
wire                            if_freeze;
232
wire                            id_freeze;
233
wire                            ex_freeze;
234
wire                            wb_freeze;
235
wire    [`OR1200_SEL_WIDTH-1:0]  sel_a;
236
wire    [`OR1200_SEL_WIDTH-1:0]  sel_b;
237
wire    [`OR1200_RFWBOP_WIDTH-1:0]       rfwb_op;
238 185 julius
wire    [`OR1200_FPUOP_WIDTH-1:0]       fpu_op;
239 10 unneback
wire    [dw-1:0]         rf_dataw;
240
wire    [dw-1:0]         rf_dataa;
241
wire    [dw-1:0]         rf_datab;
242 141 marcus.erl
wire    [dw-1:0]         muxed_a;
243 10 unneback
wire    [dw-1:0]         muxed_b;
244
wire    [dw-1:0]         wb_forw;
245
wire                            wbforw_valid;
246
wire    [dw-1:0]         operand_a;
247
wire    [dw-1:0]         operand_b;
248
wire    [dw-1:0]         alu_dataout;
249
wire    [dw-1:0]         lsu_dataout;
250
wire    [dw-1:0]         sprs_dataout;
251 185 julius
wire    [dw-1:0]         fpu_dataout;
252 258 julius
wire                            fpu_done;
253 141 marcus.erl
wire    [31:0]                   ex_simm;
254 10 unneback
wire    [`OR1200_MULTICYCLE_WIDTH-1:0]   multicycle;
255 258 julius
wire    [`OR1200_WAIT_ON_WIDTH-1:0]      wait_on;
256 10 unneback
wire    [`OR1200_EXCEPT_WIDTH-1:0]       except_type;
257
wire    [4:0]                    cust5_op;
258
wire    [5:0]                    cust5_limm;
259 141 marcus.erl
wire                            if_flushpipe;
260
wire                            id_flushpipe;
261
wire                            ex_flushpipe;
262
wire                            wb_flushpipe;
263 10 unneback
wire                            extend_flush;
264 141 marcus.erl
wire                            ex_branch_taken;
265 10 unneback
wire                            flag;
266
wire                            flagforw;
267
wire                            flag_we;
268 185 julius
wire                            flagforw_alu;
269 141 marcus.erl
wire                            flag_we_alu;
270 185 julius
wire                            flagforw_fpu;
271
wire                            flag_we_fpu;
272 10 unneback
wire                            carry;
273
wire                            cyforw;
274 141 marcus.erl
wire                            cy_we_alu;
275 642 julius
wire                            ovforw;
276
wire                            ov_we_alu;
277
wire                            ovforw_mult_mac;
278
wire                            ov_we_mult_mac;
279 141 marcus.erl
wire                            cy_we_rf;
280 10 unneback
wire                            lsu_stall;
281
wire                            epcr_we;
282
wire                            eear_we;
283
wire                            esr_we;
284
wire                            pc_we;
285
wire    [31:0]                   epcr;
286
wire    [31:0]                   eear;
287
wire    [`OR1200_SR_WIDTH-1:0]   esr;
288 185 julius
wire    [`OR1200_FPCSR_WIDTH-1:0]       fpcsr;
289 258 julius
wire                            fpcsr_we;
290 10 unneback
wire                            sr_we;
291
wire    [`OR1200_SR_WIDTH-1:0]   to_sr;
292
wire    [`OR1200_SR_WIDTH-1:0]   sr;
293 808 julius
wire                            dsx;
294 141 marcus.erl
wire                            except_flushpipe;
295 10 unneback
wire                            except_start;
296
wire                            except_started;
297 185 julius
wire                            fpu_except_started;
298 10 unneback
wire    [31:0]                   wb_insn;
299
wire                            sig_syscall;
300
wire                            sig_trap;
301 642 julius
wire                            sig_range;
302 185 julius
wire                            sig_fp;
303 10 unneback
wire    [31:0]                   spr_dat_cfgr;
304
wire    [31:0]                   spr_dat_rf;
305
wire    [31:0]                  spr_dat_npc;
306
wire    [31:0]                   spr_dat_ppc;
307
wire    [31:0]                   spr_dat_mac;
308 258 julius
wire [31:0]                      spr_dat_fpu;
309
wire                            mtspr_done;
310 10 unneback
wire                            force_dslot_fetch;
311
wire                            no_more_dslot;
312
wire                            ex_void;
313 141 marcus.erl
wire                            ex_spr_read;
314
wire                            ex_spr_write;
315 10 unneback
wire                            if_stall;
316
wire                            id_macrc_op;
317
wire                            ex_macrc_op;
318 141 marcus.erl
wire    [`OR1200_MACOP_WIDTH-1:0] id_mac_op;
319 10 unneback
wire    [`OR1200_MACOP_WIDTH-1:0] mac_op;
320
wire    [31:0]                   mult_mac_result;
321 481 julius
wire                            mult_mac_stall;
322 185 julius
wire    [13:0]                   except_trig;
323
wire    [13:0]                   except_stop;
324 10 unneback
wire                            genpc_refetch;
325
wire                            rfe;
326
wire                            lsu_unstall;
327
wire                            except_align;
328
wire                            except_dtlbmiss;
329
wire                            except_dmmufault;
330
wire                            except_illegal;
331
wire                            except_itlbmiss;
332
wire                            except_immufault;
333
wire                            except_ibuserr;
334
wire                            except_dbuserr;
335
wire                            abort_ex;
336 141 marcus.erl
wire                            abort_mvspr;
337 10 unneback
 
338
//
339
// Send exceptions to Debug Unit
340
//
341 141 marcus.erl
assign du_except_trig = except_trig;
342
assign du_except_stop = except_stop;
343
assign du_lsu_store_dat = operand_b;
344
assign du_lsu_load_dat  = lsu_dataout;
345 10 unneback
 
346
//
347
// Data cache enable
348
//
349 141 marcus.erl
`ifdef OR1200_NO_DC
350
assign dc_en = 1'b0;
351
`else
352 258 julius
   assign dc_en = sr[`OR1200_SR_DCE];
353 141 marcus.erl
`endif
354 10 unneback
 
355
//
356
// Instruction cache enable
357
//
358 141 marcus.erl
`ifdef OR1200_NO_IC
359
assign ic_en = 1'b0;
360
`else
361 10 unneback
assign ic_en = sr[`OR1200_SR_ICE];
362 141 marcus.erl
`endif
363 10 unneback
 
364
//
365 141 marcus.erl
// SB enable
366
//
367
`ifdef OR1200_SB_IMPLEMENTED
368
//assign sb_en = sr[`OR1200_SR_SBE]; // SBE not defined  -- jb
369
`else
370
assign sb_en = 1'b0;
371
`endif
372
 
373
//
374 10 unneback
// DMMU enable
375
//
376 141 marcus.erl
`ifdef OR1200_NO_DMMU
377
assign dmmu_en = 1'b0;
378
`else
379 10 unneback
assign dmmu_en = sr[`OR1200_SR_DME];
380 141 marcus.erl
`endif
381 10 unneback
 
382
//
383
// IMMU enable
384
//
385 141 marcus.erl
`ifdef OR1200_NO_IMMU
386
assign immu_en = 1'b0;
387
`else
388
assign immu_en = sr[`OR1200_SR_IME] & ~except_started;
389
`endif
390 10 unneback
 
391
//
392
// SUPV bit
393
//
394
assign supv = sr[`OR1200_SR_SM];
395
 
396
//
397 141 marcus.erl
// FLAG write enable
398
//
399 185 julius
assign flagforw = (flag_we_alu & flagforw_alu) | (flagforw_fpu & flag_we_fpu);
400
assign flag_we = (flag_we_alu | flag_we_fpu) & ~abort_mvspr;
401 141 marcus.erl
 
402
//
403 642 julius
// Flag for any MTSPR instructions, that must block execution, to indicate done
404 258 julius
//
405
assign mtspr_done = mtspr_dc_done;
406 642 julius
 
407
//
408
// Range exception
409
//
410
assign sig_range = sr[`OR1200_SR_OV];
411 258 julius
 
412
 
413 642 julius
 
414 258 julius
//
415 10 unneback
// Instantiation of instruction fetch block
416
//
417 813 olof
or1200_genpc #(.boot_adr(boot_adr)) or1200_genpc(
418 10 unneback
        .clk(clk),
419
        .rst(rst),
420
        .icpu_adr_o(icpu_adr_o),
421
        .icpu_cycstb_o(icpu_cycstb_o),
422
        .icpu_sel_o(icpu_sel_o),
423
        .icpu_tag_o(icpu_tag_o),
424
        .icpu_rty_i(icpu_rty_i),
425
        .icpu_adr_i(icpu_adr_i),
426
 
427 141 marcus.erl
        .pre_branch_op(pre_branch_op),
428 10 unneback
        .branch_op(branch_op),
429
        .except_type(except_type),
430
        .except_start(except_start),
431
        .except_prefix(sr[`OR1200_SR_EPH]),
432 141 marcus.erl
        .id_branch_addrtarget(id_branch_addrtarget),
433
        .ex_branch_addrtarget(ex_branch_addrtarget),
434
        .muxed_b(muxed_b),
435
        .operand_b(operand_b),
436 10 unneback
        .flag(flag),
437 141 marcus.erl
        .flagforw(flagforw),
438
        .ex_branch_taken(ex_branch_taken),
439 10 unneback
        .epcr(epcr),
440
        .spr_dat_i(spr_dat_cpu),
441
        .spr_pc_we(pc_we),
442
        .genpc_refetch(genpc_refetch),
443
        .genpc_freeze(genpc_freeze),
444 847 stekern
        .no_more_dslot(no_more_dslot),
445
        .lsu_stall(lsu_stall)
446 10 unneback
);
447
 
448
//
449
// Instantiation of instruction fetch block
450
//
451
or1200_if or1200_if(
452
        .clk(clk),
453
        .rst(rst),
454
        .icpu_dat_i(icpu_dat_i),
455
        .icpu_ack_i(icpu_ack_i),
456
        .icpu_err_i(icpu_err_i),
457
        .icpu_adr_i(icpu_adr_i),
458
        .icpu_tag_i(icpu_tag_i),
459
 
460
        .if_freeze(if_freeze),
461
        .if_insn(if_insn),
462
        .if_pc(if_pc),
463 141 marcus.erl
        .saving_if_insn(saving_if_insn),
464
        .if_flushpipe(if_flushpipe),
465 10 unneback
        .if_stall(if_stall),
466
        .no_more_dslot(no_more_dslot),
467
        .genpc_refetch(genpc_refetch),
468
        .rfe(rfe),
469
        .except_itlbmiss(except_itlbmiss),
470
        .except_immufault(except_immufault),
471
        .except_ibuserr(except_ibuserr)
472
);
473
 
474
//
475
// Instantiation of instruction decode/control logic
476
//
477
or1200_ctrl or1200_ctrl(
478
        .clk(clk),
479
        .rst(rst),
480
        .id_freeze(id_freeze),
481
        .ex_freeze(ex_freeze),
482
        .wb_freeze(wb_freeze),
483 141 marcus.erl
        .if_flushpipe(if_flushpipe),
484
        .id_flushpipe(id_flushpipe),
485
        .ex_flushpipe(ex_flushpipe),
486
        .wb_flushpipe(wb_flushpipe),
487
        .extend_flush(extend_flush),
488
        .except_flushpipe(except_flushpipe),
489
        .abort_mvspr(abort_mvspr),
490 10 unneback
        .if_insn(if_insn),
491 141 marcus.erl
        .id_insn(id_insn),
492 10 unneback
        .ex_insn(ex_insn),
493 141 marcus.erl
        .id_branch_op(pre_branch_op),
494
        .ex_branch_op(branch_op),
495
        .ex_branch_taken(ex_branch_taken),
496 10 unneback
        .rf_addra(rf_addra),
497
        .rf_addrb(rf_addrb),
498
        .rf_rda(rf_rda),
499
        .rf_rdb(rf_rdb),
500
        .alu_op(alu_op),
501 401 julius
        .alu_op2(alu_op2),
502 10 unneback
        .mac_op(mac_op),
503
        .comp_op(comp_op),
504
        .rf_addrw(rf_addrw),
505
        .rfwb_op(rfwb_op),
506 185 julius
        .fpu_op(fpu_op),
507 141 marcus.erl
        .pc_we(pc_we),
508 10 unneback
        .wb_insn(wb_insn),
509 141 marcus.erl
        .id_simm(id_simm),
510
        .id_branch_addrtarget(id_branch_addrtarget),
511
        .ex_branch_addrtarget(ex_branch_addrtarget),
512
        .ex_simm(ex_simm),
513 10 unneback
        .sel_a(sel_a),
514
        .sel_b(sel_b),
515 141 marcus.erl
        .id_lsu_op(id_lsu_op),
516 10 unneback
        .cust5_op(cust5_op),
517
        .cust5_limm(cust5_limm),
518 141 marcus.erl
        .id_pc(id_pc),
519
        .ex_pc(ex_pc),
520 10 unneback
        .multicycle(multicycle),
521 258 julius
        .wait_on(wait_on),
522 10 unneback
        .wbforw_valid(wbforw_valid),
523
        .sig_syscall(sig_syscall),
524
        .sig_trap(sig_trap),
525
        .force_dslot_fetch(force_dslot_fetch),
526
        .no_more_dslot(no_more_dslot),
527 141 marcus.erl
        .id_void(id_void),
528 10 unneback
        .ex_void(ex_void),
529 141 marcus.erl
        .ex_spr_read(ex_spr_read),
530
        .ex_spr_write(ex_spr_write),
531
        .id_mac_op(id_mac_op),
532 10 unneback
        .id_macrc_op(id_macrc_op),
533
        .ex_macrc_op(ex_macrc_op),
534
        .rfe(rfe),
535
        .du_hwbkpt(du_hwbkpt),
536 258 julius
        .except_illegal(except_illegal),
537
        .dc_no_writethrough(dc_no_writethrough)
538 10 unneback
);
539
 
540
//
541
// Instantiation of register file
542
//
543
or1200_rf or1200_rf(
544
        .clk(clk),
545
        .rst(rst),
546 141 marcus.erl
        .cy_we_i(cy_we_alu),
547
        .cy_we_o(cy_we_rf),
548 10 unneback
        .supv(sr[`OR1200_SR_SM]),
549
        .wb_freeze(wb_freeze),
550
        .addrw(rf_addrw),
551
        .dataw(rf_dataw),
552
        .id_freeze(id_freeze),
553
        .we(rfwb_op[0]),
554 141 marcus.erl
        .flushpipe(wb_flushpipe),
555 10 unneback
        .addra(rf_addra),
556
        .rda(rf_rda),
557
        .dataa(rf_dataa),
558
        .addrb(rf_addrb),
559
        .rdb(rf_rdb),
560
        .datab(rf_datab),
561
        .spr_cs(spr_cs[`OR1200_SPR_GROUP_SYS]),
562
        .spr_write(spr_we),
563
        .spr_addr(spr_addr),
564
        .spr_dat_i(spr_dat_cpu),
565 258 julius
        .spr_dat_o(spr_dat_rf),
566
        .du_read(du_read)
567 10 unneback
);
568
 
569
//
570
// Instantiation of operand muxes
571
//
572
or1200_operandmuxes or1200_operandmuxes(
573
        .clk(clk),
574
        .rst(rst),
575
        .id_freeze(id_freeze),
576
        .ex_freeze(ex_freeze),
577
        .rf_dataa(rf_dataa),
578
        .rf_datab(rf_datab),
579
        .ex_forw(rf_dataw),
580
        .wb_forw(wb_forw),
581 141 marcus.erl
        .simm(id_simm),
582 10 unneback
        .sel_a(sel_a),
583
        .sel_b(sel_b),
584
        .operand_a(operand_a),
585
        .operand_b(operand_b),
586 141 marcus.erl
        .muxed_a(muxed_a),
587 10 unneback
        .muxed_b(muxed_b)
588
);
589
 
590
//
591
// Instantiation of CPU's ALU
592
//
593
or1200_alu or1200_alu(
594
        .a(operand_a),
595
        .b(operand_b),
596
        .mult_mac_result(mult_mac_result),
597
        .macrc_op(ex_macrc_op),
598
        .alu_op(alu_op),
599 401 julius
        .alu_op2(alu_op2),
600 10 unneback
        .comp_op(comp_op),
601
        .cust5_op(cust5_op),
602
        .cust5_limm(cust5_limm),
603
        .result(alu_dataout),
604 185 julius
        .flagforw(flagforw_alu),
605 141 marcus.erl
        .flag_we(flag_we_alu),
606 10 unneback
        .cyforw(cyforw),
607 141 marcus.erl
        .cy_we(cy_we_alu),
608 642 julius
        .ovforw(ovforw),
609
        .ov_we(ov_we_alu),
610 141 marcus.erl
        .flag(flag),
611 10 unneback
        .carry(carry)
612
);
613
 
614 185 julius
 
615 10 unneback
//
616 185 julius
// FPU's exception is being dealt with
617
//    
618
assign fpu_except_started = except_started && (except_type == `OR1200_EXCEPT_FLOAT);
619
 
620 10 unneback
//
621 185 julius
// Instantiation of FPU
622
//
623
or1200_fpu or1200_fpu(
624
        .clk(clk),
625
        .rst(rst),
626
        .ex_freeze(ex_freeze),
627
        .a(operand_a),
628
        .b(operand_b),
629
        .fpu_op(fpu_op),
630
        .result(fpu_dataout),
631 258 julius
        .done(fpu_done),
632 185 julius
        .flagforw(flagforw_fpu),
633
        .flag_we(flag_we_fpu),
634
        .sig_fp(sig_fp),
635 258 julius
        .except_started(fpu_except_started),
636 185 julius
        .fpcsr_we(fpcsr_we),
637 258 julius
        .fpcsr(fpcsr),
638 185 julius
        .spr_cs(spr_cs[`OR1200_SPR_GROUP_FPU]),
639
        .spr_write(spr_we),
640
        .spr_addr(spr_addr),
641
        .spr_dat_i(spr_dat_cpu),
642
        .spr_dat_o(spr_dat_fpu)
643
);
644
 
645
 
646
//
647
// Instantiation of CPU's multiply unit
648
//
649 10 unneback
or1200_mult_mac or1200_mult_mac(
650
        .clk(clk),
651
        .rst(rst),
652
        .ex_freeze(ex_freeze),
653
        .id_macrc_op(id_macrc_op),
654
        .macrc_op(ex_macrc_op),
655
        .a(operand_a),
656
        .b(operand_b),
657
        .mac_op(mac_op),
658
        .alu_op(alu_op),
659
        .result(mult_mac_result),
660 642 julius
        .ovforw(ovforw_mult_mac),
661
        .ov_we(ov_we_mult_mac),
662 481 julius
        .mult_mac_stall(mult_mac_stall),
663 10 unneback
        .spr_cs(spr_cs[`OR1200_SPR_GROUP_MAC]),
664
        .spr_write(spr_we),
665
        .spr_addr(spr_addr),
666
        .spr_dat_i(spr_dat_cpu),
667
        .spr_dat_o(spr_dat_mac)
668
);
669
 
670
//
671
// Instantiation of CPU's SPRS block
672
//
673
or1200_sprs or1200_sprs(
674
        .clk(clk),
675
        .rst(rst),
676
        .addrbase(operand_a),
677 141 marcus.erl
        .addrofs(ex_simm[15:0]),
678 10 unneback
        .dat_i(operand_b),
679 141 marcus.erl
        .ex_spr_read(ex_spr_read),
680
        .ex_spr_write(ex_spr_write),
681 10 unneback
        .flagforw(flagforw),
682
        .flag_we(flag_we),
683
        .flag(flag),
684
        .cyforw(cyforw),
685 141 marcus.erl
        .cy_we(cy_we_rf),
686 10 unneback
        .carry(carry),
687 642 julius
        .ovforw(ovforw | ovforw_mult_mac),
688
        .ov_we(ov_we_alu | ov_we_mult_mac),
689 10 unneback
        .to_wbmux(sprs_dataout),
690
 
691
        .du_addr(du_addr),
692
        .du_dat_du(du_dat_du),
693
        .du_read(du_read),
694
        .du_write(du_write),
695
        .du_dat_cpu(du_dat_cpu),
696 141 marcus.erl
        .boot_adr_sel_i(boot_adr_sel_i),
697 10 unneback
        .spr_addr(spr_addr),
698
        .spr_dat_pic(spr_dat_pic),
699
        .spr_dat_tt(spr_dat_tt),
700
        .spr_dat_pm(spr_dat_pm),
701
        .spr_dat_cfgr(spr_dat_cfgr),
702
        .spr_dat_rf(spr_dat_rf),
703
        .spr_dat_npc(spr_dat_npc),
704
        .spr_dat_ppc(spr_dat_ppc),
705
        .spr_dat_mac(spr_dat_mac),
706
        .spr_dat_dmmu(spr_dat_dmmu),
707
        .spr_dat_immu(spr_dat_immu),
708
        .spr_dat_du(spr_dat_du),
709
        .spr_dat_o(spr_dat_cpu),
710
        .spr_cs(spr_cs),
711
        .spr_we(spr_we),
712
 
713
        .epcr_we(epcr_we),
714
        .eear_we(eear_we),
715
        .esr_we(esr_we),
716
        .pc_we(pc_we),
717
        .epcr(epcr),
718
        .eear(eear),
719
        .esr(esr),
720
        .except_started(except_started),
721
 
722 185 julius
        .fpcsr(fpcsr),
723 258 julius
        .fpcsr_we(fpcsr_we),
724 185 julius
        .spr_dat_fpu(spr_dat_fpu),
725
 
726 10 unneback
        .sr_we(sr_we),
727
        .to_sr(to_sr),
728
        .sr(sr),
729 808 julius
        .branch_op(branch_op),
730
        .dsx(dsx)
731 10 unneback
);
732
 
733
//
734
// Instantiation of load/store unit
735
//
736
or1200_lsu or1200_lsu(
737 141 marcus.erl
        .clk(clk),
738
        .rst(rst),
739
        .id_addrbase(muxed_a),
740
        .id_addrofs(id_simm),
741
        .ex_addrbase(operand_a),
742
        .ex_addrofs(ex_simm),
743
        .id_lsu_op(id_lsu_op),
744 10 unneback
        .lsu_datain(operand_b),
745
        .lsu_dataout(lsu_dataout),
746
        .lsu_stall(lsu_stall),
747
        .lsu_unstall(lsu_unstall),
748 141 marcus.erl
        .du_stall(du_stall),
749 10 unneback
        .except_align(except_align),
750
        .except_dtlbmiss(except_dtlbmiss),
751
        .except_dmmufault(except_dmmufault),
752
        .except_dbuserr(except_dbuserr),
753 141 marcus.erl
        .id_freeze(id_freeze),
754
        .ex_freeze(ex_freeze),
755
        .flushpipe(ex_flushpipe),
756 10 unneback
 
757
        .dcpu_adr_o(dcpu_adr_o),
758
        .dcpu_cycstb_o(dcpu_cycstb_o),
759
        .dcpu_we_o(dcpu_we_o),
760
        .dcpu_sel_o(dcpu_sel_o),
761
        .dcpu_tag_o(dcpu_tag_o),
762
        .dcpu_dat_o(dcpu_dat_o),
763
        .dcpu_dat_i(dcpu_dat_i),
764
        .dcpu_ack_i(dcpu_ack_i),
765
        .dcpu_rty_i(dcpu_rty_i),
766
        .dcpu_err_i(dcpu_err_i),
767
        .dcpu_tag_i(dcpu_tag_i)
768
);
769
 
770
//
771
// Instantiation of write-back muxes
772
//
773
or1200_wbmux or1200_wbmux(
774
        .clk(clk),
775
        .rst(rst),
776
        .wb_freeze(wb_freeze),
777
        .rfwb_op(rfwb_op),
778
        .muxin_a(alu_dataout),
779
        .muxin_b(lsu_dataout),
780
        .muxin_c(sprs_dataout),
781 141 marcus.erl
        .muxin_d(ex_pc),
782 185 julius
        .muxin_e(fpu_dataout),
783 10 unneback
        .muxout(rf_dataw),
784
        .muxreg(wb_forw),
785
        .muxreg_valid(wbforw_valid)
786
);
787
 
788
//
789
// Instantiation of freeze logic
790
//
791
or1200_freeze or1200_freeze(
792
        .clk(clk),
793
        .rst(rst),
794
        .multicycle(multicycle),
795 258 julius
        .wait_on(wait_on),
796
        .fpu_done(fpu_done),
797
        .mtspr_done(mtspr_done),
798 141 marcus.erl
        .flushpipe(wb_flushpipe),
799 10 unneback
        .extend_flush(extend_flush),
800
        .lsu_stall(lsu_stall),
801
        .if_stall(if_stall),
802
        .lsu_unstall(lsu_unstall),
803
        .force_dslot_fetch(force_dslot_fetch),
804
        .abort_ex(abort_ex),
805
        .du_stall(du_stall),
806 481 julius
        .mac_stall(mult_mac_stall),
807 141 marcus.erl
        .saving_if_insn(saving_if_insn),
808 10 unneback
        .genpc_freeze(genpc_freeze),
809
        .if_freeze(if_freeze),
810
        .id_freeze(id_freeze),
811
        .ex_freeze(ex_freeze),
812
        .wb_freeze(wb_freeze),
813
        .icpu_ack_i(icpu_ack_i),
814
        .icpu_err_i(icpu_err_i)
815
);
816
 
817
//
818
// Instantiation of exception block
819
//
820
or1200_except or1200_except(
821
        .clk(clk),
822
        .rst(rst),
823
        .sig_ibuserr(except_ibuserr),
824
        .sig_dbuserr(except_dbuserr),
825
        .sig_illegal(except_illegal),
826
        .sig_align(except_align),
827 642 julius
        .sig_range(sig_range),
828 10 unneback
        .sig_dtlbmiss(except_dtlbmiss),
829
        .sig_dmmufault(except_dmmufault),
830
        .sig_int(sig_int),
831
        .sig_syscall(sig_syscall),
832
        .sig_trap(sig_trap),
833
        .sig_itlbmiss(except_itlbmiss),
834
        .sig_immufault(except_immufault),
835
        .sig_tick(sig_tick),
836 185 julius
        .sig_fp(sig_fp),
837 258 julius
        .fpcsr_fpee(fpcsr[`OR1200_FPCSR_FPEE]),
838 141 marcus.erl
        .ex_branch_taken(ex_branch_taken),
839 10 unneback
        .icpu_ack_i(icpu_ack_i),
840
        .icpu_err_i(icpu_err_i),
841
        .dcpu_ack_i(dcpu_ack_i),
842
        .dcpu_err_i(dcpu_err_i),
843
        .genpc_freeze(genpc_freeze),
844
        .id_freeze(id_freeze),
845
        .ex_freeze(ex_freeze),
846
        .wb_freeze(wb_freeze),
847
        .if_stall(if_stall),
848
        .if_pc(if_pc),
849
        .id_pc(id_pc),
850 141 marcus.erl
        .ex_pc(ex_pc),
851
        .wb_pc(wb_pc),
852
        .id_flushpipe(id_flushpipe),
853
        .ex_flushpipe(ex_flushpipe),
854 10 unneback
        .extend_flush(extend_flush),
855 141 marcus.erl
        .except_flushpipe(except_flushpipe),
856
        .abort_mvspr(abort_mvspr),
857 10 unneback
        .except_type(except_type),
858
        .except_start(except_start),
859
        .except_started(except_started),
860
        .except_stop(except_stop),
861 141 marcus.erl
        .except_trig(except_trig),
862 10 unneback
        .ex_void(ex_void),
863
        .spr_dat_ppc(spr_dat_ppc),
864
        .spr_dat_npc(spr_dat_npc),
865
 
866 141 marcus.erl
        .datain(spr_dat_cpu),
867
        .branch_op(branch_op),
868 10 unneback
        .du_dsr(du_dsr),
869 141 marcus.erl
        .du_dmr1(du_dmr1),
870
        .du_hwbkpt(du_hwbkpt),
871
        .du_hwbkpt_ls_r(du_hwbkpt_ls_r),
872 10 unneback
        .epcr_we(epcr_we),
873
        .eear_we(eear_we),
874
        .esr_we(esr_we),
875
        .pc_we(pc_we),
876
        .epcr(epcr),
877
        .eear(eear),
878
        .esr(esr),
879
 
880
        .lsu_addr(dcpu_adr_o),
881
        .sr_we(sr_we),
882
        .to_sr(to_sr),
883
        .sr(sr),
884 808 julius
        .abort_ex(abort_ex),
885
        .dsx(dsx)
886 10 unneback
);
887
 
888
//
889
// Instantiation of configuration registers
890
//
891
or1200_cfgr or1200_cfgr(
892
        .spr_addr(spr_addr),
893
        .spr_dat_o(spr_dat_cfgr)
894
);
895
 
896
endmodule

powered by: WebSVN 2.1.0

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