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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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