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

Subversion Repositories mips789

[/] [mips789/] [branches/] [avendor/] [rtl/] [verilog/] [decode_pipe.v] - Blame information for rev 60

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

Line No. Rev Author Line
1 35 mcupro
/******************************************************************
2
 *                                                                *
3
 *    Author: Liwei                                               *
4
 *                                                                *
5
 *    This file is part of the "mips789" project.                 *
6
 *    Downloaded from:                                            *
7
 *    http://www.opencores.org/pdownloads.cgi/list/mips789        *
8
 *                                                                *
9
 *    If you encountered any problem, please contact me via       *
10
 *    Email:mcupro@opencores.org  or mcupro@163.com               *
11
 *                                                                *
12
 ******************************************************************/
13
 
14
`include "mips789_defs.v"
15 10 mcupro
module decoder(
16
        input [31:0]ins_i,
17
        output reg [`EXT_CTL_LEN-1:0] ext_ctl,
18
        output reg [`RD_SEL_LEN-1:0] rd_sel,
19
        output reg [`CMP_CTL_LEN-1:0]cmp_ctl,
20
        output reg [`PC_GEN_CTL_LEN-1:0]pc_gen_ctl,
21
        output reg [`FSM_CTL_LEN-1:0]fsm_dly,
22
        output reg [`MUXA_CTL_LEN-1:0]muxa_ctl,
23
        output reg [`MUXB_CTL_LEN-1:0]muxb_ctl,
24
        output reg [`ALU_FUNC_LEN-1:0]alu_func,
25
        output reg [`DMEM_CTL_LEN-1:0]dmem_ctl,
26
        output reg [`ALU_WE_LEN-1:0] alu_we,
27
        output reg [`WB_MUX_CTL_LEN-1:0]wb_mux,
28
        output reg [`WB_WE_LEN-1:0]wb_we
29
    );
30
 
31
    wire [5:0]  inst_op,inst_func;
32
    wire [4:0]  inst_regimm;//,inst_rs,inst_rt,inst_rd,inst_sa;
33
    wire [4:0]  inst_cop0_func;//cop0's function code filed
34
    wire [25:0] inst_cop0_code;//cop0's code field
35
 
36
    assign inst_op        = ins_i[31:26];
37
    assign inst_func      = ins_i[5:0];
38
    assign inst_regimm    = ins_i[20:16];
39
    assign inst_cop0_func = ins_i[25:21];
40
    assign inst_cop0_code = ins_i[25:0];
41
 
42
    always @(*)
43
    begin
44
        case (inst_op)//synthesis parallel_case
45
            'd0://special operation
46
            begin
47
                case (inst_func) //synthesis parallel_case
48
                    'd0://SLL rd,rt,sa
49
                    begin
50
                        //replaceID  = `SLL ;
51
                        ext_ctl = `EXT_SA;
52
                        rd_sel = `RD_RD;
53
                        cmp_ctl = `CMP_NOP;
54
                        pc_gen_ctl = `PC_NEXT;
55
                        fsm_dly = `FSM_NOP;
56
                        muxa_ctl = `MUXA_EXT;
57
                        muxb_ctl = `MUXB_RT;
58
                        alu_func = `ALU_SLL;
59
                        alu_we = `EN;
60
                        dmem_ctl = `DMEM_NOP;
61
                        wb_we =  `DIS;
62
                        wb_mux = `WB_ALU;
63
                        //end of `SLL ;
64
                    end
65
                    'd2://SRL rd,rt,sa
66
                    begin
67
                        //replaceID  = `SRL ;
68
                        ext_ctl = `EXT_SA;
69
                        rd_sel = `RD_RD;
70
                        cmp_ctl = `CMP_NOP;
71
                        pc_gen_ctl = `PC_NEXT;
72
                        fsm_dly = `FSM_NOP;
73
                        muxa_ctl = `MUXA_EXT;
74
                        muxb_ctl = `MUXB_RT;
75
                        alu_func = `ALU_SRL;
76
                        alu_we = `EN;
77
                        dmem_ctl = `DMEM_NOP;
78
                        wb_we =  `DIS;
79
                        wb_mux = `WB_ALU;
80
                        //end of `SRL ;
81
                    end
82
                    'd3://SRA rd,rt,sa
83
                    begin
84
                        //replaceID  = `SRA ;
85
                        ext_ctl = `EXT_SA;
86
                        rd_sel = `RD_RD;
87
                        cmp_ctl = `CMP_NOP;
88
                        pc_gen_ctl = `PC_NEXT;
89
                        fsm_dly = `FSM_NOP;
90
                        muxa_ctl = `MUXA_EXT;
91
                        muxb_ctl = `MUXB_RT;
92
                        alu_func = `ALU_SRA;
93
                        alu_we = `EN;
94
                        dmem_ctl = `DMEM_NOP;
95
                        wb_we =  `DIS;
96
                        wb_mux = `WB_ALU;
97
                        //end of `SRA ;
98
                    end
99
                    'd4://SLLV rd,rt,rs
100
                    begin
101
                        //replaceID  = `SLLV ;
102
                        ext_ctl = `IGN;
103
                        rd_sel = `IGN;
104
                        cmp_ctl = `IGN;
105
                        pc_gen_ctl = `IGN;
106
                        fsm_dly = `IGN;
107
                        muxa_ctl = `IGN;
108
                        muxb_ctl = `IGN;
109
                        alu_func = `IGN;
110
                        alu_we = `IGN;
111
                        dmem_ctl = `IGN;
112
                        wb_we =  `IGN;
113 35 mcupro
                        wb_mux = 1'bx;//`IGN;
114 10 mcupro
                        //end of `SLLV ;
115
                    end
116
                    'd6://SRLV rd,rt,rs
117
                    begin
118
                        //replaceID  = `SRLV ;
119
                        ext_ctl = `IGN;
120
                        rd_sel = `IGN;
121
                        cmp_ctl = `IGN;
122
                        pc_gen_ctl = `IGN;
123
                        fsm_dly = `IGN;
124
                        muxa_ctl = `IGN;
125
                        muxb_ctl = `IGN;
126
                        alu_func = `IGN;
127
                        alu_we = `IGN;
128
                        dmem_ctl = `IGN;
129
                        wb_we =  `IGN;
130
                        wb_mux = `IGN;
131
                        //end of `SRLV ;
132
                    end
133
                    'd7://SRAV rd,rt,rs
134
                    begin
135
                        //replaceID  = `SRAV ;
136
                        ext_ctl = `IGN;
137
                        rd_sel = `IGN;
138
                        cmp_ctl = `IGN;
139
                        pc_gen_ctl = `IGN;
140
                        fsm_dly = `IGN;
141
                        muxa_ctl = `IGN;
142
                        muxb_ctl = `IGN;
143
                        alu_func = `IGN;
144
                        alu_we = `IGN;
145
                        dmem_ctl = `IGN;
146
                        wb_we =  `IGN;
147
                        wb_mux = `IGN;
148
                        //end of `SRAV ;
149
                    end
150
                    'd8://JR rs
151
                    begin
152
                        //replaceID  = `JR ;
153
                        ext_ctl = `EXT_NOP;
154
                        rd_sel = `RD_NOP;
155
                        cmp_ctl = `CMP_NOP;
156
                        pc_gen_ctl = `PC_JR;
157
                        fsm_dly = `FSM_CUR;
158
                        muxa_ctl = `MUXA_NOP;
159
                        muxb_ctl = `MUXB_NOP;
160
                        alu_func = `ALU_NOP;
161
                        alu_we = `DIS;
162
                        dmem_ctl = `DMEM_NOP;
163
                        wb_we =  `DIS;
164
                        wb_mux = `WB_NOP;
165
                        //end of `JR ;
166
                    end
167
                    'd9://JALR jalr rs(rd=31) or jalr rd,rs
168
                    begin
169
                        //replaceID  = `JALR ;
170
                        ext_ctl = `IGN;
171
                        rd_sel = `IGN;
172
                        cmp_ctl = `IGN;
173
                        pc_gen_ctl = `IGN;
174
                        fsm_dly = `IGN;
175
                        muxa_ctl = `IGN;
176
                        muxb_ctl = `IGN;
177
                        alu_func = `IGN;
178
                        alu_we = `IGN;
179
                        dmem_ctl = `IGN;
180
                        wb_we =  `IGN;
181
                        wb_mux = `IGN;
182
                        //end of `JALR ;
183
                    end
184
                    'd12://SYSCALL
185
                    begin
186
                        //replaceID  = `SYSCALL ;
187
                        ext_ctl = `IGN;
188
                        rd_sel = `IGN;
189
                        cmp_ctl = `IGN;
190
                        pc_gen_ctl = `IGN;
191
                        fsm_dly = `IGN;
192
                        muxa_ctl = `IGN;
193
                        muxb_ctl = `IGN;
194
                        alu_func = `IGN;
195
                        alu_we = `IGN;
196
                        dmem_ctl = `IGN;
197
                        wb_we =  `IGN;
198
                        wb_mux = `IGN;
199
                        //end of `SYSCALL ;
200
                    end
201
                    'd13://BREAK
202
                    begin
203
                        //replaceID  = `BREAK ;
204
                        ext_ctl = `IGN;
205
                        rd_sel = `IGN;
206
                        cmp_ctl = `IGN;
207
                        pc_gen_ctl = `IGN;
208
                        fsm_dly = `IGN;
209
                        muxa_ctl = `IGN;
210
                        muxb_ctl = `IGN;
211
                        alu_func = `IGN;
212
                        alu_we = `IGN;
213
                        dmem_ctl = `IGN;
214
                        wb_we =  `IGN;
215
                        wb_mux = `IGN;
216
                        //end of `BREAK ;
217
                    end
218
                    'd16://MFHI rd
219
                    begin
220
                        //replaceID  = `MFHI ;
221
                        ext_ctl = `EXT_NOP;
222
                        rd_sel = `RD_RD;
223
                        cmp_ctl = `CMP_NOP;
224
                        pc_gen_ctl = `PC_NEXT;
225
                        fsm_dly = `FSM_NOP;
226
                        muxa_ctl = `MUXA_NOP;
227
                        muxb_ctl = `MUXB_NOP;
228
                        alu_func = `ALU_MFHI;
229
                        alu_we = `EN;
230
                        dmem_ctl = `DMEM_NOP;
231
                        wb_we =  `DIS;
232
                        wb_mux = `WB_ALU;
233
                        //end of `MFHI ;
234
                    end
235
                    'd17://MTHI rs
236
                    begin
237
                        //replaceID  = `MTHI ;
238
                        ext_ctl = `EXT_NOP      ;
239
                        rd_sel = `RD_NOP;
240
                        cmp_ctl = `CMP_NOP;
241
                        pc_gen_ctl = `PC_NEXT;
242
                        fsm_dly = `FSM_NOP;
243
                        muxa_ctl = `MUXA_RS;
244
                        muxb_ctl = `MUXB_NOP;
245
                        alu_func = `ALU_MTHI;
246
                        alu_we = `DIS;
247
                        dmem_ctl = `DMEM_NOP;
248
                        wb_we =  `DIS;
249
                        wb_mux = `WB_NOP;
250
                        //end of `MTHI ;
251
                    end
252
                    'd18://MFLO rd
253
                    begin
254
                        //replaceID  = `MFLO ;
255
                        ext_ctl = `EXT_NOP      ;
256
                        rd_sel = `RD_RD;
257
                        cmp_ctl = `CMP_NOP;
258
                        pc_gen_ctl = `PC_NEXT;
259
                        fsm_dly = `FSM_NOP;
260
                        muxa_ctl = `MUXA_NOP;
261
                        muxb_ctl = `MUXB_NOP;
262
                        alu_func = `ALU_MFLO;
263
                        alu_we = `EN;
264
                        dmem_ctl = `DMEM_NOP;
265
                        wb_we =  `DIS;
266
                        wb_mux = `WB_ALU;
267
                        //end of `MFLO ;
268
                    end
269
                    'd19://MTLO rs
270
                    begin
271
                        //replaceID  = `MTLO ;
272
                        ext_ctl = `EXT_NOP      ;
273
                        rd_sel = `RD_NOP;
274
                        cmp_ctl = `CMP_NOP;
275
                        pc_gen_ctl = `PC_NEXT;
276
                        fsm_dly = `FSM_NOP;
277
                        muxa_ctl = `MUXA_NOP;
278
                        muxb_ctl = `MUXB_NOP;
279
                        alu_func = `ALU_MFLO;
280
                        alu_we = `DIS;
281
                        dmem_ctl = `DMEM_NOP;
282
                        wb_we =  `DIS;
283
                        wb_mux = `WB_NOP;
284
 
285
                        //end of `MTLO ;
286
                    end
287
                    'd24://MULT rs,rt
288
                    begin
289
                        //replaceID  = `MULT ;
290
                        ext_ctl = `EXT_NOP;
291
                        rd_sel = `RD_NOP;
292
                        cmp_ctl = `CMP_NOP;
293
                        pc_gen_ctl = `PC_NEXT;
294
                        fsm_dly = `FSM_MUL;
295
                        muxa_ctl = `MUXA_RS;
296
                        muxb_ctl = `MUXB_RT;
297
                        alu_func = `ALU_MULT;
298
                        alu_we = `DIS;
299
                        dmem_ctl = `DMEM_NOP;
300
                        wb_we =  `DIS;
301
                        wb_mux = `WB_NOP;
302
                        //end of `MULT ;
303
                    end
304
                    'd25://MULTU rs,rt
305
                    begin
306
                        //replaceID  = `MULTU ;
307
                        ext_ctl = `EXT_NOP;
308
                        rd_sel = `RD_NOP;
309
                        cmp_ctl = `CMP_NOP;
310
                        pc_gen_ctl = `PC_NEXT;
311
                        fsm_dly = `FSM_MUL;
312
                        muxa_ctl = `MUXA_RS;
313
                        muxb_ctl = `MUXB_RT;
314
                        alu_func = `ALU_MULTU;
315
                        alu_we = `DIS;
316
                        dmem_ctl = `DMEM_NOP;
317
                        wb_we =  `DIS;
318
                        wb_mux = `WB_NOP;
319
                        //end of `MULTU ;
320
                    end
321
                    'd26://DIV rs,rt
322
                    begin
323
                        //replaceID  = `DIV ;
324
                        ext_ctl = `EXT_NOP;
325
                        rd_sel = `RD_NOP;
326
                        cmp_ctl = `CMP_NOP;
327
                        pc_gen_ctl = `PC_NEXT;
328
                        fsm_dly = `FSM_MUL;
329
                        muxa_ctl = `MUXA_RS;
330
                        muxb_ctl = `MUXB_RT;
331
                        alu_func = `ALU_DIV;
332
                        alu_we = `DIS;
333
                        dmem_ctl = `DMEM_NOP;
334
                        wb_we =  `DIS;
335
                        wb_mux = `WB_NOP;
336
                        //end of `DIV ;
337
                    end
338
                    'd27://DIVU rs,rt
339
                    begin
340
                        //replaceID  = `DIVU ;
341
                        ext_ctl = `EXT_NOP;
342
                        rd_sel = `RD_NOP;
343
                        cmp_ctl = `CMP_NOP;
344
                        pc_gen_ctl = `PC_NEXT;
345
                        fsm_dly = `FSM_MUL;
346
                        muxa_ctl = `MUXA_RS;
347
                        muxb_ctl = `MUXB_RT;
348
                        alu_func = `ALU_DIVU;
349
                        alu_we = `DIS;
350
                        dmem_ctl = `DMEM_NOP;
351
                        wb_we =  `DIS;
352
                        wb_mux = `WB_NOP;
353
                        //end of `DIVU ;
354
                    end
355
                    'd32://ADD rd,rs,rt
356
                    begin
357
                        //replaceID  = `ADD ;
358
                        ext_ctl = `EXT_NOP;
359
                        rd_sel = `RD_RD;
360
                        cmp_ctl = `CMP_NOP;
361
                        pc_gen_ctl = `PC_NEXT;
362
                        fsm_dly = `FSM_NOP;
363
                        muxa_ctl = `MUXA_RS;
364
                        muxb_ctl = `MUXB_RT;
365
                        alu_func = `ALU_ADD;
366
                        alu_we = `EN;
367
                        dmem_ctl = `DMEM_NOP;
368
                        wb_we =  `DIS;
369
                        wb_mux = `WB_ALU;
370
                        //end of `ADD ;
371
                    end
372
                    'd33://ADDU rd,rs,rt
373
                    begin
374
                        //replaceID  = `ADDU ;
375
                        ext_ctl = `EXT_NOP;
376
                        rd_sel = `RD_RD;
377
                        cmp_ctl = `CMP_NOP;
378
                        pc_gen_ctl = `PC_NEXT;
379
                        fsm_dly = `FSM_NOP;
380
                        muxa_ctl = `MUXA_RS;
381
                        muxb_ctl = `MUXB_RT;
382
                        alu_func = `ALU_ADD;
383
                        alu_we = `EN;
384
                        dmem_ctl = `DMEM_NOP;
385
                        wb_we =  `DIS;
386
                        wb_mux = `WB_ALU;
387
                        //end of `ADDU ;
388
                    end
389
                    'd34://SUB rd,rs,rt
390
                    begin
391
                        //replaceID  = `SUB ;
392
                        ext_ctl = `EXT_NOP;
393
                        rd_sel = `RD_RD;
394
                        cmp_ctl = `CMP_NOP;
395
                        pc_gen_ctl = `PC_NEXT;
396
                        fsm_dly = `FSM_NOP;
397
                        muxa_ctl = `MUXA_RS;
398
                        muxb_ctl = `MUXB_RT;
399
                        alu_func = `ALU_SUB;
400
                        alu_we = `EN;
401
                        dmem_ctl = `DMEM_NOP;
402
                        wb_we =  `DIS;
403
                        wb_mux = `WB_ALU;
404
                        //end of `SUB ;
405
                    end
406
                    'd35://SUBU rd,rs,rt
407
                    begin
408
                        //replaceID  = `SUBU ;
409
                        ext_ctl = `EXT_NOP;
410
                        rd_sel = `RD_RD;
411
                        cmp_ctl = `CMP_NOP;
412
                        pc_gen_ctl = `PC_NEXT;
413
                        fsm_dly = `FSM_NOP;
414
                        muxa_ctl = `MUXA_RS;
415
                        muxb_ctl = `MUXB_RT;
416
                        alu_func = `ALU_SUBU;
417
                        alu_we = `EN;
418
                        dmem_ctl = `DMEM_NOP;
419
                        wb_we =  `DIS;
420
                        wb_mux = `WB_ALU;
421
                        //end of `SUBU ;
422
                    end
423
                    'd36://AND rd,rs,rt
424
                    begin
425
                        //replaceID  = `AND ;
426
                        ext_ctl = `EXT_NOP;
427
                        rd_sel = `RD_RD;
428
                        cmp_ctl = `CMP_NOP;
429
                        pc_gen_ctl = `PC_NEXT;
430
                        fsm_dly = `FSM_NOP;
431
                        muxa_ctl = `MUXA_RS;
432
                        muxb_ctl = `MUXB_RT;
433
                        alu_func = `ALU_AND;
434
                        alu_we = `EN;
435
                        dmem_ctl = `DMEM_NOP;
436
                        wb_we =  `DIS;
437
                        wb_mux = `WB_ALU;
438
                        //end of `AND ;
439
                    end
440
                    'd37://OR rd,rs,rt
441
                    begin
442
                        //replaceID  = `OR ;
443
                        ext_ctl = `EXT_NOP;
444
                        rd_sel = `RD_RD;
445
                        cmp_ctl = `CMP_NOP;
446
                        pc_gen_ctl = `PC_NEXT;
447
                        fsm_dly = `FSM_NOP;
448
                        muxa_ctl = `MUXA_RS;
449
                        muxb_ctl = `MUXB_RT;
450
                        alu_func = `ALU_OR;
451
                        alu_we = `EN;
452
                        dmem_ctl = `DMEM_NOP;
453
                        wb_we =  `DIS;
454
                        wb_mux = `WB_ALU;
455
                        //end of `OR ;
456
                    end
457
                    'd38://XOR rd,rs,rt
458
                    begin
459
                        //replaceID  = `XOR ;
460
                        ext_ctl = `EXT_NOP;
461
                        rd_sel = `RD_RD;
462
                        cmp_ctl = `CMP_NOP;
463
                        pc_gen_ctl = `PC_NEXT;
464
                        fsm_dly = `FSM_NOP;
465
                        muxa_ctl = `MUXA_RS;
466
                        muxb_ctl = `MUXB_RT;
467
                        alu_func = `ALU_XOR;
468
                        alu_we = `EN;
469
                        dmem_ctl = `DMEM_NOP;
470
                        wb_we =  `DIS;
471
                        wb_mux = `WB_ALU;
472
                        //end of `XOR ;
473
                    end
474
                    'd39://NOR rd,rs,rt
475
                    begin
476
                        //replaceID  = `NOR ;
477
                        ext_ctl = `EXT_NOP;
478
                        rd_sel = `RD_RD;
479
                        cmp_ctl = `CMP_NOP;
480
                        pc_gen_ctl = `PC_NEXT;
481
                        fsm_dly = `FSM_NOP;
482
                        muxa_ctl = `MUXA_RS;
483
                        muxb_ctl = `MUXB_RT;
484
                        alu_func = `ALU_NOR;
485
                        alu_we = `EN;
486
                        dmem_ctl = `DMEM_NOP;
487
                        wb_we =  `DIS;
488
                        wb_mux = `WB_ALU;
489
                        //end of `NOR ;
490
                    end
491
                    'd42://SLT rd,rs,rt
492
                    begin
493
                        //replaceID  = `SLT ;
494
                        ext_ctl = `EXT_SIGN;
495
                        rd_sel = `RD_RD;
496
                        cmp_ctl = `CMP_NOP;
497
                        pc_gen_ctl = `PC_NEXT;
498
                        fsm_dly = `FSM_NOP;
499
                        muxa_ctl = `MUXA_RS;
500
                        muxb_ctl = `MUXB_RT;
501
                        alu_func = `ALU_SLT;
502
                        alu_we = `EN;
503
                        dmem_ctl = `DMEM_NOP;
504
                        wb_we =  `DIS;
505
                        wb_mux = `WB_ALU;
506
                        //end of `SLT ;
507
                    end
508
                    'd43://SLTU rd,rs,rt
509
                    begin
510
                        //replaceID  = `SLTU ;
511
                        ext_ctl = `EXT_NOP;
512
                        rd_sel = `RD_RD;
513
                        cmp_ctl = `CMP_NOP;
514
                        pc_gen_ctl = `PC_NEXT;
515
                        fsm_dly = `FSM_NOP;
516
                        muxa_ctl = `MUXA_RS;
517
                        muxb_ctl = `MUXB_RT;
518
                        alu_func = `ALU_SLTU;
519
                        alu_we = `EN;
520
                        dmem_ctl = `DMEM_NOP;
521
                        wb_we =  `DIS;
522
                        wb_mux = `WB_ALU;
523
                        //end of `SLTU ;
524
                    end
525
                    default:
526
                    begin
527
                        //replaceID  = `INVALID ;
528
                        ext_ctl = `IGN;
529
                        rd_sel = `IGN;
530
                        cmp_ctl = `IGN;
531
                        pc_gen_ctl = `IGN;
532
                        fsm_dly = `IGN;
533
                        muxa_ctl = `IGN;
534
                        muxb_ctl = `IGN;
535
                        alu_func = `IGN;
536
                        alu_we = `IGN;
537
                        dmem_ctl = `IGN;
538
                        wb_we =  `IGN;
539
                        wb_mux = `IGN;
540
                        //end of `INVALID ;
541
                    end
542
                endcase
543
            end
544
            'd1://regimm opreation
545
            begin
546
                case (inst_regimm) //synthesis parallel_case
547
                    'd0://BLTZ rs,offset(signed)
548
                    begin
549
                        //replaceID  = `BLTZ ;
550
                        ext_ctl = `EXT_B;
551
                        rd_sel = `RD_NOP;
552
                        cmp_ctl = `CMP_BLTZ;
553
                        pc_gen_ctl = `PC_BC;
554
                        fsm_dly = `FSM_CUR;
555
                        muxa_ctl = `MUXA_NOP;
556
                        muxb_ctl = `MUXB_NOP;
557
                        alu_func = `ALU_NOP;
558
                        alu_we = `DIS;
559
                        dmem_ctl = `DMEM_NOP;
560
                        wb_we =  `DIS;
561
                        wb_mux = `WB_NOP;
562
                        //end of `BLTZ ;
563
                    end
564
                    'd1://BGEZ rs,offset(signed)
565
                    begin
566
                        //replaceID  = `BGEZ ;
567
                        ext_ctl = `EXT_B;
568
                        rd_sel = `RD_NOP;
569
                        cmp_ctl = `CMP_BGEZ;
570
                        pc_gen_ctl = `PC_BC;
571
                        fsm_dly = `FSM_CUR;
572
                        muxa_ctl = `MUXA_NOP;
573
                        muxb_ctl = `MUXB_NOP;
574
                        alu_func = `ALU_NOP;
575
                        alu_we = `DIS;
576
                        dmem_ctl = `DMEM_NOP;
577
                        wb_we =  `DIS;
578
                        wb_mux = `WB_NOP;
579
                        //end of `BGEZ ;
580
                    end
581
                    'd16://BLTZAL rs,offset(signed)
582
                    begin
583
                        //replaceID  = `BLTZAL ;
584
                        ext_ctl = `IGN;
585
                        rd_sel = `IGN;
586
                        cmp_ctl = `IGN;
587
                        pc_gen_ctl = `IGN;
588
                        fsm_dly = `IGN;
589
                        muxa_ctl = `IGN;
590
                        muxb_ctl = `IGN;
591
                        alu_func = `IGN;
592
                        alu_we = `IGN;
593
                        dmem_ctl = `IGN;
594
                        wb_we =  `IGN;
595
                        wb_mux = `IGN;
596
                        //end of `BLTZAL ;
597
                    end
598
                    'd17://BGEZAL rs,offset(signed)
599
                    begin
600
                        //replaceID  = `BGEZAL ;
601 35 mcupro
                        //replaceID  = `INVALID ;
602
                        ext_ctl = `IGN;
603
                        rd_sel = `IGN;
604
                        cmp_ctl = `IGN;
605
                        pc_gen_ctl = `IGN;
606
                        fsm_dly = `IGN;
607
                        muxa_ctl = `IGN;
608
                        muxb_ctl = `IGN;
609
                        alu_func = `IGN;
610
                        alu_we = `IGN;
611
                        dmem_ctl = `IGN;
612
                        wb_we =  `IGN;
613
                        wb_mux = `IGN;
614
                        //end of `INVALID ;
615 10 mcupro
                    end
616
                    default:
617
                    begin
618
                        //replaceID   = `INVALID ;
619 35 mcupro
                        //replaceID  = `INVALID ;
620
                        ext_ctl = `IGN;
621
                        rd_sel = `IGN;
622
                        cmp_ctl = `IGN;
623
                        pc_gen_ctl = `IGN;
624
                        fsm_dly = `IGN;
625
                        muxa_ctl = `IGN;
626
                        muxb_ctl = `IGN;
627
                        alu_func = `IGN;
628
                        alu_we = `IGN;
629
                        dmem_ctl = `IGN;
630
                        wb_we =  `IGN;
631
                        wb_mux = `IGN;
632
                        //end of `INVALID ;
633 10 mcupro
                    end
634
                endcase
635
            end
636
            'd2://J imm26({pc[31:28],imm26,00})
637
            begin
638
                //replaceID  = `J ;
639
                ext_ctl = `EXT_J;
640
                rd_sel = `RD_NOP;
641
                cmp_ctl = `CMP_NOP;
642
                pc_gen_ctl = `PC_J;
643
                fsm_dly = `FSM_NOI;
644
                muxa_ctl = `MUXA_NOP;
645
                muxb_ctl = `MUXB_NOP;
646
                alu_func = `ALU_NOP;
647
                alu_we = `DIS;
648
                dmem_ctl = `DMEM_NOP;
649
                wb_we =  `DIS;
650
                wb_mux = `WB_NOP;
651
                //end of `J ;
652
            end
653
            'd3://JAL imm26({pc[31:28],imm26,00})
654
            begin
655
                //replaceID  = `JAL ;
656
                ext_ctl = `EXT_J;
657
                rd_sel = `RD_R31;
658
                cmp_ctl = `CMP_NOP;
659
                pc_gen_ctl = `PC_J;
660
                fsm_dly = `FSM_NOI;
661
                muxa_ctl = `MUXA_PC;
662
                muxb_ctl = `MUXB_RT;
663
                alu_func = `ALU_PA;
664
                alu_we = `EN;
665
                dmem_ctl = `DMEM_NOP;
666
                wb_we =  `DIS;
667
                wb_mux = `WB_ALU;
668
                //end of `JAL ;
669
            end
670
            'd4://BEQ rs,rt,offset(signed)
671
            begin
672
                //replaceID  = `BEQ ;
673
                ext_ctl = `EXT_B;
674
                rd_sel = `RD_NOP;
675
                cmp_ctl = `CMP_BEQ;
676
                pc_gen_ctl = `PC_BC;
677
                fsm_dly = `FSM_CUR;
678
                muxa_ctl = `MUXA_NOP;
679
                muxb_ctl = `MUXB_NOP;
680
                alu_func = `ALU_NOP;
681
                alu_we = `DIS;
682
                dmem_ctl = `DMEM_NOP;
683
                wb_we =  `DIS;
684
                wb_mux = `WB_NOP;
685
                //end of `BEQ ;
686
            end
687
            'd5://BNE rs,rt,offset(signed)
688
            begin
689
                //replaceID  = `BNE ;
690
                ext_ctl = `EXT_B;
691
                rd_sel = `RD_NOP;
692
                cmp_ctl = `CMP_BNE;
693
                pc_gen_ctl = `PC_BC;
694
                fsm_dly = `FSM_CUR;
695
                muxa_ctl = `MUXA_NOP;
696
                muxb_ctl = `MUXB_NOP;
697
                alu_func = `ALU_NOP;
698
                alu_we = `DIS;
699
                dmem_ctl = `DMEM_NOP;
700
                wb_we =  `DIS;
701
                wb_mux = `WB_NOP;
702
                //end of `BNE ;
703
            end
704
            'd6://BLEZ rs,offset(signed)
705
            begin
706
                //replaceID  = `BLEZ ;
707
                ext_ctl = `EXT_B;
708
                rd_sel = `RD_NOP;
709
                cmp_ctl = `CMP_BLEZ;
710
                pc_gen_ctl = `PC_BC;
711
                fsm_dly = `FSM_CUR;
712
                muxa_ctl = `MUXA_NOP;
713
                muxb_ctl = `MUXB_NOP;
714
                alu_func = `ALU_NOP;
715
                alu_we = `DIS;
716
                dmem_ctl = `DMEM_NOP;
717
                wb_we =  `DIS;
718
                wb_mux = `WB_NOP;
719
                //end of `BLEZ ;
720
            end
721
            'd7://BGTZ rs,offset(signed)
722
            begin
723
                //replaceID  = `BGTZ ;
724
                ext_ctl = `EXT_B;
725
                rd_sel = `RD_NOP;
726
                cmp_ctl = `CMP_BGTZ;
727
                pc_gen_ctl = `PC_BC;
728
                fsm_dly = `FSM_CUR;
729
                muxa_ctl = `MUXA_NOP;
730
                muxb_ctl = `MUXB_NOP;
731
                alu_func = `ALU_NOP;
732
                alu_we = `DIS;
733
                dmem_ctl = `DMEM_NOP;
734
                wb_we =  `DIS;
735
                wb_mux = `WB_NOP;
736
                //end of `BGTZ ;
737
            end
738
            'd8://ADDI rt,rs,imm16(singed)
739
            begin
740
                //replaceID  = `ADDI ;
741
                ext_ctl = `EXT_SIGN;
742
                rd_sel = `RD_RT;
743
                cmp_ctl = `CMP_NOP;
744
                pc_gen_ctl = `PC_NEXT;
745
                fsm_dly = `FSM_NOP;
746
                muxa_ctl = `MUXA_RS;
747
                muxb_ctl = `MUXB_EXT;
748
                alu_func = `ALU_ADD;
749
                alu_we = `EN;
750
                dmem_ctl = `DMEM_NOP;
751
                wb_we =  `DIS;
752
                wb_mux = `WB_ALU;
753
                //end of `ADDI ;
754
            end
755
            'd9://ADDIU rt,rs,imm16(singed)
756
            begin
757
                //replaceID  = `ADDIU ;
758
                ext_ctl = `EXT_SIGN;
759
                rd_sel = `RD_RT;
760
                cmp_ctl = `CMP_NOP;
761
                pc_gen_ctl = `PC_NEXT;
762
                fsm_dly = `FSM_NOP;
763
                muxa_ctl = `MUXA_RS;
764
                muxb_ctl = `MUXB_EXT;
765
                alu_func = `ALU_ADD;
766
                alu_we = `EN;
767
                dmem_ctl = `DMEM_NOP;
768
                wb_we =  `DIS;
769
                wb_mux = `WB_ALU;
770
                //end of `ADDIU ;
771
            end
772
            'd10://SLTI rt,rs,imm16(singed)
773
            begin
774
                //replaceID  = `SLTI ;
775
                ext_ctl = `EXT_SIGN;
776
                rd_sel = `RD_RT;
777
                cmp_ctl = `CMP_NOP;
778
                pc_gen_ctl = `PC_NEXT;
779
                fsm_dly = `FSM_NOP;
780
                muxa_ctl = `MUXA_RS;
781
                muxb_ctl = `MUXB_EXT;
782
                alu_func = `ALU_SLT;
783
                alu_we = `EN;
784
                dmem_ctl = `DMEM_NOP;
785
                wb_we =  `DIS;
786
                wb_mux = `WB_ALU;
787
                //end of `SLTI ;
788
            end
789
            'd11://SLTIU rt,rs,imm16(singed)
790
            begin
791
                //replaceID  = `SLTIU ;
792
                ext_ctl = `EXT_UNSIGN;
793
                rd_sel = `RD_RT;
794
                cmp_ctl = `CMP_NOP;
795
                pc_gen_ctl = `PC_NEXT;
796
                fsm_dly = `FSM_NOP;
797
                muxa_ctl = `MUXA_RS;
798
                muxb_ctl = `MUXB_EXT;
799
                alu_func = `ALU_SLTU;
800
                alu_we = `EN;
801
                dmem_ctl = `DMEM_NOP;
802
                wb_we =  `DIS;
803
                wb_mux = `WB_ALU;
804
                //end of `SLTIU ;
805
            end
806
            'd12://ANDI rt,rs,imm16(singed)
807
            begin
808
                //replaceID  = `ANDI ;
809
                ext_ctl = `EXT_UNSIGN;
810
                rd_sel = `RD_RT;
811
                cmp_ctl = `CMP_NOP;
812
                pc_gen_ctl = `PC_NEXT;
813
                fsm_dly = `FSM_NOP;
814
                muxa_ctl = `MUXA_RS;
815
                muxb_ctl = `MUXB_EXT;
816
                alu_func = `ALU_AND;
817
                alu_we = `EN;
818
                dmem_ctl = `DMEM_NOP;
819
                wb_we =  `DIS;
820
                wb_mux = `WB_ALU;
821
                //end of `ANDI ;
822
            end
823
            'd13://ORI rt,rs,imm16(singed)
824
            begin
825
                //replaceID  = `ORI ;
826
                ext_ctl = `EXT_UNSIGN;
827
                rd_sel = `RD_RT;
828
                cmp_ctl = `CMP_NOP;
829
                pc_gen_ctl = `PC_NEXT;
830
                fsm_dly = `FSM_NOP;
831
                muxa_ctl = `MUXA_RS;
832
                muxb_ctl = `MUXB_EXT;
833
                alu_func = `ALU_OR;
834
                alu_we = `EN;
835
                dmem_ctl = `DMEM_NOP;
836
                wb_we =  `DIS;
837
                wb_mux = `WB_NOP;
838
                //end of `ORI ;
839
            end
840
            'd14://XORI rt,rs,imm16(singed)
841
            begin
842
                //replaceID  = `XORI ;
843
                ext_ctl = `EXT_UNSIGN;
844
                rd_sel = `RD_RT;
845
                cmp_ctl = `CMP_NOP;
846
                pc_gen_ctl = `PC_NEXT;
847
                fsm_dly = `FSM_NOP;
848
                muxa_ctl = `MUXA_RS;
849
                muxb_ctl = `MUXB_EXT;
850
                alu_func = `ALU_XOR;
851
                alu_we = `EN;
852
                dmem_ctl = `DMEM_NOP;
853
                wb_we =  `EN;
854
                wb_mux = `WB_ALU;
855
                //end of `XORI ;
856
            end
857
            'd15://LUI rt,imm16
858
            begin
859
                //replaceID  = `LUI ;
860
                ext_ctl = `EXT_S2H;
861
                rd_sel = `RD_RT;
862
                cmp_ctl = `CMP_NOP;
863
                pc_gen_ctl = `PC_NEXT;
864
                fsm_dly = `FSM_NOP;
865
                muxa_ctl = `MUXA_RS;
866
                muxb_ctl = `MUXB_EXT;
867
                alu_func = `ALU_PB;
868
                alu_we = `EN;
869
                dmem_ctl = `DMEM_NOP;
870
                wb_we =  `DIS;
871
                wb_mux = `WB_ALU;
872
                //end of `LUI ;
873
            end
874
            'd16://COP0 func
875
            begin
876
                case(inst_cop0_func) //synthesis parallel_case
877
                    'd0://mfc0 rt,rd // GPR[rd] = CPR[rt] //differ to mips32 definition
878
                        //read saved PC
879
                    begin
880
                        //replaceID  = `MFC0;
881
                        ext_ctl = `EXT_NOP;
882
                        rd_sel = `RD_RD;
883
                        cmp_ctl = `CMP_NOP;
884
                        pc_gen_ctl = `PC_NEXT;
885
                        fsm_dly = `FSM_NOP;
886
                        muxa_ctl = `MUXA_SPC;
887
                        muxb_ctl = `MUXB_EXT;
888
                        alu_func = `ALU_PA;
889
                        alu_we = `EN;
890
                        dmem_ctl = `DMEM_LB;
891
                        wb_we =  `DIS;
892
                        wb_mux = `WB_ALU;
893
                    end
894
 
895
                    'd4://mtc0 rt,rd // CPR[rd] = GPR[rt] //follow the mips32 definition
896
                    begin        //return from interrupt
897
                        //replaceID  = `MTC0;
898
                        ext_ctl = `EXT_NOP;
899
                        rd_sel = `RD_NOP;
900
                        cmp_ctl = `CMP_NOP;
901
                        pc_gen_ctl = `PC_SPC;
902
                        fsm_dly = `FSM_RET;
903
                        muxa_ctl = `MUXA_NOP;
904
                        muxb_ctl = `MUXB_NOP;
905
                        alu_func = `ALU_NOP;
906
                        alu_we = `DIS;
907
                        dmem_ctl = `DMEM_NOP;
908
                        wb_we =  `DIS;
909
                        wb_mux = `WB_NOP;
910
                    end
911
                    default:
912
                    begin
913 35 mcupro
                        //replaceID  = `INVALID ;
914
                        ext_ctl = `IGN;
915
                        rd_sel = `IGN;
916
                        cmp_ctl = `IGN;
917
                        pc_gen_ctl = `IGN;
918
                        fsm_dly = `IGN;
919
                        muxa_ctl = `IGN;
920
                        muxb_ctl = `IGN;
921
                        alu_func = `IGN;
922
                        alu_we = `IGN;
923
                        dmem_ctl = `IGN;
924
                        wb_we =  `IGN;
925
                        wb_mux = `IGN;
926
                        //end of `INVALID ;
927 10 mcupro
                    end
928
                endcase
929
            end
930
            'd32://LB rt,offset(base) (offset:signed;base:rs)
931
            begin
932
                //replaceID  = `LB ;
933
                ext_ctl = `EXT_SIGN;
934
                rd_sel = `RD_RT;
935
                cmp_ctl = `CMP_NOP;
936
                pc_gen_ctl = `PC_NEXT;
937
                fsm_dly = `FSM_NOP;
938
                muxa_ctl = `MUXA_RS;
939
                muxb_ctl = `MUXB_EXT;
940
                alu_func = `ALU_ADD;
941
                alu_we = `DIS;
942
                dmem_ctl = `DMEM_LBS;
943
                wb_we =  `EN;
944
                wb_mux = `WB_MEM;
945
                //end of `LB ;
946
            end
947
            'd33://LH rt,offset(base) (offset:signed;base:rs)
948
            begin
949
                //replaceID  = `LH ;
950
                ext_ctl = `EXT_SIGN;
951
                rd_sel = `RD_RT;
952
                cmp_ctl = `CMP_NOP;
953
                pc_gen_ctl = `PC_NEXT;
954
                fsm_dly = `FSM_NOP;
955
                muxa_ctl = `MUXA_RS;
956
                muxb_ctl = `MUXB_EXT;
957
                alu_func = `ALU_ADD;
958
                alu_we = `DIS;
959
                dmem_ctl = `DMEM_LHS;
960
                wb_we =  `EN;
961
                wb_mux = `WB_MEM;
962
                //end of `LH ;
963
            end
964
            'd34://LWL rt,offset(base) (offset:signed;base:rs)
965
            begin
966
                //replaceID  = `LWL ;
967
                ext_ctl = `IGN;
968
                rd_sel = `IGN;
969
                cmp_ctl = `IGN;
970
                pc_gen_ctl = `IGN;
971
                fsm_dly = `IGN;
972
                muxa_ctl = `IGN;
973
                muxb_ctl = `IGN;
974
                alu_func = `IGN;
975
                alu_we = `IGN;
976
                dmem_ctl = `IGN;
977
                wb_we =  `IGN;
978
                wb_mux = `IGN;
979
                //end of `LWL ;
980
            end
981
            'd35://LW rt,offset(base) (offset:signed;base:rs)
982
            begin
983
                //replaceID  = `LW ;
984
                ext_ctl = `EXT_SIGN;
985
                rd_sel = `RD_RT;
986
                cmp_ctl = `CMP_NOP;
987
                pc_gen_ctl = `PC_NEXT;
988
                fsm_dly = `FSM_NOP;
989
                muxa_ctl = `MUXA_RS;
990
                muxb_ctl = `MUXB_EXT;
991
                alu_func = `ALU_ADD;
992
                alu_we = `DIS;
993
                dmem_ctl = `DMEM_LW;
994
                wb_we =  `EN;
995
                wb_mux = `WB_MEM;
996
                //end of `LW ;
997
            end
998
            'd36://LBU rt,offset(base) (offset:signed;base:rs)
999
            begin
1000
                //replaceID  = `LBU ;
1001
                ext_ctl = `EXT_SIGN;
1002
                rd_sel = `RD_RT;
1003
                cmp_ctl = `CMP_NOP;
1004
                pc_gen_ctl = `PC_NEXT;
1005
                fsm_dly = `FSM_NOP;
1006
                muxa_ctl = `MUXA_RS;
1007
                muxb_ctl = `MUXB_EXT;
1008
                alu_func = `ALU_ADD;
1009
                alu_we = `DIS;
1010
                dmem_ctl = `DMEM_LBU;
1011
                wb_we =  `EN;
1012
                wb_mux = `WB_MEM;
1013
                //end of `LBU ;
1014
            end
1015
            'd37://LHU rt,offset(base) (offset:signed;base:rs)
1016
            begin
1017
                //replaceID  = `LHU ;
1018
                ext_ctl = `EXT_SIGN;
1019
                rd_sel = `RD_RT;
1020
                cmp_ctl = `CMP_NOP;
1021
                pc_gen_ctl = `PC_NEXT;
1022
                fsm_dly = `FSM_NOP;
1023
                muxa_ctl = `MUXA_RS;
1024
                muxb_ctl = `MUXB_EXT;
1025
                alu_func = `ALU_ADD;
1026
                alu_we = `DIS;
1027
                dmem_ctl = `DMEM_LHU;
1028
                wb_we =  `EN;
1029
                wb_mux = `WB_MEM;
1030
                //end of `LHU ;
1031
            end
1032
            'd38://LWR rt,offset(base) (offset:signed;base:rs)
1033
            begin
1034
                //replaceID  = `LWR ;
1035
                ext_ctl = `IGN;
1036
                rd_sel = `IGN;
1037
                cmp_ctl = `IGN;
1038
                pc_gen_ctl = `IGN;
1039
                fsm_dly = `IGN;
1040
                muxa_ctl = `IGN;
1041
                muxb_ctl = `IGN;
1042
                alu_func = `IGN;
1043
                alu_we = `IGN;
1044
                dmem_ctl = `IGN;
1045
                wb_we =  `IGN;
1046
                wb_mux = `IGN;
1047
                //end of `LWR ;
1048
            end
1049
            'd40://SB rt,offset(base) (offset:signed;base:rs)
1050
            begin
1051
                //replaceID  = `SB ;
1052
                ext_ctl = `EXT_SIGN;
1053
                rd_sel = `RD_NOP;
1054
                cmp_ctl = `CMP_NOP;
1055
                pc_gen_ctl = `PC_NEXT;
1056
                fsm_dly = `FSM_NOP;
1057
                muxa_ctl = `MUXA_RS;
1058
                muxb_ctl = `MUXB_EXT;
1059
                alu_func = `ALU_ADD;
1060
                alu_we = `DIS;
1061
                dmem_ctl = `DMEM_SB;
1062
                wb_we =  `DIS;
1063
                wb_mux = `WB_NOP;
1064
                //end of `SB ;
1065
            end
1066
            'd41://SH rt,offset(base) (offset:signed;base:rs)
1067
            begin
1068
                //replaceID  = `SH ;
1069
                ext_ctl = `EXT_SIGN;
1070
                rd_sel = `RD_RT;
1071
                cmp_ctl = `CMP_NOP;
1072
                pc_gen_ctl = `PC_NEXT;
1073
                fsm_dly = `FSM_NOP;
1074
                muxa_ctl = `MUXA_RS;
1075
                muxb_ctl = `MUXB_EXT;
1076
                alu_func = `ALU_ADD;
1077
                alu_we = `DIS;
1078
                dmem_ctl = `DMEM_SH;
1079
                wb_we =  `DIS;
1080
                wb_mux = `WB_NOP;
1081
                //end of `SH ;
1082
            end
1083
            'd42://SWL rt,offset(base) (offset:signed;base:rs)
1084
            begin
1085
                //replaceID  = `SWL ;
1086
                ext_ctl = `IGN;
1087
                rd_sel = `IGN;
1088
                cmp_ctl = `IGN;
1089
                pc_gen_ctl = `IGN;
1090
                fsm_dly = `IGN;
1091
                muxa_ctl = `IGN;
1092
                muxb_ctl = `IGN;
1093
                alu_func = `IGN;
1094
                alu_we = `IGN;
1095
                dmem_ctl = `IGN;
1096
                wb_we =  `IGN;
1097
                wb_mux = `IGN;
1098
                //end of `SWL ;
1099
            end
1100
            'd43://SW rt,offset(base) (offset:signed;base:rs)
1101
            begin
1102
                //replaceID  = `SW ;
1103
                ext_ctl = `EXT_SIGN;
1104
                rd_sel = `RD_NOP;
1105
                cmp_ctl = `CMP_NOP;
1106
                pc_gen_ctl = `PC_NEXT;
1107
                fsm_dly = `FSM_NOP;
1108
                muxa_ctl = `MUXA_RS;
1109
                muxb_ctl = `MUXB_EXT;
1110
                alu_func = `ALU_ADD;
1111
                alu_we = `DIS;
1112
                dmem_ctl = `DMEM_SW;
1113
                wb_we =  `DIS;
1114
                wb_mux = `WB_NOP;
1115
                //end of `SW ;
1116
            end
1117
            'd46://SWR rt,offset(base) (offset:signed;base:rs)
1118
            begin
1119
                //replaceID  = `SWR ;
1120
                ext_ctl = `IGN;
1121
                rd_sel = `IGN;
1122
                cmp_ctl = `IGN;
1123
                pc_gen_ctl = `IGN;
1124
                fsm_dly = `IGN;
1125
                muxa_ctl = `IGN;
1126
                muxb_ctl = `IGN;
1127
                alu_func = `IGN;
1128
                alu_we = `IGN;
1129
                dmem_ctl = `IGN;
1130
                wb_we =  `IGN;
1131
                wb_mux = `IGN;
1132
                //end of `SWR ;
1133
            end
1134
            default:
1135
            begin
1136 35 mcupro
                //replaceID  = `INVALID ;
1137
                ext_ctl = `IGN;
1138
                rd_sel = `IGN;
1139
                cmp_ctl = `IGN;
1140
                pc_gen_ctl = `IGN;
1141
                fsm_dly = `IGN;
1142
                muxa_ctl = `IGN;
1143
                muxb_ctl = `IGN;
1144
                alu_func = `IGN;
1145
                alu_we = `IGN;
1146
                dmem_ctl = `IGN;
1147
                wb_we =  `IGN;
1148
                wb_mux = `IGN;
1149
                //end of `INVALID ;  //replaceID   = `INVALID ;
1150 10 mcupro
            end
1151
        endcase
1152
    end
1153
endmodule
1154
 
1155
 
1156
 
1157
module pipelinedregs (
1158
        clk,id2ra_ctl_clr,id2ra_ctl_cls,ra2ex_ctl_clr,
1159
        alu_func_i,alu_we_i,cmp_ctl_i,dmem_ctl_i,ext_ctl_i,
1160
        muxa_ctl_i,muxb_ctl_i,pc_gen_ctl_i,rd_sel_i,wb_mux_ctl_i,
1161
        wb_we_i,alu_func_o,alu_we_o,cmp_ctl_o,dmem_ctl_o,dmem_ctl_ur_o,
1162
        ext_ctl,muxa_ctl_o,muxb_ctl_o,pc_gen_ctl_o,rd_sel_o,wb_mux_ctl_o,wb_we_o
1163
    ) ;
1164
 
1165
    input clk;
1166
    wire clk;
1167
    input id2ra_ctl_clr;
1168
    wire id2ra_ctl_clr;
1169
    input id2ra_ctl_cls;
1170
    wire id2ra_ctl_cls;
1171
    input ra2ex_ctl_clr;
1172
    wire ra2ex_ctl_clr;
1173
    input [4:0] alu_func_i;
1174
    wire [4:0] alu_func_i;
1175
    input [0:0] alu_we_i;
1176
    wire [0:0] alu_we_i;
1177
    input [2:0] cmp_ctl_i;
1178
    wire [2:0] cmp_ctl_i;
1179
    input [3:0] dmem_ctl_i;
1180
    wire [3:0] dmem_ctl_i;
1181
    input [2:0] ext_ctl_i;
1182
    wire [2:0] ext_ctl_i;
1183
    input [1:0] muxa_ctl_i;
1184
    wire [1:0] muxa_ctl_i;
1185
    input [1:0] muxb_ctl_i;
1186
    wire [1:0] muxb_ctl_i;
1187
    input [2:0] pc_gen_ctl_i;
1188
    wire [2:0] pc_gen_ctl_i;
1189
    input [1:0] rd_sel_i;
1190
    wire [1:0] rd_sel_i;
1191
    input [0:0] wb_mux_ctl_i;
1192
    wire [0:0] wb_mux_ctl_i;
1193
    input [0:0] wb_we_i;
1194
    wire [0:0] wb_we_i;
1195
    output [4:0] alu_func_o;
1196
    wire [4:0] alu_func_o;
1197
    output [0:0] alu_we_o;
1198
    wire [0:0] alu_we_o;
1199
    output [2:0] cmp_ctl_o;
1200
    wire [2:0] cmp_ctl_o;
1201
    output [3:0] dmem_ctl_o;
1202
    wire [3:0] dmem_ctl_o;
1203
    output [3:0] dmem_ctl_ur_o;
1204
    wire [3:0] dmem_ctl_ur_o;
1205
    output [2:0] ext_ctl;
1206
    wire [2:0] ext_ctl;
1207
    output [1:0] muxa_ctl_o;
1208
    wire [1:0] muxa_ctl_o;
1209
    output [1:0] muxb_ctl_o;
1210
    wire [1:0] muxb_ctl_o;
1211
    output [2:0] pc_gen_ctl_o;
1212
    wire [2:0] pc_gen_ctl_o;
1213
    output [1:0] rd_sel_o;
1214
    wire [1:0] rd_sel_o;
1215
    output [0:0] wb_mux_ctl_o;
1216
    wire [0:0] wb_mux_ctl_o;
1217
    output [0:0] wb_we_o;
1218
    wire [0:0] wb_we_o;
1219
 
1220
 
1221
    wire NET7643;
1222
    wire [0:0] BUS4987;
1223
    wire [1:0] BUS5008;
1224
    wire [1:0] BUS5483;
1225
    wire [0:0] BUS5639;
1226
    wire [0:0] BUS5651;
1227
    wire [3:0] BUS5666;
1228
    wire [4:0] BUS5674;
1229
    wire [0:0] BUS5682;
1230
    wire [0:0] BUS5690;
1231
    wire [0:0] BUS5790;
1232
    wire [0:0] BUS7299;
1233
    wire [0:0] BUS7822;
1234
 
1235
 
1236
    muxb_ctl_reg_clr_cls U1
1237
                         (
1238
                             .clk(clk),
1239
                             .clr(id2ra_ctl_clr),
1240
                             .cls(id2ra_ctl_cls),
1241
                             .muxb_ctl_i(muxb_ctl_i),
1242
                             .muxb_ctl_o(BUS5483)
1243
                         );
1244
 
1245
 
1246
 
1247
    wb_mux_ctl_reg_clr_cls U10
1248
                           (
1249
                               .clk(clk),
1250
                               .clr(id2ra_ctl_clr),
1251
                               .cls(id2ra_ctl_cls),
1252
                               .wb_mux_ctl_i(wb_mux_ctl_i),
1253
                               .wb_mux_ctl_o(BUS5651)
1254
                           );
1255
 
1256
 
1257
 
1258
    wb_we_reg_clr_cls U11
1259
                      (
1260
                          .clk(clk),
1261
                          .clr(id2ra_ctl_clr),
1262
                          .cls(id2ra_ctl_cls),
1263
                          .wb_we_i(wb_we_i),
1264
                          .wb_we_o(BUS5639)
1265
                      );
1266
 
1267
 
1268
 
1269
    wb_we_reg U12
1270
              (
1271
                  .clk(clk),
1272
                  .wb_we_i(NET7643),
1273
                  .wb_we_o(wb_we_o)
1274
              );
1275
 
1276
 
1277
 
1278
    wb_mux_ctl_reg_clr U13
1279
                       (
1280
                           .clk(clk),
1281
                           .clr(ra2ex_ctl_clr),
1282
                           .wb_mux_ctl_i(BUS5651),
1283
                           .wb_mux_ctl_o(BUS5690)
1284
                       );
1285
 
1286
 
1287
 
1288
    muxb_ctl_reg_clr U14
1289
                     (
1290
                         .clk(clk),
1291
                         .clr(ra2ex_ctl_clr),
1292
                         .muxb_ctl_i(BUS5483),
1293
                         .muxb_ctl_o(muxb_ctl_o)
1294
                     );
1295
 
1296
 
1297
 
1298
    dmem_ctl_reg_clr U15
1299
                     (
1300
                         .clk(clk),
1301
                         .clr(ra2ex_ctl_clr),
1302
                         .dmem_ctl_i(BUS5666),
1303
                         .dmem_ctl_o(dmem_ctl_ur_o)
1304
                     );
1305
 
1306
 
1307
 
1308
    alu_func_reg_clr U16
1309
                     (
1310
                         .alu_func_i(BUS5674),
1311
                         .alu_func_o(alu_func_o),
1312
                         .clk(clk),
1313
                         .clr(ra2ex_ctl_clr)
1314
                     );
1315
 
1316
 
1317
 
1318
    muxa_ctl_reg_clr U17
1319
                     (
1320
                         .clk(clk),
1321
                         .clr(ra2ex_ctl_clr),
1322
                         .muxa_ctl_i(BUS5008),
1323
                         .muxa_ctl_o(muxa_ctl_o)
1324
                     );
1325
 
1326
 
1327
 
1328
    wb_mux_ctl_reg U18
1329
                   (
1330
                       .clk(clk),
1331
                       .wb_mux_ctl_i(BUS5790),
1332
                       .wb_mux_ctl_o(wb_mux_ctl_o)
1333
                   );
1334
 
1335
 
1336
 
1337
    wb_we_reg_clr U19
1338
                  (
1339
                      .clk(clk),
1340
                      .clr(ra2ex_ctl_clr),
1341
                      .wb_we_i(BUS5639),
1342
                      .wb_we_o(BUS5682)
1343
                  );
1344
 
1345
 
1346
 
1347
    cmp_ctl_reg_clr_cls U2
1348
                        (
1349
                            .clk(clk),
1350
                            .clr(id2ra_ctl_clr),
1351
                            .cls(id2ra_ctl_cls),
1352
                            .cmp_ctl_i(cmp_ctl_i),
1353
                            .cmp_ctl_o(cmp_ctl_o)
1354
                        );
1355
 
1356
 
1357
 
1358
    wb_we_reg U20
1359
              (
1360
                  .clk(clk),
1361
                  .wb_we_i(BUS5682),
1362
                  .wb_we_o(BUS7822)
1363
              );
1364
 
1365
 
1366
 
1367
    wb_mux_ctl_reg U21
1368
                   (
1369
                       .clk(clk),
1370
                       .wb_mux_ctl_i(BUS5690),
1371
                       .wb_mux_ctl_o(BUS5790)
1372
                   );
1373
 
1374
 
1375
 
1376
    wb_we_reg U22
1377
              (
1378
                  .clk(clk),
1379
                  .wb_we_i(BUS7299),
1380
                  .wb_we_o(alu_we_o)
1381
              );
1382
 
1383
 
1384
 
1385
    assign NET7643 = alu_we_o[0] | BUS7822[0];
1386
 
1387
 
1388
    alu_we_reg_clr U24
1389
                   (
1390
                       .alu_we_i(BUS4987),
1391
                       .alu_we_o(BUS7299),
1392
                       .clk(clk),
1393
                       .clr(ra2ex_ctl_clr)
1394
                   );
1395
 
1396
 
1397
 
1398
    alu_func_reg_clr_cls U26
1399
                         (
1400
                             .alu_func_i(alu_func_i),
1401
                             .alu_func_o(BUS5674),
1402
                             .clk(clk),
1403
                             .clr(id2ra_ctl_clr),
1404
                             .cls(id2ra_ctl_cls)
1405
                         );
1406
 
1407
 
1408
 
1409
    dmem_ctl_reg_clr_cls U3
1410
                         (
1411
                             .clk(clk),
1412
                             .clr(id2ra_ctl_clr),
1413
                             .cls(id2ra_ctl_cls),
1414
                             .dmem_ctl_i(dmem_ctl_i),
1415
                             .dmem_ctl_o(BUS5666)
1416
                         );
1417
 
1418
 
1419
 
1420
    ext_ctl_reg_clr_cls U4
1421
                        (
1422
                            .clk(clk),
1423
                            .clr(id2ra_ctl_clr),
1424
                            .cls(id2ra_ctl_cls),
1425
                            .ext_ctl_i(ext_ctl_i),
1426
                            .ext_ctl_o(ext_ctl)
1427
                        );
1428
 
1429
 
1430
 
1431
    rd_sel_reg_clr_cls U5
1432
                       (
1433
                           .clk(clk),
1434
                           .clr(id2ra_ctl_clr),
1435
                           .cls(id2ra_ctl_cls),
1436
                           .rd_sel_i(rd_sel_i),
1437
                           .rd_sel_o(rd_sel_o)
1438
                       );
1439
 
1440
 
1441
 
1442
    alu_we_reg_clr_cls U6
1443
                       (
1444
                           .alu_we_i(alu_we_i),
1445
                           .alu_we_o(BUS4987),
1446
                           .clk(clk),
1447
                           .clr(id2ra_ctl_clr),
1448
                           .cls(id2ra_ctl_cls)
1449
                       );
1450
 
1451
 
1452
 
1453
    muxa_ctl_reg_clr_cls U7
1454
                         (
1455
                             .clk(clk),
1456
                             .clr(id2ra_ctl_clr),
1457
                             .cls(id2ra_ctl_cls),
1458
                             .muxa_ctl_i(muxa_ctl_i),
1459
                             .muxa_ctl_o(BUS5008)
1460
                         );
1461
 
1462
 
1463
 
1464
    pc_gen_ctl_reg_clr_cls U8
1465
                           (
1466
                               .clk(clk),
1467
                               .clr(id2ra_ctl_clr),
1468
                               .cls(id2ra_ctl_cls),
1469
                               .pc_gen_ctl_i(pc_gen_ctl_i),
1470
                               .pc_gen_ctl_o(pc_gen_ctl_o)
1471
                           );
1472
 
1473
 
1474
 
1475
    dmem_ctl_reg U9
1476
                 (
1477
                     .clk(clk),
1478
                     .dmem_ctl_i(dmem_ctl_ur_o),
1479
                     .dmem_ctl_o(dmem_ctl_o)
1480
                 );
1481
 
1482
 
1483
 
1484
endmodule
1485
 
1486
module decode_pipe
1487
    (
1488
        clk,id2ra_ctl_clr,id2ra_ctl_cls,
1489
        ra2ex_ctl_clr,ins_i,alu_func_o,alu_we_o,
1490
        cmp_ctl_o,dmem_ctl_o,dmem_ctl_ur_o,ext_ctl_o,
1491
        fsm_dly,muxa_ctl_o,muxb_ctl_o,pc_gen_ctl_o,rd_sel_o,
1492
        wb_mux_ctl_o,wb_we_o
1493
    ) ;
1494
 
1495
    input clk;
1496
    wire clk;
1497
    input id2ra_ctl_clr;
1498
    wire id2ra_ctl_clr;
1499
    input id2ra_ctl_cls;
1500
    wire id2ra_ctl_cls;
1501
    input ra2ex_ctl_clr;
1502
    wire ra2ex_ctl_clr;
1503
    input [31:0] ins_i;
1504
    wire [31:0] ins_i;
1505
    output [4:0] alu_func_o;
1506
    wire [4:0] alu_func_o;
1507
    output [0:0] alu_we_o;
1508
    wire [0:0] alu_we_o;
1509
    output [2:0] cmp_ctl_o;
1510
    wire [2:0] cmp_ctl_o;
1511
    output [3:0] dmem_ctl_o;
1512
    wire [3:0] dmem_ctl_o;
1513
    output [3:0] dmem_ctl_ur_o;
1514
    wire [3:0] dmem_ctl_ur_o;
1515
    output [2:0] ext_ctl_o;
1516
    wire [2:0] ext_ctl_o;
1517
    output [2:0] fsm_dly;
1518
    wire [2:0] fsm_dly;
1519
    output [1:0] muxa_ctl_o;
1520
    wire [1:0] muxa_ctl_o;
1521
    output [1:0] muxb_ctl_o;
1522
    wire [1:0] muxb_ctl_o;
1523
    output [2:0] pc_gen_ctl_o;
1524
    wire [2:0] pc_gen_ctl_o;
1525
    output [1:0] rd_sel_o;
1526
    wire [1:0] rd_sel_o;
1527
    output [0:0] wb_mux_ctl_o;
1528
    wire [0:0] wb_mux_ctl_o;
1529
    output [0:0] wb_we_o;
1530
    wire [0:0] wb_we_o;
1531
 
1532
 
1533
    wire [4:0] BUS2040;
1534
    wire [0:0] BUS2048;
1535
    wire [2:0] BUS2056;
1536
    wire [3:0] BUS2064;
1537
    wire [2:0] BUS2072;
1538
    wire [1:0] BUS2086;
1539
    wire [1:0] BUS2094;
1540
    wire [2:0] BUS2102;
1541
    wire [1:0] BUS2110;
1542
    wire [0:0] BUS2118;
1543
    wire [0:0] BUS2126;
1544
 
1545
 
1546
    decoder idecoder
1547
            (
1548
                .alu_func(BUS2040),
1549
                .alu_we(BUS2048),
1550
                .cmp_ctl(BUS2056),
1551
                .dmem_ctl(BUS2064),
1552
                .ext_ctl(BUS2072),
1553
                .fsm_dly(fsm_dly),
1554
                .ins_i(ins_i),
1555
                .muxa_ctl(BUS2086),
1556
                .muxb_ctl(BUS2094),
1557
                .pc_gen_ctl(BUS2102),
1558
                .rd_sel(BUS2110),
1559
                .wb_mux(BUS2118),
1560
                .wb_we(BUS2126)
1561
            );
1562
 
1563
 
1564
 
1565
    pipelinedregs pipereg
1566
                  (
1567
                      .alu_func_i(BUS2040),
1568
                      .alu_func_o(alu_func_o),
1569
                      .alu_we_i(BUS2048),
1570
                      .alu_we_o(alu_we_o),
1571
                      .clk(clk),
1572
                      .cmp_ctl_i(BUS2056),
1573
                      .cmp_ctl_o(cmp_ctl_o),
1574
                      .dmem_ctl_i(BUS2064),
1575
                      .dmem_ctl_o(dmem_ctl_o),
1576
                      .dmem_ctl_ur_o(dmem_ctl_ur_o),
1577
                      .ext_ctl(ext_ctl_o),
1578
                      .ext_ctl_i(BUS2072),
1579
                      .id2ra_ctl_clr(id2ra_ctl_clr),
1580
                      .id2ra_ctl_cls(id2ra_ctl_cls),
1581
                      .muxa_ctl_i(BUS2086),
1582
                      .muxa_ctl_o(muxa_ctl_o),
1583
                      .muxb_ctl_i(BUS2094),
1584
                      .muxb_ctl_o(muxb_ctl_o),
1585
                      .pc_gen_ctl_i(BUS2102),
1586
                      .pc_gen_ctl_o(pc_gen_ctl_o),
1587
                      .ra2ex_ctl_clr(ra2ex_ctl_clr),
1588
                      .rd_sel_i(BUS2110),
1589
                      .rd_sel_o(rd_sel_o),
1590
                      .wb_mux_ctl_i(BUS2118),
1591
                      .wb_mux_ctl_o(wb_mux_ctl_o),
1592
                      .wb_we_i(BUS2126),
1593
                      .wb_we_o(wb_we_o)
1594
                  );
1595
 
1596
 
1597
 
1598
endmodule
1599
 
1600
 
1601
 
1602
 
1603
 

powered by: WebSVN 2.1.0

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