Skip to content

Commit 6275dd5

Browse files
committed
refactor: add inst trait to share common vars
1 parent 797c5a3 commit 6275dd5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

rtl/tc_l3/src/main/scala/core/if/Regfile.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ package treecorel3
33
import chisel._
44
import chisel.uitl._
55

6-
class RegFileIO(implicit p: Parameters) extends Bundle {
7-
val raddr1 = Input(UInt(5.W))
8-
val raddr2 = Input(UInt(5.W))
9-
val rdata1 = Output(UInt(xlen.W))
10-
val rdata2 = Output(UInt(xlen.W))
6+
class RegFileIO extends Bundle with IOConfig {
7+
val raddr1 = Input(UInt(RegfileLen.W))
8+
val raddr2 = Input(UInt(RegfileLen.W))
9+
val rdata1 = Output(UInt(XLen.W))
10+
val rdata2 = Output(UInt(XLen.W))
1111
val wen = Input(Bool())
12-
val waddr = Input(UInt(5.W))
13-
val wdata = Input(UInt(xlen.W))
12+
val waddr = Input(UInt(RegfileLen.W))
13+
val wdata = Input(UInt(XLen.W))
1414
}
1515

16-
class RegFile(implicit val p: Parameters) extends Module {
17-
val io = IO(new RegFileIO)
18-
val regs = Mem(32, UInt(xlen.W)) // NOTE: right?
19-
io.rdata1 := Mux(io.raddr1.orR, regs(io.raddr1), 0.U)
20-
io.rdata2 := Mux(io.raddr2.orR, regs(io.raddr2), 0.U)
16+
class RegFile extends Module with InstConfig {
17+
val io = IO(new RegFileIO)
18+
protected val regs = Mem(RegfileNum, UInt(XLen.W))
19+
io.rdata1 := Mux(io.raddr1.orR, regs(io.raddr1), 0.U(XLen.W))
20+
io.rdata2 := Mux(io.raddr2.orR, regs(io.raddr2), 0.U(XLen.W))
2121
when(io.wen & io.waddr.orR) {
2222
regs(io.waddr) := io.wdata
2323
}

0 commit comments

Comments
 (0)