Skip to content

Commit 30695de

Browse files
committed
refactor: use common params to simplify the codes
1 parent 6294041 commit 30695de

File tree

6 files changed

+31
-46
lines changed

6 files changed

+31
-46
lines changed

rtl/tc_l2/src/main/scala/common/ConstVal.scala

Lines changed: 0 additions & 10 deletions
This file was deleted.

rtl/tc_l2/src/main/scala/core/TreeCoreL2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class TreeCoreL2 extends Module with InstConfig {
6262

6363
// special judge
6464
protected val lsStall = RegEnable(cyc1, false.B, io.globalEn) || RegEnable(cyc2, false.B, io.globalEn)
65-
protected val ldDataReg = RegInit(0.U(64.W))
65+
protected val ldDataReg = RegInit(0.U(XLen.W))
6666

6767
when(io.globalEn) {
6868
when(cyc1) {

rtl/tc_l2/src/main/scala/core/exec/CSRReg.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ class CSRReg extends Module with InstConfig {
4141
)
4242
)
4343

44-
protected val mretVis = io.inst === instMRET
45-
protected val ecallVis = io.inst === instECALL
46-
protected val zimm = ZeroExt(io.inst(19, 15), XLen)
47-
protected val addr = io.inst(31, 20)
48-
44+
protected val zimm = ZeroExt(io.inst(19, 15), XLen)
45+
protected val addr = io.inst(31, 20)
46+
protected val mretVis = io.inst === instMRET
47+
protected val ecallVis = io.inst === instECALL
4948
protected val mhartidVis = addr === mhartidAddr
5049
protected val mstatusVis = addr === mstatusAddr
5150
protected val mieVis = addr === mieAddr

rtl/tc_l2/src/main/scala/core/if/BPU.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class BPU extends Module with InstConfig {
99
val io = IO(new Bundle {
1010
val branchInfo = Flipped(new BRANCHIO)
1111
// predictor interface
12-
val lookupPc = Input(UInt(ConstVal.AddrLen.W))
12+
val lookupPc = Input(UInt(XLen.W))
1313
val predTaken = Output(Bool())
14-
val predTgt = Output(UInt(ConstVal.AddrLen.W))
14+
val predTgt = Output(UInt(XLen.W))
1515
val predIdx = Output(UInt(GHRLen.W))
1616
})
1717

rtl/tc_l2/src/main/scala/core/if/BTB.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package treecorel2
33
import chisel3._
44
import chisel3.util._
55

6-
class BTBLine extends Bundle {
7-
val pc = UInt(ConstVal.AddrLen.W)
8-
val tgt = UInt(ConstVal.AddrLen.W)
6+
class BTBLine extends Bundle with IOConfig {
7+
val pc = UInt(XLen.W)
8+
val tgt = UInt(XLen.W)
99
val jump = Bool()
1010
}
1111

@@ -14,13 +14,13 @@ class BTB extends Module with InstConfig {
1414
// branch info (from idu)
1515
val branch = Input(Bool())
1616
val jump = Input(Bool())
17-
val pc = Input(UInt(ConstVal.AddrLen.W))
18-
val tgt = Input(UInt(ConstVal.AddrLen.W))
17+
val pc = Input(UInt(XLen.W))
18+
val tgt = Input(UInt(XLen.W))
1919
// BTB lookup interface
2020
val lookupBranch = Output(Bool())
2121
val lookupJump = Output(Bool())
22-
val lookupPc = Input(UInt(ConstVal.AddrLen.W))
23-
val lookupTgt = Output(UInt(ConstVal.AddrLen.W))
22+
val lookupPc = Input(UInt(XLen.W))
23+
val lookupTgt = Output(UInt(XLen.W))
2424
})
2525

2626
// definitions of BTB lines and valid bits

rtl/tc_l2/src/main/scala/core/ma/LSU.scala

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class LSU extends Module with InstConfig {
2323

2424
protected val ldSize = MuxLookup(
2525
io.isa,
26-
0.U(3.W),
26+
0.U(LDSize.W),
2727
Seq(
28-
instLH -> 1.U(3.W),
29-
instLHU -> 1.U(3.W),
30-
instLW -> 2.U(3.W),
31-
instLWU -> 2.U(3.W),
32-
instLD -> 3.U(3.W)
28+
instLH -> 1.U(LDSize.W),
29+
instLHU -> 1.U(LDSize.W),
30+
instLW -> 2.U(LDSize.W),
31+
instLWU -> 2.U(LDSize.W),
32+
instLD -> 3.U(LDSize.W)
3333
)
3434
)
3535
io.ld.size := ldSize
@@ -67,26 +67,22 @@ class LSU extends Module with InstConfig {
6767
)
6868
)
6969

70-
protected val sdMask = MuxLookup(
70+
val sdMask = MuxLookup(
7171
io.isa,
72-
0.U(8.W), // NOTE: important!!!
72+
0.U(MaskLen.W), // NOTE: important!!!
7373
Seq(
74-
instSD -> "b1111_1111".U(8.W),
75-
instSW -> ("b0000_1111".U(8.W) << io.sd.addr(2, 0)),
76-
instSH -> ("b0000_0011".U(8.W) << io.sd.addr(2, 0)),
77-
instSB -> ("b0000_0001".U(8.W) << io.sd.addr(2, 0))
74+
instSD -> "b1111_1111".U(MaskLen.W),
75+
instSW -> ("b0000_1111".U(MaskLen.W) << io.sd.addr(2, 0)),
76+
instSH -> ("b0000_0011".U(MaskLen.W) << io.sd.addr(2, 0)),
77+
instSB -> ("b0000_0001".U(MaskLen.W) << io.sd.addr(2, 0))
7878
)
7979
)
8080

81-
protected val sdMask0 = Mux(sdMask(0).asBool(), "hff".U(8.W), 0.U(8.W))
82-
protected val sdMask1 = Mux(sdMask(1).asBool(), "hff".U(8.W), 0.U(8.W))
83-
protected val sdMask2 = Mux(sdMask(2).asBool(), "hff".U(8.W), 0.U(8.W))
84-
protected val sdMask3 = Mux(sdMask(3).asBool(), "hff".U(8.W), 0.U(8.W))
85-
protected val sdMask4 = Mux(sdMask(4).asBool(), "hff".U(8.W), 0.U(8.W))
86-
protected val sdMask5 = Mux(sdMask(5).asBool(), "hff".U(8.W), 0.U(8.W))
87-
protected val sdMask6 = Mux(sdMask(6).asBool(), "hff".U(8.W), 0.U(8.W))
88-
protected val sdMask7 = Mux(sdMask(7).asBool(), "hff".U(8.W), 0.U(8.W))
89-
protected val extenMask = Cat(sdMask7, sdMask6, sdMask5, sdMask4, sdMask3, sdMask2, sdMask1, sdMask0)
81+
val tmpMask = Wire(Vec(8, UInt((XLen / 8).W)))
82+
for (i <- 0 until 8) {
83+
tmpMask(i) := Mux(sdMask(i).asBool(), "hff".U((XLen / 8).W), 0.U((XLen / 8).W))
84+
}
85+
protected val extenMask = tmpMask.asUInt()
9086

9187
io.sd.data := storeData & extenMask
9288
io.sd.mask := sdMask

0 commit comments

Comments
 (0)