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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [or1200/] [rtl/] [verilog/] [id.v] - Blame information for rev 209

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

Line No. Rev Author Line
1 168 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Instruction decode                                 ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Majority of instruction decoding is performed here.         ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - make it smaller and faster                               ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 203 lampret
// Revision 1.2  2001/08/13 03:36:20  lampret
48
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
49
//
50 170 lampret
// Revision 1.1  2001/08/09 13:39:33  lampret
51
// Major clean-up.
52 168 lampret
//
53 170 lampret
//
54 168 lampret
 
55
`include "timescale.v"
56
`include "defines.v"
57
 
58
module id(
59
        // Clock and reset
60
        clk, rst,
61
 
62
        // Internal i/f
63 205 lampret
        id_freeze, ex_freeze, wb_freeze, except_flushpipe, if_insn, branch_op,
64 168 lampret
        rf_addra, rf_addrb, alu_op, shrot_op, comp_op, rf_addrw, rfwb_op,
65
        wb_insn, simm, branch_addrofs, lsu_addrofs, sel_a, sel_b, lsu_op,
66 203 lampret
        multicycle, spr_addrimm, wbforw_valid, sig_syscall,
67 209 lampret
        force_dslot_fetch, id_macrc_op, ex_macrc_op
68 168 lampret
);
69
 
70
//
71
// I/O
72
//
73
input                                   clk;
74
input                                   rst;
75 205 lampret
input                                   id_freeze;
76
input                                   ex_freeze;
77
input                                   wb_freeze;
78 168 lampret
input                                   except_flushpipe;
79
input   [31:0]                           if_insn;
80
output  [`BRANCHOP_WIDTH-1:0]            branch_op;
81
output  [`REGFILE_ADDR_WIDTH-1:0]        rf_addrw;
82
output  [`REGFILE_ADDR_WIDTH-1:0]        rf_addra;
83
output  [`REGFILE_ADDR_WIDTH-1:0]        rf_addrb;
84
output  [`ALUOP_WIDTH-1:0]               alu_op;
85
output  [`SHROTOP_WIDTH-1:0]             shrot_op;
86
output  [`RFWBOP_WIDTH-1:0]              rfwb_op;
87
output  [31:0]                           wb_insn;
88
output  [31:0]                           simm;
89
output  [31:2]                          branch_addrofs;
90
output  [31:0]                           lsu_addrofs;
91
output  [`SEL_WIDTH-1:0]         sel_a;
92
output  [`SEL_WIDTH-1:0]         sel_b;
93
output  [`LSUOP_WIDTH-1:0]               lsu_op;
94
output  [`COMPOP_WIDTH-1:0]              comp_op;
95
output  [`MULTICYCLE_WIDTH-1:0]          multicycle;
96
output  [15:0]                           spr_addrimm;
97
input                                   wbforw_valid;
98
output                                  sig_syscall;
99 203 lampret
output                                  force_dslot_fetch;
100 209 lampret
output                                  id_macrc_op;
101
output                                  ex_macrc_op;
102 168 lampret
 
103
//
104
// Internal wires and regs
105
//
106
reg     [`BRANCHOP_WIDTH-1:0]            pre_branch_op;
107
reg     [`BRANCHOP_WIDTH-1:0]            branch_op;
108
reg     [`ALUOP_WIDTH-1:0]               alu_op;
109
reg     [`SHROTOP_WIDTH-1:0]             shrot_op;
110
reg     [31:0]                           id_insn;
111
reg     [31:0]                           ex_insn;
112
reg     [31:0]                           wb_insn;
113
reg     [`REGFILE_ADDR_WIDTH-1:0]        rf_addrw;
114
reg     [`REGFILE_ADDR_WIDTH-1:0]        wb_rfaddrw;
115
reg     [`RFWBOP_WIDTH-1:0]              rfwb_op;
116
reg     [31:0]                           lsu_addrofs;
117
reg     [`SEL_WIDTH-1:0]         sel_a;
118
reg     [`SEL_WIDTH-1:0]         sel_b;
119
reg                                     sel_imm;
120
reg     [`LSUOP_WIDTH-1:0]               lsu_op;
121
reg     [`COMPOP_WIDTH-1:0]              comp_op;
122
reg     [`MULTICYCLE_WIDTH-1:0]          multicycle;
123
reg                                     imm_signextend;
124
reg     [15:0]                           spr_addrimm;
125
reg                                     sig_syscall;
126
wire                                    rst_or_except_flushpipe;
127 209 lampret
reg                                     ex_macrc_op;
128 168 lampret
 
129
//
130
// Register file read addresses
131
//
132
assign rf_addra = if_insn[20:16];
133
assign rf_addrb = if_insn[15:11];
134
 
135
//
136 203 lampret
// Force fetch of delay slot instruction when jump/branch is preceeded by load/store
137
// instructions
138
//
139 209 lampret
assign force_dslot_fetch = ((|pre_branch_op) & (|lsu_op));
140 203 lampret
 
141
//
142 168 lampret
// Sign/Zero extension of immediates
143
//
144
assign simm = (imm_signextend == `on) ? {{16{id_insn[15]}}, id_insn[15:0]} : {{16'b0}, id_insn[15:0]};
145
 
146
//
147
// Sign extension of branch offset
148
//
149
assign branch_addrofs = {{4{ex_insn[25]}}, ex_insn[25:0]};
150
 
151
//
152
// Async reset for most of pipeline flops
153
//
154
assign rst_or_except_flushpipe = rst | except_flushpipe;
155
 
156
//
157 209 lampret
// l.macrc in ID stage
158
//
159
assign id_macrc_op = (id_insn[31:26] == 6'b00_0110) & id_insn[16];
160
 
161
//
162 168 lampret
// Generation of sel_a
163
//
164 209 lampret
always @(rf_addrw or id_insn or rfwb_op or wbforw_valid or wb_rfaddrw)
165 168 lampret
        if ((id_insn[20:16] == rf_addrw) && rfwb_op[0])
166 209 lampret
                sel_a = `SEL_EX_FORW;
167 168 lampret
        else if ((id_insn[20:16] == wb_rfaddrw) && wbforw_valid)
168 209 lampret
                sel_a = `SEL_WB_FORW;
169 168 lampret
        else
170 209 lampret
                sel_a = `SEL_RF;
171 168 lampret
 
172
//
173
// Generation of sel_b
174
//
175 209 lampret
always @(rf_addrw or sel_imm or id_insn or rfwb_op or wbforw_valid or wb_rfaddrw)
176 168 lampret
        if (sel_imm)
177 209 lampret
                sel_b = `SEL_IMM;
178 168 lampret
        else if ((id_insn[15:11] == rf_addrw) && rfwb_op[0])
179 209 lampret
                sel_b = `SEL_EX_FORW;
180 168 lampret
        else if ((id_insn[15:11] == wb_rfaddrw) && wbforw_valid)
181 209 lampret
                sel_b = `SEL_WB_FORW;
182 168 lampret
        else
183 209 lampret
                sel_b = `SEL_RF;
184 168 lampret
 
185
//
186 209 lampret
// l.macrc in EX stage
187
//
188
always @(posedge clk or posedge rst_or_except_flushpipe) begin
189
        if (rst_or_except_flushpipe)
190
                ex_macrc_op <= #1 1'b0;
191
        else if (!ex_freeze & id_freeze)
192
                ex_macrc_op <= #1 1'b0;
193
        else if (!ex_freeze)
194
                ex_macrc_op <= #1 id_macrc_op;
195
end
196
 
197
//
198 168 lampret
// Decode of spr_addrimm
199
//
200
always @(posedge clk or posedge rst_or_except_flushpipe) begin
201
        if (rst_or_except_flushpipe)
202
                spr_addrimm <= #1 16'h0000;
203 205 lampret
        else if (!ex_freeze & id_freeze)
204
                spr_addrimm <= #1 16'h0000;
205
        else if (!ex_freeze) begin
206 168 lampret
                case (id_insn[31:26])   // synopsys full_case parallel_case
207
                        // l.mtspr
208
                        `OR32_MTSPR:
209
                                spr_addrimm <= #1 id_insn[15:0];
210
                        // l.mfspr
211
                        default:
212
                                spr_addrimm <= #1 {id_insn[25:21], id_insn[10:0]};
213
                endcase
214
        end
215
end
216
 
217
//
218
// Decode of multicycle
219
//
220
always @(id_insn) begin
221
  case (id_insn[31:26])         // synopsys full_case parallel_case
222
 
223
    // l.lwz
224
    `OR32_LWZ:
225 209 lampret
      multicycle = `TWO_CYCLES;
226 168 lampret
 
227
    // l.lbz
228
    `OR32_LBZ:
229 209 lampret
      multicycle = `TWO_CYCLES;
230 168 lampret
 
231
    // l.lbs
232
    `OR32_LBS:
233 209 lampret
      multicycle = `TWO_CYCLES;
234 168 lampret
 
235
    // l.lhz
236
    `OR32_LHZ:
237 209 lampret
      multicycle = `TWO_CYCLES;
238 168 lampret
 
239
    // l.lhs
240
    `OR32_LHS:
241 209 lampret
      multicycle = `TWO_CYCLES;
242 168 lampret
 
243
    // l.sw
244
    `OR32_SW:
245 209 lampret
      multicycle = `TWO_CYCLES;
246 168 lampret
 
247
    // l.sb
248
    `OR32_SB:
249 209 lampret
      multicycle = `TWO_CYCLES;
250 168 lampret
 
251
    // l.sh
252
    `OR32_SH:
253 209 lampret
      multicycle = `TWO_CYCLES;
254 168 lampret
 
255
    // ALU instructions except the one with immediate
256
    `OR32_ALU:
257 209 lampret
      multicycle = id_insn[`ALUMCYC_POS];
258 168 lampret
 
259
    // Single cycle instructions
260
    default: begin
261 209 lampret
      multicycle = `ONE_CYCLE;
262 168 lampret
    end
263
 
264
  endcase
265
 
266
end
267
 
268
//
269
// Decode of imm_signextend
270
//
271
always @(id_insn) begin
272
  case (id_insn[31:26])         // synopsys full_case parallel_case
273
 
274
        // l.addi
275
        `OR32_ADDI:
276 209 lampret
                imm_signextend = `on;
277 168 lampret
 
278
        // l.addic
279
        `OR32_ADDIC:
280 209 lampret
                imm_signextend = `on;
281 168 lampret
 
282
        // l.xori
283
        `OR32_XORI:
284 209 lampret
                imm_signextend = `on;
285 168 lampret
 
286
        // l.muli
287
        `OR32_MULI:
288 209 lampret
                imm_signextend = `on;
289 168 lampret
 
290
        // l.maci
291
        `OR32_MACI:
292 209 lampret
                imm_signextend = `on;
293 168 lampret
 
294
        // SFXX insns with immediate
295
        `OR32_SFXXI:
296 209 lampret
                imm_signextend = `on;
297 168 lampret
 
298
        // Instructions with no or zero extended immediate
299
        default: begin
300 209 lampret
                imm_signextend = `off;
301 168 lampret
        end
302
 
303
endcase
304
 
305
end
306
 
307
//
308
// LSU addr offset
309
//
310
always @(lsu_op or ex_insn) begin
311 209 lampret
        lsu_addrofs[10:0] = ex_insn[10:0];
312 168 lampret
        case(lsu_op)    // synopsys parallel_case full_case
313
                `LSUOP_SW, `LSUOP_SH, `LSUOP_SB :
314 209 lampret
                        lsu_addrofs[31:11] = {{16{ex_insn[25]}}, ex_insn[25:21]};
315 168 lampret
                default :
316 209 lampret
                        lsu_addrofs[31:11] = {{16{ex_insn[15]}}, ex_insn[15:11]};
317 168 lampret
        endcase
318
end
319
 
320
//
321
// Register file write address
322
//
323
always @(posedge clk or posedge rst) begin
324
        if (rst)
325
                rf_addrw <= #1 5'd0;
326 205 lampret
        else if (!ex_freeze & id_freeze)
327
                rf_addrw <= #1 5'd00;
328
        else if (!ex_freeze)
329 168 lampret
                case (pre_branch_op)    // synopsys parallel_case full_case
330
                        `BRANCHOP_JR, `BRANCHOP_BAL:
331
                                rf_addrw <= #1 5'd09;   // link register r9
332
                        default:
333
                                rf_addrw <= #1 id_insn[25:21];
334
                endcase
335
end
336
 
337
//
338
// rf_addrw in wb stage (used in forwarding logic)
339
//
340
always @(posedge clk or posedge rst) begin
341
        if (rst)
342
                wb_rfaddrw <= #1 5'd0;
343 205 lampret
        else if (!wb_freeze)
344 168 lampret
                wb_rfaddrw <= #1 rf_addrw;
345
end
346
 
347
//
348
// Instruction latch in id_insn
349
//
350
always @(posedge clk or posedge rst) begin
351
        if (rst) begin
352
                id_insn[31:26] <= #1 `OR32_NOP;
353
                id_insn[25:0] <= #1 26'd0;
354
        end
355 205 lampret
        else if (!id_freeze) begin
356 168 lampret
                id_insn <= #1 if_insn;
357 203 lampret
`ifdef OR1200_VERBOSE
358
// synopsys translate_off
359 168 lampret
                $display("%t: id_insn <= %h", $time, if_insn);
360 203 lampret
// synopsys translate_on
361
`endif
362 168 lampret
        end
363
end
364
 
365
//
366
// Instruction latch in ex_insn
367
//
368
always @(posedge clk or posedge rst) begin
369
        if (rst) begin
370
                ex_insn[31:26] <= #1 `OR32_NOP;
371
                ex_insn[25:0] <= #1 26'd0;
372
        end
373 205 lampret
        else if (!ex_freeze & id_freeze)
374
                ex_insn <= #1 {`OR32_NOP, 26'h000_4444};
375
        else if (!ex_freeze) begin
376 168 lampret
                ex_insn <= #1 id_insn;
377 203 lampret
`ifdef OR1200_VERBOSE
378
// synopsys translate_off
379 168 lampret
                $display("%t: ex_insn <= %h", $time, id_insn);
380 203 lampret
// synopsys translate_on
381
`endif
382 168 lampret
        end
383
end
384
 
385
//
386
// Instruction latch in wb_insn
387
//
388
always @(posedge clk or posedge rst) begin
389
        if (rst) begin
390
                wb_insn[31:26] <= #1 `OR32_NOP;
391
                wb_insn[25:0] <= #1 26'd0;
392
        end
393 205 lampret
        else if (!wb_freeze) begin
394 168 lampret
                wb_insn <= #1 ex_insn;
395
        end
396
end
397
 
398
//
399
// Decode of sel_imm
400
//
401
always @(posedge clk or posedge rst) begin
402
        if (rst)
403
                sel_imm <= #1 1'b0;
404 205 lampret
        else if (!id_freeze) begin
405 168 lampret
          case (if_insn[31:26])         // synopsys full_case parallel_case
406
 
407
            // j.jalr
408
            `OR32_JALR:
409
              sel_imm <= #1 `off;
410
 
411
            // l.jr
412
            `OR32_JR:
413
              sel_imm <= #1 `off;
414
 
415
            // l.rfe
416
            `OR32_RFE:
417
              sel_imm <= #1 `off;
418
 
419
            // l.mfspr
420
            `OR32_MFSPR:
421
              sel_imm <= #1 `off;
422
 
423
            // l.mtspr
424
            `OR32_MTSPR:
425
              sel_imm <= #1 `off;
426
 
427
            // l.sys, l.brk and all three sync insns
428
            `OR32_XSYNC:
429
              sel_imm <= #1 `off;
430
 
431
            // l.sw
432
            `OR32_SW:
433
              sel_imm <= #1 `off;
434
 
435
            // l.sb
436
            `OR32_SB:
437
              sel_imm <= #1 `off;
438
 
439
            // l.sh
440
            `OR32_SH:
441
              sel_imm <= #1 `off;
442
 
443
            // ALU instructions except the one with immediate
444
            `OR32_ALU:
445
              sel_imm <= #1 `off;
446
 
447
            // SFXX instructions
448
            `OR32_SFXX:
449
              sel_imm <= #1 `off;
450
 
451
            // l.nop
452
            `OR32_NOP:
453
              sel_imm <= #1 `off;
454
 
455
            // All instructions with immediates
456
            default: begin
457
              sel_imm <= #1 `on;
458
            end
459
 
460
          endcase
461
 
462
        end
463
end
464
 
465
 
466
//
467
// Decode of alu_op
468
//
469
always @(posedge clk or posedge rst_or_except_flushpipe) begin
470
        if (rst_or_except_flushpipe)
471
                alu_op <= #1 `ALUOP_NOP;
472 205 lampret
        else if (!ex_freeze & id_freeze)
473
                alu_op <= #1 `ALUOP_NOP;
474
        else if (!ex_freeze) begin
475 168 lampret
          case (id_insn[31:26])         // synopsys full_case parallel_case
476
 
477
            // l.j
478
            `OR32_J:
479
              alu_op <= #1 `ALUOP_IMM;
480
 
481
            // j.jal
482
            `OR32_JAL:
483
              alu_op <= #1 `ALUOP_IMM;
484
 
485
            // j.jalr
486
            `OR32_JALR:
487
              alu_op <= #1 `ALUOP_OR;
488
 
489
            // l.jr
490
            `OR32_JR:
491
              alu_op <= #1 `ALUOP_ADD;
492
 
493
            // l.bnf
494
            `OR32_BNF:
495
              alu_op <= #1 `ALUOP_ADD;
496
 
497
            // l.bf
498
            `OR32_BF:
499
              alu_op <= #1 `ALUOP_ADD;
500
 
501
            // l.rfe
502
            `OR32_RFE:
503
              alu_op <= #1 `ALUOP_NOP;
504
 
505
            // l.movhi
506
            `OR32_MOVHI:
507
              alu_op <= #1 `ALUOP_MOVHI;
508
 
509
            // l.mfspr
510
            `OR32_MFSPR:
511
              alu_op <= #1 `ALUOP_MFSR;
512
 
513
            // l.mtspr
514
            `OR32_MTSPR:
515
              alu_op <= #1 `ALUOP_MTSR;
516
 
517
            // l.sys, l.brk and all three sync insns
518
            `OR32_XSYNC:
519
              alu_op <= #1 `ALUOP_NOP;
520
 
521
            // l.lwz
522
            `OR32_LWZ:
523
              alu_op <= #1 `ALUOP_ADD;
524
 
525
            // l.lbz
526
            `OR32_LBZ:
527
              alu_op <= #1 `ALUOP_ADD;
528
 
529
            // l.lbs
530
            `OR32_LBS:
531
              alu_op <= #1 `ALUOP_ADD;
532
 
533
            // l.lhz
534
            `OR32_LHZ:
535
              alu_op <= #1 `ALUOP_ADD;
536
 
537
            // l.lhs
538
            `OR32_LHS:
539
              alu_op <= #1 `ALUOP_ADD;
540
 
541
            // l.addi
542
            `OR32_ADDI:
543
              alu_op <= #1 `ALUOP_ADD;
544
 
545
            // l.addic
546
            `OR32_ADDIC:
547
              alu_op <= #1 `ALUOP_ADD;
548
 
549
            // l.andi
550
            `OR32_ANDI:
551
              alu_op <= #1 `ALUOP_AND;
552
 
553
            // l.ori
554
            `OR32_ORI:
555
              alu_op <= #1 `ALUOP_OR;
556
 
557
            // l.xori
558
            `OR32_XORI:
559
              alu_op <= #1 `ALUOP_XOR;
560
 
561
            // l.muli
562
            `OR32_MULI:
563
              alu_op <= #1 `ALUOP_MUL;
564
 
565
            // l.maci
566
            `OR32_MACI:
567
              alu_op <= #1 `ALUOP_MAC;
568
 
569
            // Shift and rotate insns with immediate
570
            `OR32_SH_ROTI:
571
              alu_op <= #1 `ALUOP_SHROT;
572
 
573
            // SFXX insns with immediate
574
            `OR32_SFXXI:
575
              alu_op <= #1 `ALUOP_COMP;
576
 
577
            // l.sw
578
            `OR32_SW:
579
              alu_op <= #1 `ALUOP_ADD;
580
 
581
            // l.sb
582
            `OR32_SB:
583
              alu_op <= #1 `ALUOP_ADD;
584
 
585
            // l.sh
586
            `OR32_SH:
587
              alu_op <= #1 `ALUOP_ADD;
588
 
589
            // ALU instructions except the one with immediate
590
            `OR32_ALU:
591
              alu_op <= #1 id_insn[3:0];
592
 
593
            // SFXX instructions
594
            `OR32_SFXX:
595
              alu_op <= #1 `ALUOP_COMP;
596
 
597
            // l.nop
598
            `OR32_NOP:
599
              alu_op <= #1 `ALUOP_NOP;
600
 
601
            // Illegal and OR1200 unsupported instructions
602
            default: begin
603
              alu_op <= #1 `ALUOP_NOP;
604 203 lampret
`ifdef OR1200_VERBOSE
605
// synopsys translate_off
606 168 lampret
              $display("%t: Illegal insn.... insn %h", $time, id_insn);
607 203 lampret
// synopsys translate_on
608
`endif
609 168 lampret
            end
610
 
611
          endcase
612
 
613
        end
614
end
615
 
616
//
617
// Decode of shrot_op
618
//
619
always @(posedge clk or posedge rst_or_except_flushpipe) begin
620
        if (rst_or_except_flushpipe)
621
                shrot_op <= #1 `SHROTOP_NOP;
622 205 lampret
        else if (!ex_freeze & id_freeze)
623
                shrot_op <= #1 `SHROTOP_NOP;
624
        else if (!ex_freeze) begin
625 168 lampret
                shrot_op <= #1 id_insn[`SHROTOP_POS];
626
        end
627
end
628
 
629
//
630
// Decode of rfwb_op
631
//
632
always @(posedge clk or posedge rst_or_except_flushpipe) begin
633
        if (rst_or_except_flushpipe)
634
                rfwb_op <= #1 `RFWBOP_NOP;
635 205 lampret
        else  if (!ex_freeze & id_freeze)
636
                rfwb_op <= #1 `RFWBOP_NOP;
637
        else  if (!ex_freeze) begin
638 168 lampret
                case (id_insn[31:26])           // synopsys full_case parallel_case
639
 
640
                  // j.jal
641
                  `OR32_JAL:
642
                    rfwb_op <= #1 `RFWBOP_LR;
643
 
644
                  // j.jalr
645
                  `OR32_JALR:
646
                    rfwb_op <= #1 `RFWBOP_LR;
647
 
648
                  // l.movhi
649
                  `OR32_MOVHI:
650
                    rfwb_op <= #1 `RFWBOP_ALU;
651
 
652
                  // l.mfspr
653
                  `OR32_MFSPR:
654
                    rfwb_op <= #1 `RFWBOP_SPRS;
655
 
656
                  // l.lwz
657
                  `OR32_LWZ:
658
                    rfwb_op <= #1 `RFWBOP_LSU;
659
 
660
                  // l.lbz
661
                  `OR32_LBZ:
662
                    rfwb_op <= #1 `RFWBOP_LSU;
663
 
664
                  // l.lbs
665
                  `OR32_LBS:
666
                    rfwb_op <= #1 `RFWBOP_LSU;
667
 
668
                  // l.lhz
669
                  `OR32_LHZ:
670
                    rfwb_op <= #1 `RFWBOP_LSU;
671
 
672
                  // l.lhs
673
                  `OR32_LHS:
674
                    rfwb_op <= #1 `RFWBOP_LSU;
675
 
676
                  // l.addi
677
                  `OR32_ADDI:
678
                    rfwb_op <= #1 `RFWBOP_ALU;
679
 
680
                  // l.addic
681
                  `OR32_ADDIC:
682
                    rfwb_op <= #1 `RFWBOP_ALU;
683
 
684
                  // l.andi
685
                  `OR32_ANDI:
686
                    rfwb_op <= #1 `RFWBOP_ALU;
687
 
688
                  // l.ori
689
                  `OR32_ORI:
690
                    rfwb_op <= #1 `RFWBOP_ALU;
691
 
692
                  // l.xori
693
                  `OR32_XORI:
694
                    rfwb_op <= #1 `RFWBOP_ALU;
695
 
696
                  // l.muli
697
                  `OR32_MULI:
698
                    rfwb_op <= #1 `RFWBOP_ALU;
699
 
700
                  // l.maci
701
                  `OR32_MACI:
702
                    rfwb_op <= #1 `RFWBOP_ALU;
703
 
704
                  // Shift and rotate insns with immediate
705
                  `OR32_SH_ROTI:
706
                    rfwb_op <= #1 `RFWBOP_ALU;
707
 
708
                  // ALU instructions except the one with immediate
709
                  `OR32_ALU:
710
                    rfwb_op <= #1 `RFWBOP_ALU;
711
 
712
                  // Instructions w/o register-file write-back
713
                  default: begin
714
                    rfwb_op <= #1 `RFWBOP_NOP;
715
                  end
716
 
717
                endcase
718
        end
719
end
720
 
721
//
722
// Decode of pre_branch_op
723
//
724
always @(posedge clk or posedge rst_or_except_flushpipe) begin
725
        if (rst_or_except_flushpipe)
726
                pre_branch_op <= #1 `BRANCHOP_NOP;
727 205 lampret
        else if (!id_freeze) begin
728 168 lampret
                case (if_insn[31:26])           // synopsys full_case parallel_case
729
 
730
                  // l.j
731
                  `OR32_J:
732
                    pre_branch_op <= #1 `BRANCHOP_BAL;
733
 
734
                  // j.jal
735
                  `OR32_JAL:
736
                    pre_branch_op <= #1 `BRANCHOP_BAL;
737
 
738
                  // j.jalr
739
                  `OR32_JALR:
740
                    pre_branch_op <= #1 `BRANCHOP_JR;
741
 
742
                  // l.jr
743
                  `OR32_JR:
744
                    pre_branch_op <= #1 `BRANCHOP_JR;
745
 
746
                  // l.bnf
747
                  `OR32_BNF:
748
                    pre_branch_op <= #1 `BRANCHOP_BNF;
749
 
750
                  // l.bf
751
                  `OR32_BF:
752
                    pre_branch_op <= #1 `BRANCHOP_BF;
753
 
754
                  // l.rfe
755
                  `OR32_RFE:
756
                    pre_branch_op <= #1 `BRANCHOP_RFE;
757
 
758
                  // Non branch instructions
759
                  default: begin
760
                    pre_branch_op <= #1 `BRANCHOP_NOP;
761
                  end
762
                endcase
763
        end
764
end
765
 
766
//
767
// Generation of branch_op
768
//
769
always @(posedge clk or posedge rst_or_except_flushpipe) begin
770
        if (rst_or_except_flushpipe)
771
                branch_op <= #1 `BRANCHOP_NOP;
772 205 lampret
        else if (!ex_freeze & id_freeze)
773
                branch_op <= #1 `BRANCHOP_NOP;
774
        else if (!ex_freeze) begin
775 168 lampret
                branch_op <= #1 pre_branch_op;
776
        end
777
end
778
 
779
//
780
// Decode of lsu_op
781
//
782
always @(posedge clk or posedge rst_or_except_flushpipe) begin
783
        if (rst_or_except_flushpipe)
784
                lsu_op <= #1 `LSUOP_NOP;
785 205 lampret
        else if (!ex_freeze & id_freeze)
786
                lsu_op <= #1 `LSUOP_NOP;
787
        else if (!ex_freeze)  begin
788 168 lampret
          case (id_insn[31:26])         // synopsys full_case parallel_case
789
 
790
            // l.lwz
791
            `OR32_LWZ:
792
              lsu_op <= #1 `LSUOP_LWZ;
793
 
794
            // l.lbz
795
            `OR32_LBZ:
796
              lsu_op <= #1 `LSUOP_LBZ;
797
 
798
            // l.lbs
799
            `OR32_LBS:
800
              lsu_op <= #1 `LSUOP_LBS;
801
 
802
            // l.lhz
803
            `OR32_LHZ:
804
              lsu_op <= #1 `LSUOP_LHZ;
805
 
806
            // l.lhs
807
            `OR32_LHS:
808
              lsu_op <= #1 `LSUOP_LHS;
809
 
810
            // l.sw
811
            `OR32_SW:
812
              lsu_op <= #1 `LSUOP_SW;
813
 
814
            // l.sb
815
            `OR32_SB:
816
              lsu_op <= #1 `LSUOP_SB;
817
 
818
            // l.sh
819
            `OR32_SH:
820
              lsu_op <= #1 `LSUOP_SH;
821
 
822
            // Non load/store instructions
823
            default: begin
824
              lsu_op <= #1 `LSUOP_NOP;
825
            end
826
          endcase
827
        end
828
end
829
 
830
//
831
// Decode of comp_op
832
//
833
always @(posedge clk or posedge rst_or_except_flushpipe) begin
834
        if (rst_or_except_flushpipe)
835
                comp_op <= #1 4'd0;
836 205 lampret
        else if (!ex_freeze & id_freeze)
837
                comp_op <= #1 4'd0;
838
        else if (!ex_freeze) begin
839 168 lampret
                comp_op <= #1 id_insn[24:21];
840
        end
841
end
842
 
843
//
844
// Decode of l.sys
845
//
846
always @(posedge clk or posedge rst) begin
847
        if (rst)
848
                sig_syscall <= #1 1'b0;
849 205 lampret
        else if (!wb_freeze) begin
850 203 lampret
`ifdef OR1200_VERBOSE
851 168 lampret
// synopsys translate_off
852
                if (wb_insn[31:24] == {`OR32_XSYNC, 2'b00})
853
                        $display("Generating sig_syscall");
854
// synopsys translate_on
855 203 lampret
`endif
856 170 lampret
//              sig_syscall <= #1 (wb_insn[31:24] == {`OR32_XSYNC, 2'b00});
857 168 lampret
        end
858
end
859
 
860
endmodule

powered by: WebSVN 2.1.0

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