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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm3/] [verilog/] [or1200_cpu.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's CPU                                                ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/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
// CVS Revision History
46
//
47
// $Log: not supported by cvs2svn $
48
// Revision 1.15  2004/05/09 19:49:04  lampret
49
// Added some l.cust5 custom instructions as example
50
//
51
// Revision 1.14  2004/04/05 08:29:57  lampret
52
// Merged branch_qmem into main tree.
53
//
54
// Revision 1.12.4.2  2004/02/11 01:40:11  lampret
55
// preliminary HW breakpoints support in debug unit (by default disabled). To enable define OR1200_DU_HWBKPTS.
56
//
57
// Revision 1.12.4.1  2003/12/09 11:46:48  simons
58
// Mbist nameing changed, Artisan ram instance signal names fixed, some synthesis waning fixed.
59
//
60
// Revision 1.12  2002/09/07 05:42:02  lampret
61
// Added optional SR[CY]. Added define to enable additional (compare) flag modifiers. Defines are OR1200_IMPL_ADDC and OR1200_ADDITIONAL_FLAG_MODIFIERS.
62
//
63
// Revision 1.11  2002/08/28 01:44:25  lampret
64
// Removed some commented RTL. Fixed SR/ESR flag bug.
65
//
66
// Revision 1.10  2002/07/14 22:17:17  lampret
67
// Added simple trace buffer [only for Xilinx Virtex target]. Fixed instruction fetch abort when new exception is recognized.
68
//
69
// Revision 1.9  2002/03/29 16:29:37  lampret
70
// Fixed some ports in instnatiations that were removed from the modules
71
//
72
// Revision 1.8  2002/03/29 15:16:54  lampret
73
// Some of the warnings fixed.
74
//
75
// Revision 1.7  2002/02/11 04:33:17  lampret
76
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
77
//
78
// Revision 1.6  2002/02/01 19:56:54  lampret
79
// Fixed combinational loops.
80
//
81
// Revision 1.5  2002/01/28 01:15:59  lampret
82
// Changed 'void' nop-ops instead of insn[0] to use insn[16]. Debug unit stalls the tick timer. Prepared new flag generation for add and and insns. Blocked DC/IC while they are turned off. Fixed I/D MMU SPRs layout except WAYs. TODO: smart IC invalidate, l.j 2 and TLB ways.
83
//
84
// Revision 1.4  2002/01/18 14:21:43  lampret
85
// Fixed 'the NPC single-step fix'.
86
//
87
// Revision 1.3  2002/01/18 07:56:00  lampret
88
// No more low/high priority interrupts (PICPR removed). Added tick timer exception. Added exception prefix (SR[EPH]). Fixed single-step bug whenreading NPC.
89
//
90
// Revision 1.2  2002/01/14 06:18:22  lampret
91
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
92
//
93
// Revision 1.1  2002/01/03 08:16:15  lampret
94
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
95
//
96
// Revision 1.19  2001/11/30 18:59:47  simons
97
// *** empty log message ***
98
//
99
// Revision 1.18  2001/11/23 21:42:31  simons
100
// Program counter divided to PPC and NPC.
101
//
102
// Revision 1.17  2001/11/23 08:38:51  lampret
103
// Changed DSR/DRR behavior and exception detection.
104
//
105
// Revision 1.16  2001/11/20 00:57:22  lampret
106
// Fixed width of du_except.
107
//
108
// Revision 1.15  2001/11/18 09:58:28  lampret
109
// Fixed some l.trap typos.
110
//
111
// Revision 1.14  2001/11/18 08:36:28  lampret
112
// For GDB changed single stepping and disabled trap exception.
113
//
114
// Revision 1.13  2001/11/13 10:02:21  lampret
115
// Added 'setpc'. Renamed some signals (except_flushpipe into flushpipe etc)
116
//
117
// Revision 1.12  2001/11/12 01:45:40  lampret
118
// Moved flag bit into SR. Changed RF enable from constant enable to dynamic enable for read ports.
119
//
120
// Revision 1.11  2001/11/10 03:43:57  lampret
121
// Fixed exceptions.
122
//
123
// Revision 1.10  2001/10/21 17:57:16  lampret
124
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
125
//
126
// Revision 1.9  2001/10/14 13:12:09  lampret
127
// MP3 version.
128
//
129
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
130
// no message
131
//
132
// Revision 1.4  2001/08/17 08:01:19  lampret
133
// IC enable/disable.
134
//
135
// Revision 1.3  2001/08/13 03:36:20  lampret
136
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
137
//
138
// Revision 1.2  2001/08/09 13:39:33  lampret
139
// Major clean-up.
140
//
141
// Revision 1.1  2001/07/20 00:46:03  lampret
142
// Development version of RTL. Libraries are missing.
143
//
144
//
145
 
146
// synopsys translate_off
147
`include "timescale.v"
148
// synopsys translate_on
149
`include "or1200_defines.v"
150
 
151
module or1200_cpu_cm3(
152
                clk_i_cml_1,
153
                clk_i_cml_2,
154
                cmls,
155
 
156
        // Clk & Rst
157
        clk, rst,
158
 
159
        // Insn interface
160
        ic_en,
161
        icpu_adr_o, icpu_cycstb_o, icpu_sel_o, icpu_tag_o,
162
        icpu_dat_i, icpu_ack_i, icpu_rty_i, icpu_err_i, icpu_adr_i, icpu_tag_i,
163
        immu_en,
164
 
165
        // Debug unit
166
        ex_insn, ex_freeze, id_pc, branch_op,
167
        spr_dat_npc, rf_dataw,
168
        du_stall, du_addr, du_dat_du, du_read, du_write, du_dsr, du_hwbkpt,
169
        du_except, du_dat_cpu,
170
 
171
        // Data interface
172
        dc_en,
173
        dcpu_adr_o, dcpu_cycstb_o, dcpu_we_o, dcpu_sel_o, dcpu_tag_o, dcpu_dat_o,
174
        dcpu_dat_i, dcpu_ack_i, dcpu_rty_i, dcpu_err_i, dcpu_tag_i,
175
        dmmu_en,
176
 
177
        // Interrupt & tick exceptions
178
        sig_int, sig_tick,
179
 
180
        // SPR interface
181
        supv, spr_addr, spr_dat_cpu, spr_dat_pic, spr_dat_tt, spr_dat_pm,
182
        spr_dat_dmmu, spr_dat_immu, spr_dat_du, spr_cs, spr_we
183
);
184
 
185
 
186
input clk_i_cml_1;
187
input clk_i_cml_2;
188
input [1:0] cmls;
189
reg [ 31 : 0 ] spr_cs_cml_2;
190
reg [ 31 : 0 ] spr_cs_cml_1;
191
reg [ 3 - 1 : 0 ] rfwb_op_cml_2;
192
reg [ 3 - 1 : 0 ] rfwb_op_cml_1;
193
reg [ 16 - 1 : 0 ] sr_cml_2;
194
reg [ 16 - 1 : 0 ] sr_cml_1;
195
 
196
 
197
 
198
parameter dw = `OR1200_OPERAND_WIDTH;
199
parameter aw = `OR1200_REGFILE_ADDR_WIDTH;
200
 
201
//
202
// I/O ports
203
//
204
 
205
//
206
// Clk & Rst
207
//
208
input                           clk;
209
input                           rst;
210
 
211
//
212
// Insn (IC) interface
213
//
214
output                          ic_en;
215
output  [31:0]                   icpu_adr_o;
216
output                          icpu_cycstb_o;
217
output  [3:0]                    icpu_sel_o;
218
output  [3:0]                    icpu_tag_o;
219
input   [31:0]                   icpu_dat_i;
220
input                           icpu_ack_i;
221
input                           icpu_rty_i;
222
input                           icpu_err_i;
223
input   [31:0]                   icpu_adr_i;
224
input   [3:0]                    icpu_tag_i;
225
 
226
//
227
// Insn (IMMU) interface
228
//
229
output                          immu_en;
230
 
231
//
232
// Debug interface
233
//
234
output  [31:0]                   ex_insn;
235
output                          ex_freeze;
236
output  [31:0]                   id_pc;
237
output  [`OR1200_BRANCHOP_WIDTH-1:0]     branch_op;
238
 
239
input                           du_stall;
240
input   [dw-1:0]         du_addr;
241
input   [dw-1:0]         du_dat_du;
242
input                           du_read;
243
input                           du_write;
244
input   [`OR1200_DU_DSR_WIDTH-1:0]       du_dsr;
245
input                           du_hwbkpt;
246
output  [12:0]                   du_except;
247
output  [dw-1:0]         du_dat_cpu;
248
output  [dw-1:0]         rf_dataw;
249
 
250
//
251
// Data (DC) interface
252
//
253
output  [31:0]                   dcpu_adr_o;
254
output                          dcpu_cycstb_o;
255
output                          dcpu_we_o;
256
output  [3:0]                    dcpu_sel_o;
257
output  [3:0]                    dcpu_tag_o;
258
output  [31:0]                   dcpu_dat_o;
259
input   [31:0]                   dcpu_dat_i;
260
input                           dcpu_ack_i;
261
input                           dcpu_rty_i;
262
input                           dcpu_err_i;
263
input   [3:0]                    dcpu_tag_i;
264
output                          dc_en;
265
 
266
//
267
// Data (DMMU) interface
268
//
269
output                          dmmu_en;
270
 
271
//
272
// SPR interface
273
//
274
output                          supv;
275
input   [dw-1:0]         spr_dat_pic;
276
input   [dw-1:0]         spr_dat_tt;
277
input   [dw-1:0]         spr_dat_pm;
278
input   [dw-1:0]         spr_dat_dmmu;
279
input   [dw-1:0]         spr_dat_immu;
280
input   [dw-1:0]         spr_dat_du;
281
output  [dw-1:0]         spr_addr;
282
output  [dw-1:0]         spr_dat_cpu;
283
output  [dw-1:0]         spr_dat_npc;
284
output  [31:0]                   spr_cs;
285
output                          spr_we;
286
 
287
//
288
// Interrupt exceptions
289
//
290
input                           sig_int;
291
input                           sig_tick;
292
 
293
//
294
// Internal wires
295
//
296
wire    [31:0]                   if_insn;
297
wire    [31:0]                   if_pc;
298
wire    [31:2]                  lr_sav;
299
wire    [aw-1:0]         rf_addrw;
300
wire    [aw-1:0]                 rf_addra;
301
wire    [aw-1:0]                 rf_addrb;
302
wire                            rf_rda;
303
wire                            rf_rdb;
304
wire    [dw-1:0]         simm;
305
wire    [dw-1:2]                branch_addrofs;
306
wire    [`OR1200_ALUOP_WIDTH-1:0]        alu_op;
307
wire    [`OR1200_SHROTOP_WIDTH-1:0]      shrot_op;
308
wire    [`OR1200_COMPOP_WIDTH-1:0]       comp_op;
309
wire    [`OR1200_BRANCHOP_WIDTH-1:0]     branch_op;
310
wire    [`OR1200_LSUOP_WIDTH-1:0]        lsu_op;
311
wire                            genpc_freeze;
312
wire                            if_freeze;
313
wire                            id_freeze;
314
wire                            ex_freeze;
315
wire                            wb_freeze;
316
wire    [`OR1200_SEL_WIDTH-1:0]  sel_a;
317
wire    [`OR1200_SEL_WIDTH-1:0]  sel_b;
318
wire    [`OR1200_RFWBOP_WIDTH-1:0]       rfwb_op;
319
wire    [dw-1:0]         rf_dataw;
320
wire    [dw-1:0]         rf_dataa;
321
wire    [dw-1:0]         rf_datab;
322
wire    [dw-1:0]         muxed_b;
323
wire    [dw-1:0]         wb_forw;
324
wire                            wbforw_valid;
325
wire    [dw-1:0]         operand_a;
326
wire    [dw-1:0]         operand_b;
327
wire    [dw-1:0]         alu_dataout;
328
wire    [dw-1:0]         lsu_dataout;
329
wire    [dw-1:0]         sprs_dataout;
330
wire    [31:0]                   lsu_addrofs;
331
wire    [`OR1200_MULTICYCLE_WIDTH-1:0]   multicycle;
332
wire    [`OR1200_EXCEPT_WIDTH-1:0]       except_type;
333
wire    [4:0]                    cust5_op;
334
wire    [5:0]                    cust5_limm;
335
wire                            flushpipe;
336
wire                            extend_flush;
337
wire                            branch_taken;
338
wire                            flag;
339
wire                            flagforw;
340
wire                            flag_we;
341
wire                            carry;
342
wire                            cyforw;
343
wire                            cy_we;
344
wire                            lsu_stall;
345
wire                            epcr_we;
346
wire                            eear_we;
347
wire                            esr_we;
348
wire                            pc_we;
349
wire    [31:0]                   epcr;
350
wire    [31:0]                   eear;
351
wire    [`OR1200_SR_WIDTH-1:0]   esr;
352
wire                            sr_we;
353
wire    [`OR1200_SR_WIDTH-1:0]   to_sr;
354
wire    [`OR1200_SR_WIDTH-1:0]   sr;
355
wire                            except_start;
356
wire                            except_started;
357
wire    [31:0]                   wb_insn;
358
wire    [15:0]                   spr_addrimm;
359
wire                            sig_syscall;
360
wire                            sig_trap;
361
wire    [31:0]                   spr_dat_cfgr;
362
wire    [31:0]                   spr_dat_rf;
363
wire    [31:0]                  spr_dat_npc;
364
wire    [31:0]                   spr_dat_ppc;
365
wire    [31:0]                   spr_dat_mac;
366
wire                            force_dslot_fetch;
367
wire                            no_more_dslot;
368
wire                            ex_void;
369
wire                            if_stall;
370
wire                            id_macrc_op;
371
wire                            ex_macrc_op;
372
wire    [`OR1200_MACOP_WIDTH-1:0] mac_op;
373
wire    [31:0]                   mult_mac_result;
374
wire                            mac_stall;
375
wire    [12:0]                   except_stop;
376
wire                            genpc_refetch;
377
wire                            rfe;
378
wire                            lsu_unstall;
379
wire                            except_align;
380
wire                            except_dtlbmiss;
381
wire                            except_dmmufault;
382
wire                            except_illegal;
383
wire                            except_itlbmiss;
384
wire                            except_immufault;
385
wire                            except_ibuserr;
386
wire                            except_dbuserr;
387
wire                            abort_ex;
388
 
389
//
390
// Send exceptions to Debug Unit
391
//
392
assign du_except = except_stop;
393
 
394
//
395
// Data cache enable
396
//
397
 
398
// SynEDA CoreMultiplier
399
// assignment(s): dc_en
400
// replace(s): sr
401
assign dc_en = sr_cml_1[`OR1200_SR_DCE];
402
 
403
//
404
// Instruction cache enable
405
//
406
assign ic_en = sr[`OR1200_SR_ICE];
407
 
408
//
409
// DMMU enable
410
//
411
assign dmmu_en = sr[`OR1200_SR_DME];
412
 
413
//
414
// IMMU enable
415
//
416
assign immu_en = sr[`OR1200_SR_IME];
417
 
418
//
419
// SUPV bit
420
//
421
 
422
// SynEDA CoreMultiplier
423
// assignment(s): supv
424
// replace(s): sr
425
assign supv = sr_cml_1[`OR1200_SR_SM];
426
 
427
//
428
// Instantiation of instruction fetch block
429
//
430
wire except_prefix;
431
assign except_prefix = sr[`OR1200_SR_EPH];
432
 
433
or1200_genpc_cm3 or1200_genpc(
434
                .clk_i_cml_1(clk_i_cml_1),
435
                .clk_i_cml_2(clk_i_cml_2),
436
        .clk(clk),
437
        .rst(rst),
438
        .icpu_adr_o(icpu_adr_o),
439
        .icpu_cycstb_o(icpu_cycstb_o),
440
        .icpu_sel_o(icpu_sel_o),
441
        .icpu_tag_o(icpu_tag_o),
442
        .icpu_rty_i(icpu_rty_i),
443
        .icpu_adr_i(icpu_adr_i),
444
 
445
        .branch_op(branch_op),
446
        .except_type(except_type),
447
        .except_start(except_start),
448
        .except_prefix(except_prefix),
449
        .branch_addrofs(branch_addrofs),
450
        .lr_restor(operand_b),
451
        .flag(flag),
452
        .taken(branch_taken),
453
        .binsn_addr(lr_sav),
454
        .epcr(epcr),
455
        .spr_dat_i(spr_dat_cpu),
456
        .spr_pc_we(pc_we),
457
        .genpc_refetch(genpc_refetch),
458
        .genpc_freeze(genpc_freeze),
459
  .genpc_stop_prefetch(1'b0),
460
        .no_more_dslot(no_more_dslot)
461
);
462
 
463
//
464
// Instantiation of instruction fetch block
465
//
466
or1200_if_cm3 or1200_if(
467
                .clk_i_cml_1(clk_i_cml_1),
468
                .clk_i_cml_2(clk_i_cml_2),
469
        .clk(clk),
470
        .rst(rst),
471
        .icpu_dat_i(icpu_dat_i),
472
        .icpu_ack_i(icpu_ack_i),
473
        .icpu_err_i(icpu_err_i),
474
        .icpu_adr_i(icpu_adr_i),
475
        .icpu_tag_i(icpu_tag_i),
476
 
477
        .if_freeze(if_freeze),
478
        .if_insn(if_insn),
479
        .if_pc(if_pc),
480
        .flushpipe(flushpipe),
481
        .if_stall(if_stall),
482
        .no_more_dslot(no_more_dslot),
483
        .genpc_refetch(genpc_refetch),
484
        .rfe(rfe),
485
        .except_itlbmiss(except_itlbmiss),
486
        .except_immufault(except_immufault),
487
        .except_ibuserr(except_ibuserr)
488
);
489
 
490
//
491
// Instantiation of instruction decode/control logic
492
//
493
or1200_ctrl_cm3 or1200_ctrl(
494
                .clk_i_cml_1(clk_i_cml_1),
495
                .clk_i_cml_2(clk_i_cml_2),
496
        .clk(clk),
497
        .rst(rst),
498
        .id_freeze(id_freeze),
499
        .ex_freeze(ex_freeze),
500
        .wb_freeze(wb_freeze),
501
        .flushpipe(flushpipe),
502
        .if_insn(if_insn),
503
        .ex_insn(ex_insn),
504
        .branch_op(branch_op),
505
        .branch_taken(branch_taken),
506
        .rf_addra(rf_addra),
507
        .rf_addrb(rf_addrb),
508
        .rf_rda(rf_rda),
509
        .rf_rdb(rf_rdb),
510
        .alu_op(alu_op),
511
        .mac_op(mac_op),
512
        .shrot_op(shrot_op),
513
        .comp_op(comp_op),
514
        .rf_addrw(rf_addrw),
515
        .rfwb_op(rfwb_op),
516
        .wb_insn(wb_insn),
517
        .simm(simm),
518
        .branch_addrofs(branch_addrofs),
519
        .lsu_addrofs(lsu_addrofs),
520
        .sel_a(sel_a),
521
        .sel_b(sel_b),
522
        .lsu_op(lsu_op),
523
        .cust5_op(cust5_op),
524
        .cust5_limm(cust5_limm),
525
        .multicycle(multicycle),
526
        .spr_addrimm(spr_addrimm),
527
        .wbforw_valid(wbforw_valid),
528
        .sig_syscall(sig_syscall),
529
        .sig_trap(sig_trap),
530
        .force_dslot_fetch(force_dslot_fetch),
531
        .no_more_dslot(no_more_dslot),
532
        .ex_void(ex_void),
533
        .id_macrc_op(id_macrc_op),
534
        .ex_macrc_op(ex_macrc_op),
535
        .rfe(rfe),
536
        .du_hwbkpt(du_hwbkpt),
537
        .except_illegal(except_illegal)
538
);
539
 
540
//
541
// Instantiation of register file
542
//
543
wire supv_wire;
544
 
545
// SynEDA CoreMultiplier
546
// assignment(s): supv_wire
547
// replace(s): sr
548
assign supv_wire = sr_cml_2[`OR1200_SR_SM];
549
wire we;
550
 
551
// SynEDA CoreMultiplier
552
// assignment(s): we
553
// replace(s): rfwb_op
554
assign we = rfwb_op_cml_2[0];
555
wire spr_cs_group_sys;
556
 
557
// SynEDA CoreMultiplier
558
// assignment(s): spr_cs_group_sys
559
// replace(s): spr_cs
560
assign spr_cs_group_sys = spr_cs_cml_1[`OR1200_SPR_GROUP_SYS];
561
 
562
or1200_rf_cm3 or1200_rf(
563
                .clk_i_cml_1(clk_i_cml_1),
564
                .clk_i_cml_2(clk_i_cml_2),
565
                .cmls(cmls),
566
        .clk(clk),
567
        .rst(rst),
568
        .supv(supv_wire),
569
        .wb_freeze(wb_freeze),
570
        .addrw(rf_addrw),
571
        .dataw(rf_dataw),
572
        .id_freeze(id_freeze),
573
        .we(we),
574
        .flushpipe(flushpipe),
575
        .addra(rf_addra),
576
        .rda(rf_rda),
577
        .dataa(rf_dataa),
578
        .addrb(rf_addrb),
579
        .rdb(rf_rdb),
580
        .datab(rf_datab),
581
        .spr_cs(spr_cs_group_sys),
582
        .spr_write(spr_we),
583
        .spr_addr(spr_addr),
584
        .spr_dat_i(spr_dat_cpu),
585
        .spr_dat_o(spr_dat_rf)
586
);
587
 
588
//
589
// Instantiation of operand muxes
590
//
591
or1200_operandmuxes_cm3 or1200_operandmuxes(
592
                .clk_i_cml_1(clk_i_cml_1),
593
                .clk_i_cml_2(clk_i_cml_2),
594
        .clk(clk),
595
        .rst(rst),
596
        .id_freeze(id_freeze),
597
        .ex_freeze(ex_freeze),
598
        .rf_dataa(rf_dataa),
599
        .rf_datab(rf_datab),
600
        .ex_forw(rf_dataw),
601
        .wb_forw(wb_forw),
602
        .simm(simm),
603
        .sel_a(sel_a),
604
        .sel_b(sel_b),
605
        .operand_a(operand_a),
606
        .operand_b(operand_b),
607
        .muxed_b(muxed_b)
608
);
609
 
610
//
611
// Instantiation of CPU's ALU
612
//
613
or1200_alu_cm3 or1200_alu(
614
                .clk_i_cml_1(clk_i_cml_1),
615
                .clk_i_cml_2(clk_i_cml_2),
616
        .a(operand_a),
617
        .b(operand_b),
618
        .mult_mac_result(mult_mac_result),
619
        .macrc_op(ex_macrc_op),
620
        .alu_op(alu_op),
621
        .shrot_op(shrot_op),
622
        .comp_op(comp_op),
623
        .cust5_op(cust5_op),
624
        .cust5_limm(cust5_limm),
625
        .result(alu_dataout),
626
        .flagforw(flagforw),
627
        .flag_we(flag_we),
628
        .cyforw(cyforw),
629
        .cy_we(cy_we),
630
  .flag(flag),
631
        .carry(carry)
632
);
633
 
634
//
635
// Instantiation of CPU's ALU
636
//
637
wire spr_cs_group_mac;
638
 
639
// SynEDA CoreMultiplier
640
// assignment(s): spr_cs_group_mac
641
// replace(s): spr_cs
642
assign spr_cs_group_mac = spr_cs_cml_2[`OR1200_SPR_GROUP_MAC];
643
 
644
or1200_mult_mac_cm3 or1200_mult_mac(
645
                .clk_i_cml_1(clk_i_cml_1),
646
                .clk_i_cml_2(clk_i_cml_2),
647
        .clk(clk),
648
        .rst(rst),
649
        .ex_freeze(ex_freeze),
650
        .id_macrc_op(id_macrc_op),
651
        .macrc_op(ex_macrc_op),
652
        .a(operand_a),
653
        .b(operand_b),
654
        .mac_op(mac_op),
655
        .alu_op(alu_op),
656
        .result(mult_mac_result),
657
        .mac_stall_r(mac_stall),
658
        .spr_cs(spr_cs_group_mac),
659
        .spr_write(spr_we),
660
        .spr_addr(spr_addr),
661
        .spr_dat_i(spr_dat_cpu),
662
        .spr_dat_o(spr_dat_mac)
663
);
664
 
665
//
666
// Instantiation of CPU's SPRS block
667
//
668
or1200_sprs_cm3 or1200_sprs(
669
                .clk_i_cml_1(clk_i_cml_1),
670
                .clk_i_cml_2(clk_i_cml_2),
671
        .clk(clk),
672
        .rst(rst),
673
        .addrbase(operand_a),
674
        .addrofs(spr_addrimm),
675
        .dat_i(operand_b),
676
        .alu_op(alu_op),
677
        .flagforw(flagforw),
678
        .flag_we(flag_we),
679
        .flag(flag),
680
        .cyforw(cyforw),
681
        .cy_we(cy_we),
682
        .carry(carry),
683
        .to_wbmux(sprs_dataout),
684
 
685
        .du_addr(du_addr),
686
        .du_dat_du(du_dat_du),
687
        .du_read(du_read),
688
        .du_write(du_write),
689
        .du_dat_cpu(du_dat_cpu),
690
 
691
        .spr_addr(spr_addr),
692
        .spr_dat_pic(spr_dat_pic),
693
        .spr_dat_tt(spr_dat_tt),
694
        .spr_dat_pm(spr_dat_pm),
695
        .spr_dat_cfgr(spr_dat_cfgr),
696
        .spr_dat_rf(spr_dat_rf),
697
        .spr_dat_npc(spr_dat_npc),
698
        .spr_dat_ppc(spr_dat_ppc),
699
        .spr_dat_mac(spr_dat_mac),
700
        .spr_dat_dmmu(spr_dat_dmmu),
701
        .spr_dat_immu(spr_dat_immu),
702
        .spr_dat_du(spr_dat_du),
703
        .spr_dat_o(spr_dat_cpu),
704
        .spr_cs(spr_cs),
705
        .spr_we(spr_we),
706
 
707
        .epcr_we(epcr_we),
708
        .eear_we(eear_we),
709
        .esr_we(esr_we),
710
        .pc_we(pc_we),
711
        .epcr(epcr),
712
        .eear(eear),
713
        .esr(esr),
714
        .except_started(except_started),
715
 
716
        .sr_we(sr_we),
717
        .to_sr(to_sr),
718
        .sr(sr),
719
        .branch_op(branch_op)
720
);
721
 
722
//
723
// Instantiation of load/store unit
724
//
725
or1200_lsu_cm3 or1200_lsu(
726
                .clk_i_cml_1(clk_i_cml_1),
727
                .clk_i_cml_2(clk_i_cml_2),
728
        .addrbase(operand_a),
729
        .addrofs(lsu_addrofs),
730
        .lsu_op(lsu_op),
731
        .lsu_datain(operand_b),
732
        .lsu_dataout(lsu_dataout),
733
        .lsu_stall(lsu_stall),
734
        .lsu_unstall(lsu_unstall),
735
        .du_stall(du_stall),
736
        .except_align(except_align),
737
        .except_dtlbmiss(except_dtlbmiss),
738
        .except_dmmufault(except_dmmufault),
739
        .except_dbuserr(except_dbuserr),
740
 
741
        .dcpu_adr_o(dcpu_adr_o),
742
        .dcpu_cycstb_o(dcpu_cycstb_o),
743
        .dcpu_we_o(dcpu_we_o),
744
        .dcpu_sel_o(dcpu_sel_o),
745
        .dcpu_tag_o(dcpu_tag_o),
746
        .dcpu_dat_o(dcpu_dat_o),
747
        .dcpu_dat_i(dcpu_dat_i),
748
        .dcpu_ack_i(dcpu_ack_i),
749
        .dcpu_rty_i(dcpu_rty_i),
750
        .dcpu_err_i(dcpu_err_i),
751
        .dcpu_tag_i(dcpu_tag_i)
752
);
753
 
754
//
755
// Instantiation of write-back muxes
756
//
757
wire [31:0] muxin_d;
758
assign muxin_d = {lr_sav, 2'b0};
759
 
760
or1200_wbmux_cm3 or1200_wbmux(
761
                .clk_i_cml_1(clk_i_cml_1),
762
                .clk_i_cml_2(clk_i_cml_2),
763
        .clk(clk),
764
        .rst(rst),
765
        .wb_freeze(wb_freeze),
766
        .rfwb_op(rfwb_op),
767
        .muxin_a(alu_dataout),
768
        .muxin_b(lsu_dataout),
769
        .muxin_c(sprs_dataout),
770
        .muxin_d(muxin_d),
771
        .muxout(rf_dataw),
772
        .muxreg(wb_forw),
773
        .muxreg_valid(wbforw_valid)
774
);
775
 
776
//
777
// Instantiation of freeze logic
778
//
779
or1200_freeze_cm3 or1200_freeze(
780
                .clk_i_cml_1(clk_i_cml_1),
781
                .clk_i_cml_2(clk_i_cml_2),
782
        .clk(clk),
783
        .rst(rst),
784
        .multicycle(multicycle),
785
        .flushpipe(flushpipe),
786
        .extend_flush(extend_flush),
787
        .lsu_stall(lsu_stall),
788
        .if_stall(if_stall),
789
        .lsu_unstall(lsu_unstall),
790
        .force_dslot_fetch(force_dslot_fetch),
791
        .abort_ex(abort_ex),
792
        .du_stall(du_stall),
793
        .mac_stall(mac_stall),
794
        .genpc_freeze(genpc_freeze),
795
        .if_freeze(if_freeze),
796
        .id_freeze(id_freeze),
797
        .ex_freeze(ex_freeze),
798
        .wb_freeze(wb_freeze),
799
        .icpu_ack_i(icpu_ack_i),
800
        .icpu_err_i(icpu_err_i)
801
);
802
 
803
//
804
// Instantiation of exception block
805
//
806
or1200_except_cm3 or1200_except(
807
                .clk_i_cml_1(clk_i_cml_1),
808
                .clk_i_cml_2(clk_i_cml_2),
809
        .clk(clk),
810
        .rst(rst),
811
        .sig_ibuserr(except_ibuserr),
812
        .sig_dbuserr(except_dbuserr),
813
        .sig_illegal(except_illegal),
814
        .sig_align(except_align),
815
        .sig_range(1'b0),
816
        .sig_dtlbmiss(except_dtlbmiss),
817
        .sig_dmmufault(except_dmmufault),
818
        .sig_int(sig_int),
819
        .sig_syscall(sig_syscall),
820
        .sig_trap(sig_trap),
821
        .sig_itlbmiss(except_itlbmiss),
822
        .sig_immufault(except_immufault),
823
        .sig_tick(sig_tick),
824
        .branch_taken(branch_taken),
825
        .icpu_ack_i(icpu_ack_i),
826
        .icpu_err_i(icpu_err_i),
827
        .dcpu_ack_i(dcpu_ack_i),
828
        .dcpu_err_i(dcpu_err_i),
829
        .genpc_freeze(genpc_freeze),
830
        .id_freeze(id_freeze),
831
        .ex_freeze(ex_freeze),
832
        .wb_freeze(wb_freeze),
833
        .if_stall(if_stall),
834
        .if_pc(if_pc),
835
        .id_pc(id_pc),
836
        .lr_sav(lr_sav),
837
        .flushpipe(flushpipe),
838
        .extend_flush(extend_flush),
839
        .except_type(except_type),
840
        .except_start(except_start),
841
        .except_started(except_started),
842
        .except_stop(except_stop),
843
        .ex_void(ex_void),
844
        .spr_dat_ppc(spr_dat_ppc),
845
        .spr_dat_npc(spr_dat_npc),
846
 
847
        .datain(operand_b),
848
        .du_dsr(du_dsr),
849
        .epcr_we(epcr_we),
850
        .eear_we(eear_we),
851
        .esr_we(esr_we),
852
        .pc_we(pc_we),
853
        .epcr(epcr),
854
        .eear(eear),
855
        .esr(esr),
856
 
857
        .lsu_addr(dcpu_adr_o),
858
        .sr_we(sr_we),
859
        .to_sr(to_sr),
860
        .sr(sr),
861
        .abort_ex(abort_ex)
862
);
863
 
864
//
865
// Instantiation of configuration registers
866
//
867
or1200_cfgr_cm3 or1200_cfgr(
868
                .clk_i_cml_1(clk_i_cml_1),
869
        .spr_addr(spr_addr),
870
        .spr_dat_o(spr_dat_cfgr)
871
);
872
 
873
 
874
always @ (posedge clk_i_cml_1) begin
875
spr_cs_cml_1 <= spr_cs;
876
rfwb_op_cml_1 <= rfwb_op;
877
sr_cml_1 <= sr;
878
end
879
always @ (posedge clk_i_cml_2) begin
880
spr_cs_cml_2 <= spr_cs_cml_1;
881
rfwb_op_cml_2 <= rfwb_op_cml_1;
882
sr_cml_2 <= sr_cml_1;
883
end
884
endmodule
885
 

powered by: WebSVN 2.1.0

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