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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 350 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's CPU                                                ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/project,or1k                       ////
7
////                                                              ////
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
// $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
 
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
        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,
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
        abort_mvspr, abort_ex,
73
 
74
        // Data interface
75
        dc_en,
76
        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
 
80
        // SR Interface
81
        boot_adr_sel_i,
82
 
83
        // 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
        spr_dat_dmmu, spr_dat_immu, spr_dat_du, spr_cs, spr_we, mtspr_dc_done
89
);
90
 
91
parameter dw = `OR1200_OPERAND_WIDTH;
92
parameter aw = `OR1200_REGFILE_ADDR_WIDTH;
93 814 olof
parameter boot_adr = `OR1200_BOOT_ADR;
94 350 julius
 
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
output                          id_void;
129
output  [31:0]                   id_insn;
130
output                          ex_void;
131
output  [31:0]                   ex_insn;
132
output                          ex_freeze;
133
output  [31:0]                   wb_insn;
134
output                          wb_freeze;
135
output  [31:0]                   id_pc;
136
output  [31:0]                   ex_pc;
137
output  [31:0]                   wb_pc;
138
output                          ex_flushpipe;
139
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
input   [24:0]                   du_dmr1;
148
input                           du_hwbkpt;
149
input                           du_hwbkpt_ls_r;
150
output  [13:0]                   du_except_trig;
151
output  [13:0]                   du_except_stop;
152
output  [dw-1:0]         du_dat_cpu;
153
output  [dw-1:0]         rf_dataw;
154
output  [dw-1:0]         du_lsu_store_dat;
155
output  [dw-1:0]         du_lsu_load_dat;
156
 
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
output                          dc_no_writethrough;
173
 
174
//
175
// Data (DMMU) interface
176
//
177
output                          sb_en;
178
output                          dmmu_en;
179
output                          abort_ex;
180
output                          abort_mvspr;
181
 
182
//
183
// SR Interface 
184
//
185
input                           boot_adr_sel_i;
186
 
187
//
188
// 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
input                           mtspr_dc_done;
203
 
204
//
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
wire                            saving_if_insn;
215
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
wire    [dw-1:0]         id_simm;
222
wire    [dw-1:2]                id_branch_addrtarget;
223
wire    [dw-1:2]                ex_branch_addrtarget;
224
wire    [`OR1200_ALUOP_WIDTH-1:0]        alu_op;
225 403 julius
wire    [`OR1200_ALUOP2_WIDTH-1:0]       alu_op2;
226 350 julius
wire    [`OR1200_COMPOP_WIDTH-1:0]       comp_op;
227
wire    [`OR1200_BRANCHOP_WIDTH-1:0]     pre_branch_op;
228
wire    [`OR1200_BRANCHOP_WIDTH-1:0]     branch_op;
229
wire    [`OR1200_LSUOP_WIDTH-1:0]        id_lsu_op;
230
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
wire    [`OR1200_FPUOP_WIDTH-1:0]       fpu_op;
239
wire    [dw-1:0]         rf_dataw;
240
wire    [dw-1:0]         rf_dataa;
241
wire    [dw-1:0]         rf_datab;
242
wire    [dw-1:0]         muxed_a;
243
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
wire    [dw-1:0]         fpu_dataout;
252
wire                            fpu_done;
253
wire    [31:0]                   ex_simm;
254
wire    [`OR1200_MULTICYCLE_WIDTH-1:0]   multicycle;
255
wire    [`OR1200_WAIT_ON_WIDTH-1:0]      wait_on;
256
wire    [`OR1200_EXCEPT_WIDTH-1:0]       except_type;
257
wire    [4:0]                    cust5_op;
258
wire    [5:0]                    cust5_limm;
259
wire                            if_flushpipe;
260
wire                            id_flushpipe;
261
wire                            ex_flushpipe;
262
wire                            wb_flushpipe;
263
wire                            extend_flush;
264
wire                            ex_branch_taken;
265
wire                            flag;
266
wire                            flagforw;
267
wire                            flag_we;
268
wire                            flagforw_alu;
269
wire                            flag_we_alu;
270
wire                            flagforw_fpu;
271
wire                            flag_we_fpu;
272
wire                            carry;
273
wire                            cyforw;
274
wire                            cy_we_alu;
275 502 julius
wire                            ovforw;
276
wire                            ov_we_alu;
277
wire                            ovforw_mult_mac;
278
wire                            ov_we_mult_mac;
279 350 julius
wire                            cy_we_rf;
280
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
wire    [`OR1200_FPCSR_WIDTH-1:0]       fpcsr;
289
wire                            fpcsr_we;
290
wire                            sr_we;
291
wire    [`OR1200_SR_WIDTH-1:0]   to_sr;
292
wire    [`OR1200_SR_WIDTH-1:0]   sr;
293 807 julius
wire                            dsx;
294 350 julius
wire                            except_flushpipe;
295
wire                            except_start;
296
wire                            except_started;
297
wire                            fpu_except_started;
298
wire    [31:0]                   wb_insn;
299
wire                            sig_syscall;
300
wire                            sig_trap;
301 502 julius
wire                            sig_range;
302 350 julius
wire                            sig_fp;
303
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
wire [31:0]                      spr_dat_fpu;
309
wire                            mtspr_done;
310
wire                            force_dslot_fetch;
311
wire                            no_more_dslot;
312
wire                            ex_void;
313
wire                            ex_spr_read;
314
wire                            ex_spr_write;
315
wire                            if_stall;
316
wire                            id_macrc_op;
317
wire                            ex_macrc_op;
318
wire    [`OR1200_MACOP_WIDTH-1:0] id_mac_op;
319
wire    [`OR1200_MACOP_WIDTH-1:0] mac_op;
320
wire    [31:0]                   mult_mac_result;
321 435 julius
wire                            mult_mac_stall;
322 350 julius
wire    [13:0]                   except_trig;
323
wire    [13:0]                   except_stop;
324
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
wire                            abort_mvspr;
337
 
338
//
339
// Send exceptions to Debug Unit
340
//
341
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
 
346
//
347
// Data cache enable
348
//
349
`ifdef OR1200_NO_DC
350
assign dc_en = 1'b0;
351
`else
352
   assign dc_en = sr[`OR1200_SR_DCE];
353
`endif
354
 
355
//
356
// Instruction cache enable
357
//
358
`ifdef OR1200_NO_IC
359
assign ic_en = 1'b0;
360
`else
361
assign ic_en = sr[`OR1200_SR_ICE];
362
`endif
363
 
364
//
365
// 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
// DMMU enable
375
//
376
`ifdef OR1200_NO_DMMU
377
assign dmmu_en = 1'b0;
378
`else
379
assign dmmu_en = sr[`OR1200_SR_DME];
380
`endif
381
 
382
//
383
// IMMU enable
384
//
385
`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
 
391
//
392
// SUPV bit
393
//
394
assign supv = sr[`OR1200_SR_SM];
395
 
396
//
397
// FLAG write enable
398
//
399
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
 
402
//
403 502 julius
// Flag for any MTSPR instructions, that must block execution, to indicate done
404 350 julius
//
405
assign mtspr_done = mtspr_dc_done;
406 502 julius
 
407
//
408
// Range exception
409
//
410
assign sig_range = sr[`OR1200_SR_OV];
411 350 julius
 
412
 
413 502 julius
 
414 350 julius
//
415
// Instantiation of instruction fetch block
416
//
417 814 olof
or1200_genpc #(.boot_adr(boot_adr)) or1200_genpc(
418 350 julius
        .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
        .pre_branch_op(pre_branch_op),
428
        .branch_op(branch_op),
429
        .except_type(except_type),
430
        .except_start(except_start),
431
        .except_prefix(sr[`OR1200_SR_EPH]),
432
        .id_branch_addrtarget(id_branch_addrtarget),
433
        .ex_branch_addrtarget(ex_branch_addrtarget),
434
        .muxed_b(muxed_b),
435
        .operand_b(operand_b),
436
        .flag(flag),
437
        .flagforw(flagforw),
438
        .ex_branch_taken(ex_branch_taken),
439
        .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 850 stekern
        .no_more_dslot(no_more_dslot),
445
        .lsu_stall(lsu_stall)
446 350 julius
);
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
        .saving_if_insn(saving_if_insn),
464
        .if_flushpipe(if_flushpipe),
465
        .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
        .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
        .if_insn(if_insn),
491
        .id_insn(id_insn),
492
        .ex_insn(ex_insn),
493
        .id_branch_op(pre_branch_op),
494
        .ex_branch_op(branch_op),
495
        .ex_branch_taken(ex_branch_taken),
496
        .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 403 julius
        .alu_op2(alu_op2),
502 350 julius
        .mac_op(mac_op),
503
        .comp_op(comp_op),
504
        .rf_addrw(rf_addrw),
505
        .rfwb_op(rfwb_op),
506
        .fpu_op(fpu_op),
507
        .pc_we(pc_we),
508
        .wb_insn(wb_insn),
509
        .id_simm(id_simm),
510
        .id_branch_addrtarget(id_branch_addrtarget),
511
        .ex_branch_addrtarget(ex_branch_addrtarget),
512
        .ex_simm(ex_simm),
513
        .sel_a(sel_a),
514
        .sel_b(sel_b),
515
        .id_lsu_op(id_lsu_op),
516
        .cust5_op(cust5_op),
517
        .cust5_limm(cust5_limm),
518
        .id_pc(id_pc),
519
        .ex_pc(ex_pc),
520
        .multicycle(multicycle),
521
        .wait_on(wait_on),
522
        .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
        .id_void(id_void),
528
        .ex_void(ex_void),
529
        .ex_spr_read(ex_spr_read),
530
        .ex_spr_write(ex_spr_write),
531
        .id_mac_op(id_mac_op),
532
        .id_macrc_op(id_macrc_op),
533
        .ex_macrc_op(ex_macrc_op),
534
        .rfe(rfe),
535
        .du_hwbkpt(du_hwbkpt),
536
        .except_illegal(except_illegal),
537
        .dc_no_writethrough(dc_no_writethrough)
538
);
539
 
540
//
541
// Instantiation of register file
542
//
543
or1200_rf or1200_rf(
544
        .clk(clk),
545
        .rst(rst),
546
        .cy_we_i(cy_we_alu),
547
        .cy_we_o(cy_we_rf),
548
        .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
        .flushpipe(wb_flushpipe),
555
        .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
        .spr_dat_o(spr_dat_rf),
566
        .du_read(du_read)
567
);
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
        .simm(id_simm),
582
        .sel_a(sel_a),
583
        .sel_b(sel_b),
584
        .operand_a(operand_a),
585
        .operand_b(operand_b),
586
        .muxed_a(muxed_a),
587
        .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 403 julius
        .alu_op2(alu_op2),
600 350 julius
        .comp_op(comp_op),
601
        .cust5_op(cust5_op),
602
        .cust5_limm(cust5_limm),
603
        .result(alu_dataout),
604
        .flagforw(flagforw_alu),
605
        .flag_we(flag_we_alu),
606
        .cyforw(cyforw),
607
        .cy_we(cy_we_alu),
608 502 julius
        .ovforw(ovforw),
609
        .ov_we(ov_we_alu),
610 350 julius
        .flag(flag),
611
        .carry(carry)
612
);
613
 
614
 
615
//
616
// FPU's exception is being dealt with
617
//    
618
assign fpu_except_started = except_started && (except_type == `OR1200_EXCEPT_FLOAT);
619
 
620
//
621
// 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
        .done(fpu_done),
632
        .flagforw(flagforw_fpu),
633
        .flag_we(flag_we_fpu),
634
        .sig_fp(sig_fp),
635
        .except_started(fpu_except_started),
636
        .fpcsr_we(fpcsr_we),
637
        .fpcsr(fpcsr),
638
        .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
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 502 julius
        .ovforw(ovforw_mult_mac),
661
        .ov_we(ov_we_mult_mac),
662 435 julius
        .mult_mac_stall(mult_mac_stall),
663 350 julius
        .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
        .addrofs(ex_simm[15:0]),
678
        .dat_i(operand_b),
679
        .ex_spr_read(ex_spr_read),
680
        .ex_spr_write(ex_spr_write),
681
        .flagforw(flagforw),
682
        .flag_we(flag_we),
683
        .flag(flag),
684
        .cyforw(cyforw),
685
        .cy_we(cy_we_rf),
686
        .carry(carry),
687 502 julius
        .ovforw(ovforw | ovforw_mult_mac),
688
        .ov_we(ov_we_alu | ov_we_mult_mac),
689 350 julius
        .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
        .boot_adr_sel_i(boot_adr_sel_i),
697
        .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
        .fpcsr(fpcsr),
723
        .fpcsr_we(fpcsr_we),
724
        .spr_dat_fpu(spr_dat_fpu),
725
 
726
        .sr_we(sr_we),
727
        .to_sr(to_sr),
728
        .sr(sr),
729 807 julius
        .branch_op(branch_op),
730
        .dsx(dsx)
731 350 julius
);
732
 
733
//
734
// Instantiation of load/store unit
735
//
736
or1200_lsu or1200_lsu(
737
        .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
        .lsu_datain(operand_b),
745
        .lsu_dataout(lsu_dataout),
746
        .lsu_stall(lsu_stall),
747
        .lsu_unstall(lsu_unstall),
748
        .du_stall(du_stall),
749
        .except_align(except_align),
750
        .except_dtlbmiss(except_dtlbmiss),
751
        .except_dmmufault(except_dmmufault),
752
        .except_dbuserr(except_dbuserr),
753
        .id_freeze(id_freeze),
754
        .ex_freeze(ex_freeze),
755
        .flushpipe(ex_flushpipe),
756
 
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
        .muxin_d(ex_pc),
782
        .muxin_e(fpu_dataout),
783
        .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
        .wait_on(wait_on),
796
        .fpu_done(fpu_done),
797
        .mtspr_done(mtspr_done),
798
        .flushpipe(wb_flushpipe),
799
        .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 435 julius
        .mac_stall(mult_mac_stall),
807 350 julius
        .saving_if_insn(saving_if_insn),
808
        .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 502 julius
        .sig_range(sig_range),
828 350 julius
        .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
        .sig_fp(sig_fp),
837
        .fpcsr_fpee(fpcsr[`OR1200_FPCSR_FPEE]),
838
        .ex_branch_taken(ex_branch_taken),
839
        .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
        .ex_pc(ex_pc),
851
        .wb_pc(wb_pc),
852
        .id_flushpipe(id_flushpipe),
853
        .ex_flushpipe(ex_flushpipe),
854
        .extend_flush(extend_flush),
855
        .except_flushpipe(except_flushpipe),
856
        .abort_mvspr(abort_mvspr),
857
        .except_type(except_type),
858
        .except_start(except_start),
859
        .except_started(except_started),
860
        .except_stop(except_stop),
861
        .except_trig(except_trig),
862
        .ex_void(ex_void),
863
        .spr_dat_ppc(spr_dat_ppc),
864
        .spr_dat_npc(spr_dat_npc),
865
 
866
        .datain(spr_dat_cpu),
867
        .branch_op(branch_op),
868
        .du_dsr(du_dsr),
869
        .du_dmr1(du_dmr1),
870
        .du_hwbkpt(du_hwbkpt),
871
        .du_hwbkpt_ls_r(du_hwbkpt_ls_r),
872
        .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 807 julius
        .abort_ex(abort_ex),
885
        .dsx(dsx)
886 350 julius
);
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.