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

Subversion Repositories or1k-cf

[/] [or1k-cf/] [trunk/] [src/] [id.cf] - Blame information for rev 6

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

Line No. Rev Author Line
1 2 kenr
(*
2
     Instruction decoder for OpenRisc 1200
3
 
4
     Copyright 2004 Ken Rose
5
     All rights reserved
6
*)
7
 
8
-T
9
is
10
 
11
component T
12
  +IR
13
  -WB_write_what -WB_write_enable -WB_Dest -ALUctl
14
  -MEMWriteEnable -LatchFlag -CalcFlag -MemOffset -UseIMM -IM
15
  -RunFetch -SysCall -IllInstr -SPROffset -LatchSPR
16
with
17
  MulStall
18
is
19
 
20
  IM <- ((IR'[15]) '#' 17) '++' (IR'[14:0])
21
 
22 3 kenr
  MEMWriteEnable <- (IR'[31:26] '==' '110101') 'then' '01' (* write word *)
23
                'else' (IR'[31:26] '==' '110110') 'then' '10' (* write byte *)
24
                'else' (IR'[31:26] '==' '110111') 'then' '11' (* write half *)
25
                'else'                                '00' (* Don't write *)
26 2 kenr
 
27
  (* Control for writeback mux.  Must match writeback
28
       "0000"   ALU output
29
       "0001"   Zero-extended memory word
30
       "0010"   Sign-extended memory word
31
       "0011"   Zero-extended memory byte
32
       "0100"   Sign-extended memory byte
33
       "0101"   Zero-extended memory halfword
34
       "0110"   Sign-extended memory halfword
35
       "0111"   Immediate data in high half
36
       "1000"   Data from SPR
37
  *)
38 3 kenr
  WB_write_what <-  IR'[31:26] '==' '100111' 'then' '0000'      (* l.addi *)
39
                'else' IR'[31:29] '==' '100'    'then' '0' '++' IR'[28:26] (* loads *)
40
                'else' IR'[31:26] '==' '000110' 'then' '0111'      (* l.movhi *)
41
                'else' IR'[31:26] '==' '101101' 'then' '1000'      (* l.mfspr *)
42
                'else'                              '0000'
43 2 kenr
 
44
  (* Next is reg file write enable *)
45
  WB_write_enable <-   IR'[31:26] '==' '000110'  (* movhi *)
46
                   '|' IR'[31:26] '==' '101101'  (* mfspr *)
47
                   '|' IR'[31:30] '==' '10'     (* loads & immediate ALU *)
48
                   '|' IR'[31:26] '==' '111000' (* register ALU *)
49
 
50
 
51
  (* Select an immediate operand *)
52
  UseIMM <- IR'[31:29] '==' '101' '|' IR'[31:26] '==' '100111'
53
 
54
  (* Send the memory offset to the MEM unit *)
55 3 kenr
  MemOffset <- IR'[31:29] '==' '110' 'then' ((IR'[25]) '#' 17) '++' (IR'[24:21 10:0])
56
                                     'else' ((IR'[15]) '#' 17) '++' (IR'[14:0])
57 2 kenr
 
58
  (* Send the SPR offset to the SPR code *)
59
  LatchSPR <- IR'[31:26] '==' '110000'
60 3 kenr
  SPROffset <- LatchSPR 'then' IR'[25:21 10:0] 'else' IR'[15:0]
61 2 kenr
 
62
  (* Control ALU *)
63
  local RRctl RIctl is
64 3 kenr
    RRctl <- IR'[9:6 3:0] '==' '00001000' 'then' '0000'   (* sll *)
65
         'else' IR'[9:6 3:0] '==' '00011000' 'then' '0001'   (* srl *)
66
         'else' IR'[9:6 3:0] '==' '00011000' 'then' '0010'   (* sra *)
67
         'else' IR'[9:8 3:0] '==' '000000'   'then' '0011'   (* add *)
68
         'else' IR'[9:8 3:0] '==' '000001'   'then' '0100'   (* addc *)
69
         'else' IR'[9:8 3:0] '==' '000010'   'then' '0101'   (* sub *)
70
         'else' IR'[9:8 3:0] '==' '000011'   'then' '0110'   (* and *)
71
         'else' IR'[9:8 3:0] '==' '000100'   'then' '0111'   (* or *)
72
         'else' IR'[9:8 3:0] '==' '000101'   'then' '1000'   (* xor *)
73
         'else' IR'[9:8 3:0] '==' '110110'   'then' '1001'   (* mul *)
74
         'else' IR'[9:8 3:0] '==' '111011'   'then' '1010'   (* mulu *)
75
         'else'                                  '0011'   (* default add *)
76 2 kenr
 
77 3 kenr
    RIctl <- IR'[31:26]     '==' '100111'   'then' '0011'   (* addi *)
78
         'else' IR'[31:26]     '==' '101001'   'then' '0110'   (* andi *)
79
         'else' IR'[31:26]     '==' '101010'   'then' '0111'   (* ori *)
80
         'else' IR'[31:26]     '==' '101011'   'then' '1000'   (* xori *)
81
         'else' IR'[31:26]     '==' '101100'   'then' '1001'   (* muli *)
82
         'else' IR'[31:26 7 6] '==' '10111000' 'then' '0000'   (* slli *)
83
         'else' IR'[31:26 7 6] '==' '10111001' 'then' '0001'   (* srli *)
84
         'else' IR'[31:26 7 6] '==' '10111010' 'then' '0010'   (* srai *)
85
         'else' IR'[31:26 7 6] '==' '10111011' 'then' '1011'   (* rori *)
86
         'else'                                    '0011'   (* default add *)
87 2 kenr
 
88 3 kenr
    ALUctl <- IR'[31:26] '==' '111000' 'then' RRctl 'else' RIctl
89 2 kenr
  end
90
  MulStall <- ALUctl '==' '1001' '|' ALUctl '==' '1010'
91
  (*
92 3 kenr
  {StateMachine [
93 2 kenr
                  [ "0" 0 0 "1" ]
94
                  [ "1" 0 1 "0" ]
95
                  [ "-" 1 2 "0" ]
96
                  [ "-" 2 0 "1" ]
97 3 kenr
                 ] MulStall RunFetch}
98 2 kenr
    *) RunFetch <- '1'
99
 
100
  (* Control the flag bit *)
101
  LatchFlag <- IR'[31:26] '==' '111001'
102
  CalcFlag <- IR'[24:21]
103
 
104
  (* Illegal Instruction *)
105
  IllInstr <- '0'
106
 
107
  (* System call instruction *)
108
  SysCall <- IR'[31:16] '==' '0x2000'
109
 
110
  (* If there's a register writeback, the register number is here. *)
111
  WB_Dest <- IR'[25:21]
112
 
113
end
114
 

powered by: WebSVN 2.1.0

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