Skip to content

Commit 44b0b82

Browse files
refactor Consts to chisel3. (#3052)
1 parent b308e0c commit 44b0b82

File tree

1 file changed

+50
-49
lines changed

1 file changed

+50
-49
lines changed

src/main/scala/rocket/Consts.scala

+50-49
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,81 @@
22

33
package freechips.rocketchip.rocket.constants
44

5-
import Chisel._
5+
import chisel3._
6+
import chisel3.util._
67
import freechips.rocketchip.util._
78

89
trait ScalarOpConstants {
910
val SZ_BR = 3
1011
def BR_X = BitPat("b???")
11-
def BR_EQ = UInt(0, 3)
12-
def BR_NE = UInt(1, 3)
13-
def BR_J = UInt(2, 3)
14-
def BR_N = UInt(3, 3)
15-
def BR_LT = UInt(4, 3)
16-
def BR_GE = UInt(5, 3)
17-
def BR_LTU = UInt(6, 3)
18-
def BR_GEU = UInt(7, 3)
12+
def BR_EQ = 0.U(3.W)
13+
def BR_NE = 1.U(3.W)
14+
def BR_J = 2.U(3.W)
15+
def BR_N = 3.U(3.W)
16+
def BR_LT = 4.U(3.W)
17+
def BR_GE = 5.U(3.W)
18+
def BR_LTU = 6.U(3.W)
19+
def BR_GEU = 7.U(3.W)
1920

2021
def A1_X = BitPat("b??")
21-
def A1_ZERO = UInt(0, 2)
22-
def A1_RS1 = UInt(1, 2)
23-
def A1_PC = UInt(2, 2)
22+
def A1_ZERO = 0.U(2.W)
23+
def A1_RS1 = 1.U(2.W)
24+
def A1_PC = 2.U(2.W)
2425

2526
def IMM_X = BitPat("b???")
26-
def IMM_S = UInt(0, 3)
27-
def IMM_SB = UInt(1, 3)
28-
def IMM_U = UInt(2, 3)
29-
def IMM_UJ = UInt(3, 3)
30-
def IMM_I = UInt(4, 3)
31-
def IMM_Z = UInt(5, 3)
27+
def IMM_S = 0.U(3.W)
28+
def IMM_SB = 1.U(3.W)
29+
def IMM_U = 2.U(3.W)
30+
def IMM_UJ = 3.U(3.W)
31+
def IMM_I = 4.U(3.W)
32+
def IMM_Z = 5.U(3.W)
3233

3334
def A2_X = BitPat("b??")
34-
def A2_ZERO = UInt(0, 2)
35-
def A2_SIZE = UInt(1, 2)
36-
def A2_RS2 = UInt(2, 2)
37-
def A2_IMM = UInt(3, 2)
35+
def A2_ZERO = 0.U(2.W)
36+
def A2_SIZE = 1.U(2.W)
37+
def A2_RS2 = 2.U(2.W)
38+
def A2_IMM = 3.U(2.W)
3839

3940
def X = BitPat("b?")
4041
def N = BitPat("b0")
4142
def Y = BitPat("b1")
4243

4344
val SZ_DW = 1
4445
def DW_X = X
45-
def DW_32 = Bool(false)
46-
def DW_64 = Bool(true)
46+
def DW_32 = false.B
47+
def DW_64 = true.B
4748
def DW_XPR = DW_64
4849
}
4950

5051
trait MemoryOpConstants {
5152
val NUM_XA_OPS = 9
5253
val M_SZ = 5
5354
def M_X = BitPat("b?????");
54-
def M_XRD = UInt("b00000"); // int load
55-
def M_XWR = UInt("b00001"); // int store
56-
def M_PFR = UInt("b00010"); // prefetch with intent to read
57-
def M_PFW = UInt("b00011"); // prefetch with intent to write
58-
def M_XA_SWAP = UInt("b00100");
59-
def M_FLUSH_ALL = UInt("b00101") // flush all lines
60-
def M_XLR = UInt("b00110");
61-
def M_XSC = UInt("b00111");
62-
def M_XA_ADD = UInt("b01000");
63-
def M_XA_XOR = UInt("b01001");
64-
def M_XA_OR = UInt("b01010");
65-
def M_XA_AND = UInt("b01011");
66-
def M_XA_MIN = UInt("b01100");
67-
def M_XA_MAX = UInt("b01101");
68-
def M_XA_MINU = UInt("b01110");
69-
def M_XA_MAXU = UInt("b01111");
70-
def M_FLUSH = UInt("b10000") // write back dirty data and cede R/W permissions
71-
def M_PWR = UInt("b10001") // partial (masked) store
72-
def M_PRODUCE = UInt("b10010") // write back dirty data and cede W permissions
73-
def M_CLEAN = UInt("b10011") // write back dirty data and retain R/W permissions
74-
def M_SFENCE = UInt("b10100") // SFENCE.VMA
75-
def M_HFENCEV = UInt("b10101") // HFENCE.VVMA
76-
def M_HFENCEG = UInt("b10110") // HFENCE.GVMA
77-
def M_WOK = UInt("b10111") // check write permissions but don't perform a write
78-
def M_HLVX = UInt("b10000") // HLVX instruction
55+
def M_XRD = "b00000".U; // int load
56+
def M_XWR = "b00001".U; // int store
57+
def M_PFR = "b00010".U; // prefetch with intent to read
58+
def M_PFW = "b00011".U; // prefetch with intent to write
59+
def M_XA_SWAP = "b00100".U
60+
def M_FLUSH_ALL = "b00101".U // flush all lines
61+
def M_XLR = "b00110".U
62+
def M_XSC = "b00111".U
63+
def M_XA_ADD = "b01000".U
64+
def M_XA_XOR = "b01001".U
65+
def M_XA_OR = "b01010".U
66+
def M_XA_AND = "b01011".U
67+
def M_XA_MIN = "b01100".U
68+
def M_XA_MAX = "b01101".U
69+
def M_XA_MINU = "b01110".U
70+
def M_XA_MAXU = "b01111".U
71+
def M_FLUSH = "b10000".U // write back dirty data and cede R/W permissions
72+
def M_PWR = "b10001".U // partial (masked) store
73+
def M_PRODUCE = "b10010".U // write back dirty data and cede W permissions
74+
def M_CLEAN = "b10011".U // write back dirty data and retain R/W permissions
75+
def M_SFENCE = "b10100".U // SFENCE.VMA
76+
def M_HFENCEV = "b10101".U // HFENCE.VVMA
77+
def M_HFENCEG = "b10110".U // HFENCE.GVMA
78+
def M_WOK = "b10111".U // check write permissions but don't perform a write
79+
def M_HLVX = "b10000".U // HLVX instruction
7980

8081
def isAMOLogical(cmd: UInt) = cmd.isOneOf(M_XA_SWAP, M_XA_XOR, M_XA_OR, M_XA_AND)
8182
def isAMOArithmetic(cmd: UInt) = cmd.isOneOf(M_XA_ADD, M_XA_MIN, M_XA_MAX, M_XA_MINU, M_XA_MAXU)

0 commit comments

Comments
 (0)