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 814

Go to most recent revision | 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
        .no_more_dslot(no_more_dslot)
445
);
446
 
447
//
448
// Instantiation of instruction fetch block
449
//
450
or1200_if or1200_if(
451
        .clk(clk),
452
        .rst(rst),
453
        .icpu_dat_i(icpu_dat_i),
454
        .icpu_ack_i(icpu_ack_i),
455
        .icpu_err_i(icpu_err_i),
456
        .icpu_adr_i(icpu_adr_i),
457
        .icpu_tag_i(icpu_tag_i),
458
 
459
        .if_freeze(if_freeze),
460
        .if_insn(if_insn),
461
        .if_pc(if_pc),
462
        .saving_if_insn(saving_if_insn),
463
        .if_flushpipe(if_flushpipe),
464
        .if_stall(if_stall),
465
        .no_more_dslot(no_more_dslot),
466
        .genpc_refetch(genpc_refetch),
467
        .rfe(rfe),
468
        .except_itlbmiss(except_itlbmiss),
469
        .except_immufault(except_immufault),
470
        .except_ibuserr(except_ibuserr)
471
);
472
 
473
//
474
// Instantiation of instruction decode/control logic
475
//
476
or1200_ctrl or1200_ctrl(
477
        .clk(clk),
478
        .rst(rst),
479
        .id_freeze(id_freeze),
480
        .ex_freeze(ex_freeze),
481
        .wb_freeze(wb_freeze),
482
        .if_flushpipe(if_flushpipe),
483
        .id_flushpipe(id_flushpipe),
484
        .ex_flushpipe(ex_flushpipe),
485
        .wb_flushpipe(wb_flushpipe),
486
        .extend_flush(extend_flush),
487
        .except_flushpipe(except_flushpipe),
488
        .abort_mvspr(abort_mvspr),
489
        .if_insn(if_insn),
490
        .id_insn(id_insn),
491
        .ex_insn(ex_insn),
492
        .id_branch_op(pre_branch_op),
493
        .ex_branch_op(branch_op),
494
        .ex_branch_taken(ex_branch_taken),
495
        .rf_addra(rf_addra),
496
        .rf_addrb(rf_addrb),
497
        .rf_rda(rf_rda),
498
        .rf_rdb(rf_rdb),
499
        .alu_op(alu_op),
500 403 julius
        .alu_op2(alu_op2),
501 350 julius
        .mac_op(mac_op),
502
        .comp_op(comp_op),
503
        .rf_addrw(rf_addrw),
504
        .rfwb_op(rfwb_op),
505
        .fpu_op(fpu_op),
506
        .pc_we(pc_we),
507
        .wb_insn(wb_insn),
508
        .id_simm(id_simm),
509
        .id_branch_addrtarget(id_branch_addrtarget),
510
        .ex_branch_addrtarget(ex_branch_addrtarget),
511
        .ex_simm(ex_simm),
512
        .sel_a(sel_a),
513
        .sel_b(sel_b),
514
        .id_lsu_op(id_lsu_op),
515
        .cust5_op(cust5_op),
516
        .cust5_limm(cust5_limm),
517
        .id_pc(id_pc),
518
        .ex_pc(ex_pc),
519
        .multicycle(multicycle),
520
        .wait_on(wait_on),
521
        .wbforw_valid(wbforw_valid),
522
        .sig_syscall(sig_syscall),
523
        .sig_trap(sig_trap),
524
        .force_dslot_fetch(force_dslot_fetch),
525
        .no_more_dslot(no_more_dslot),
526
        .id_void(id_void),
527
        .ex_void(ex_void),
528
        .ex_spr_read(ex_spr_read),
529
        .ex_spr_write(ex_spr_write),
530
        .id_mac_op(id_mac_op),
531
        .id_macrc_op(id_macrc_op),
532
        .ex_macrc_op(ex_macrc_op),
533
        .rfe(rfe),
534
        .du_hwbkpt(du_hwbkpt),
535
        .except_illegal(except_illegal),
536
        .dc_no_writethrough(dc_no_writethrough)
537
);
538
 
539
//
540
// Instantiation of register file
541
//
542
or1200_rf or1200_rf(
543
        .clk(clk),
544
        .rst(rst),
545
        .cy_we_i(cy_we_alu),
546
        .cy_we_o(cy_we_rf),
547
        .supv(sr[`OR1200_SR_SM]),
548
        .wb_freeze(wb_freeze),
549
        .addrw(rf_addrw),
550
        .dataw(rf_dataw),
551
        .id_freeze(id_freeze),
552
        .we(rfwb_op[0]),
553
        .flushpipe(wb_flushpipe),
554
        .addra(rf_addra),
555
        .rda(rf_rda),
556
        .dataa(rf_dataa),
557
        .addrb(rf_addrb),
558
        .rdb(rf_rdb),
559
        .datab(rf_datab),
560
        .spr_cs(spr_cs[`OR1200_SPR_GROUP_SYS]),
561
        .spr_write(spr_we),
562
        .spr_addr(spr_addr),
563
        .spr_dat_i(spr_dat_cpu),
564
        .spr_dat_o(spr_dat_rf),
565
        .du_read(du_read)
566
);
567
 
568
//
569
// Instantiation of operand muxes
570
//
571
or1200_operandmuxes or1200_operandmuxes(
572
        .clk(clk),
573
        .rst(rst),
574
        .id_freeze(id_freeze),
575
        .ex_freeze(ex_freeze),
576
        .rf_dataa(rf_dataa),
577
        .rf_datab(rf_datab),
578
        .ex_forw(rf_dataw),
579
        .wb_forw(wb_forw),
580
        .simm(id_simm),
581
        .sel_a(sel_a),
582
        .sel_b(sel_b),
583
        .operand_a(operand_a),
584
        .operand_b(operand_b),
585
        .muxed_a(muxed_a),
586
        .muxed_b(muxed_b)
587
);
588
 
589
//
590
// Instantiation of CPU's ALU
591
//
592
or1200_alu or1200_alu(
593
        .a(operand_a),
594
        .b(operand_b),
595
        .mult_mac_result(mult_mac_result),
596
        .macrc_op(ex_macrc_op),
597
        .alu_op(alu_op),
598 403 julius
        .alu_op2(alu_op2),
599 350 julius
        .comp_op(comp_op),
600
        .cust5_op(cust5_op),
601
        .cust5_limm(cust5_limm),
602
        .result(alu_dataout),
603
        .flagforw(flagforw_alu),
604
        .flag_we(flag_we_alu),
605
        .cyforw(cyforw),
606
        .cy_we(cy_we_alu),
607 502 julius
        .ovforw(ovforw),
608
        .ov_we(ov_we_alu),
609 350 julius
        .flag(flag),
610
        .carry(carry)
611
);
612
 
613
 
614
//
615
// FPU's exception is being dealt with
616
//    
617
assign fpu_except_started = except_started && (except_type == `OR1200_EXCEPT_FLOAT);
618
 
619
//
620
// Instantiation of FPU
621
//
622
or1200_fpu or1200_fpu(
623
        .clk(clk),
624
        .rst(rst),
625
        .ex_freeze(ex_freeze),
626
        .a(operand_a),
627
        .b(operand_b),
628
        .fpu_op(fpu_op),
629
        .result(fpu_dataout),
630
        .done(fpu_done),
631
        .flagforw(flagforw_fpu),
632
        .flag_we(flag_we_fpu),
633
        .sig_fp(sig_fp),
634
        .except_started(fpu_except_started),
635
        .fpcsr_we(fpcsr_we),
636
        .fpcsr(fpcsr),
637
        .spr_cs(spr_cs[`OR1200_SPR_GROUP_FPU]),
638
        .spr_write(spr_we),
639
        .spr_addr(spr_addr),
640
        .spr_dat_i(spr_dat_cpu),
641
        .spr_dat_o(spr_dat_fpu)
642
);
643
 
644
 
645
//
646
// Instantiation of CPU's multiply unit
647
//
648
or1200_mult_mac or1200_mult_mac(
649
        .clk(clk),
650
        .rst(rst),
651
        .ex_freeze(ex_freeze),
652
        .id_macrc_op(id_macrc_op),
653
        .macrc_op(ex_macrc_op),
654
        .a(operand_a),
655
        .b(operand_b),
656
        .mac_op(mac_op),
657
        .alu_op(alu_op),
658
        .result(mult_mac_result),
659 502 julius
        .ovforw(ovforw_mult_mac),
660
        .ov_we(ov_we_mult_mac),
661 435 julius
        .mult_mac_stall(mult_mac_stall),
662 350 julius
        .spr_cs(spr_cs[`OR1200_SPR_GROUP_MAC]),
663
        .spr_write(spr_we),
664
        .spr_addr(spr_addr),
665
        .spr_dat_i(spr_dat_cpu),
666
        .spr_dat_o(spr_dat_mac)
667
);
668
 
669
//
670
// Instantiation of CPU's SPRS block
671
//
672
or1200_sprs or1200_sprs(
673
        .clk(clk),
674
        .rst(rst),
675
        .addrbase(operand_a),
676
        .addrofs(ex_simm[15:0]),
677
        .dat_i(operand_b),
678
        .ex_spr_read(ex_spr_read),
679
        .ex_spr_write(ex_spr_write),
680
        .flagforw(flagforw),
681
        .flag_we(flag_we),
682
        .flag(flag),
683
        .cyforw(cyforw),
684
        .cy_we(cy_we_rf),
685
        .carry(carry),
686 502 julius
        .ovforw(ovforw | ovforw_mult_mac),
687
        .ov_we(ov_we_alu | ov_we_mult_mac),
688 350 julius
        .to_wbmux(sprs_dataout),
689
 
690
        .du_addr(du_addr),
691
        .du_dat_du(du_dat_du),
692
        .du_read(du_read),
693
        .du_write(du_write),
694
        .du_dat_cpu(du_dat_cpu),
695
        .boot_adr_sel_i(boot_adr_sel_i),
696
        .spr_addr(spr_addr),
697
        .spr_dat_pic(spr_dat_pic),
698
        .spr_dat_tt(spr_dat_tt),
699
        .spr_dat_pm(spr_dat_pm),
700
        .spr_dat_cfgr(spr_dat_cfgr),
701
        .spr_dat_rf(spr_dat_rf),
702
        .spr_dat_npc(spr_dat_npc),
703
        .spr_dat_ppc(spr_dat_ppc),
704
        .spr_dat_mac(spr_dat_mac),
705
        .spr_dat_dmmu(spr_dat_dmmu),
706
        .spr_dat_immu(spr_dat_immu),
707
        .spr_dat_du(spr_dat_du),
708
        .spr_dat_o(spr_dat_cpu),
709
        .spr_cs(spr_cs),
710
        .spr_we(spr_we),
711
 
712
        .epcr_we(epcr_we),
713
        .eear_we(eear_we),
714
        .esr_we(esr_we),
715
        .pc_we(pc_we),
716
        .epcr(epcr),
717
        .eear(eear),
718
        .esr(esr),
719
        .except_started(except_started),
720
 
721
        .fpcsr(fpcsr),
722
        .fpcsr_we(fpcsr_we),
723
        .spr_dat_fpu(spr_dat_fpu),
724
 
725
        .sr_we(sr_we),
726
        .to_sr(to_sr),
727
        .sr(sr),
728 807 julius
        .branch_op(branch_op),
729
        .dsx(dsx)
730 350 julius
);
731
 
732
//
733
// Instantiation of load/store unit
734
//
735
or1200_lsu or1200_lsu(
736
        .clk(clk),
737
        .rst(rst),
738
        .id_addrbase(muxed_a),
739
        .id_addrofs(id_simm),
740
        .ex_addrbase(operand_a),
741
        .ex_addrofs(ex_simm),
742
        .id_lsu_op(id_lsu_op),
743
        .lsu_datain(operand_b),
744
        .lsu_dataout(lsu_dataout),
745
        .lsu_stall(lsu_stall),
746
        .lsu_unstall(lsu_unstall),
747
        .du_stall(du_stall),
748
        .except_align(except_align),
749
        .except_dtlbmiss(except_dtlbmiss),
750
        .except_dmmufault(except_dmmufault),
751
        .except_dbuserr(except_dbuserr),
752
        .id_freeze(id_freeze),
753
        .ex_freeze(ex_freeze),
754
        .flushpipe(ex_flushpipe),
755
 
756
        .dcpu_adr_o(dcpu_adr_o),
757
        .dcpu_cycstb_o(dcpu_cycstb_o),
758
        .dcpu_we_o(dcpu_we_o),
759
        .dcpu_sel_o(dcpu_sel_o),
760
        .dcpu_tag_o(dcpu_tag_o),
761
        .dcpu_dat_o(dcpu_dat_o),
762
        .dcpu_dat_i(dcpu_dat_i),
763
        .dcpu_ack_i(dcpu_ack_i),
764
        .dcpu_rty_i(dcpu_rty_i),
765
        .dcpu_err_i(dcpu_err_i),
766
        .dcpu_tag_i(dcpu_tag_i)
767
);
768
 
769
//
770
// Instantiation of write-back muxes
771
//
772
or1200_wbmux or1200_wbmux(
773
        .clk(clk),
774
        .rst(rst),
775
        .wb_freeze(wb_freeze),
776
        .rfwb_op(rfwb_op),
777
        .muxin_a(alu_dataout),
778
        .muxin_b(lsu_dataout),
779
        .muxin_c(sprs_dataout),
780
        .muxin_d(ex_pc),
781
        .muxin_e(fpu_dataout),
782
        .muxout(rf_dataw),
783
        .muxreg(wb_forw),
784
        .muxreg_valid(wbforw_valid)
785
);
786
 
787
//
788
// Instantiation of freeze logic
789
//
790
or1200_freeze or1200_freeze(
791
        .clk(clk),
792
        .rst(rst),
793
        .multicycle(multicycle),
794
        .wait_on(wait_on),
795
        .fpu_done(fpu_done),
796
        .mtspr_done(mtspr_done),
797
        .flushpipe(wb_flushpipe),
798
        .extend_flush(extend_flush),
799
        .lsu_stall(lsu_stall),
800
        .if_stall(if_stall),
801
        .lsu_unstall(lsu_unstall),
802
        .force_dslot_fetch(force_dslot_fetch),
803
        .abort_ex(abort_ex),
804
        .du_stall(du_stall),
805 435 julius
        .mac_stall(mult_mac_stall),
806 350 julius
        .saving_if_insn(saving_if_insn),
807
        .genpc_freeze(genpc_freeze),
808
        .if_freeze(if_freeze),
809
        .id_freeze(id_freeze),
810
        .ex_freeze(ex_freeze),
811
        .wb_freeze(wb_freeze),
812
        .icpu_ack_i(icpu_ack_i),
813
        .icpu_err_i(icpu_err_i)
814
);
815
 
816
//
817
// Instantiation of exception block
818
//
819
or1200_except or1200_except(
820
        .clk(clk),
821
        .rst(rst),
822
        .sig_ibuserr(except_ibuserr),
823
        .sig_dbuserr(except_dbuserr),
824
        .sig_illegal(except_illegal),
825
        .sig_align(except_align),
826 502 julius
        .sig_range(sig_range),
827 350 julius
        .sig_dtlbmiss(except_dtlbmiss),
828
        .sig_dmmufault(except_dmmufault),
829
        .sig_int(sig_int),
830
        .sig_syscall(sig_syscall),
831
        .sig_trap(sig_trap),
832
        .sig_itlbmiss(except_itlbmiss),
833
        .sig_immufault(except_immufault),
834
        .sig_tick(sig_tick),
835
        .sig_fp(sig_fp),
836
        .fpcsr_fpee(fpcsr[`OR1200_FPCSR_FPEE]),
837
        .ex_branch_taken(ex_branch_taken),
838
        .icpu_ack_i(icpu_ack_i),
839
        .icpu_err_i(icpu_err_i),
840
        .dcpu_ack_i(dcpu_ack_i),
841
        .dcpu_err_i(dcpu_err_i),
842
        .genpc_freeze(genpc_freeze),
843
        .id_freeze(id_freeze),
844
        .ex_freeze(ex_freeze),
845
        .wb_freeze(wb_freeze),
846
        .if_stall(if_stall),
847
        .if_pc(if_pc),
848
        .id_pc(id_pc),
849
        .ex_pc(ex_pc),
850
        .wb_pc(wb_pc),
851
        .id_flushpipe(id_flushpipe),
852
        .ex_flushpipe(ex_flushpipe),
853
        .extend_flush(extend_flush),
854
        .except_flushpipe(except_flushpipe),
855
        .abort_mvspr(abort_mvspr),
856
        .except_type(except_type),
857
        .except_start(except_start),
858
        .except_started(except_started),
859
        .except_stop(except_stop),
860
        .except_trig(except_trig),
861
        .ex_void(ex_void),
862
        .spr_dat_ppc(spr_dat_ppc),
863
        .spr_dat_npc(spr_dat_npc),
864
 
865
        .datain(spr_dat_cpu),
866
        .branch_op(branch_op),
867
        .du_dsr(du_dsr),
868
        .du_dmr1(du_dmr1),
869
        .du_hwbkpt(du_hwbkpt),
870
        .du_hwbkpt_ls_r(du_hwbkpt_ls_r),
871
        .epcr_we(epcr_we),
872
        .eear_we(eear_we),
873
        .esr_we(esr_we),
874
        .pc_we(pc_we),
875
        .epcr(epcr),
876
        .eear(eear),
877
        .esr(esr),
878
 
879
        .lsu_addr(dcpu_adr_o),
880
        .sr_we(sr_we),
881
        .to_sr(to_sr),
882
        .sr(sr),
883 807 julius
        .abort_ex(abort_ex),
884
        .dsx(dsx)
885 350 julius
);
886
 
887
//
888
// Instantiation of configuration registers
889
//
890
or1200_cfgr or1200_cfgr(
891
        .spr_addr(spr_addr),
892
        .spr_dat_o(spr_dat_cfgr)
893
);
894
 
895
endmodule

powered by: WebSVN 2.1.0

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