Skip to content

Commit 65b8b67

Browse files
committed
refactor: add io trait to share common vars
1 parent 6275dd5 commit 65b8b67

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

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

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

6-
class ImmGenIO(implicit p: Parameters) extends Bundle {
7-
val inst = Input(UInt(xlen.W))
6+
class ImmGenIO extends Bundle with IOConfig {
7+
val inst = Input(UInt(XLen.W))
88
val sel = Input(UInt(3.W))
9-
val out = Output(UInt(xlen.W))
9+
val out = Output(UInt(XLen.W))
1010
}
1111

12-
class ImmGen(implicit p: Parameters) extends Module {
13-
val io = IO(new ImmGenIO)
14-
val Iimm = io.inst(31, 20).asSInt
15-
val Simm = Cat(io.inst(31, 25), io.inst(11, 7)).asSInt
16-
val Bimm = Cat(io.inst(31), io.inst(7), io.inst(30, 25), io.inst(11, 8), 0.U(1.W)).asSInt
17-
val Uimm = Cat(io.inst(31, 12), 0.U(12.W)).asSInt
18-
val Jimm = Cat(io.inst(31), io.inst(19, 12), io.inst(20), io.inst(30, 25), io.inst(24, 21), 0.U(1.W)).asSInt
19-
val Zimm = io.inst(19, 15).zext
12+
class ImmGen extends Module {
13+
val io = IO(new ImmGenIO)
14+
protected val Iimm = io.inst(31, 20).asSInt
15+
protected val Simm = Cat(io.inst(31, 25), io.inst(11, 7)).asSInt
16+
protected val Bimm = Cat(io.inst(31), io.inst(7), io.inst(30, 25), io.inst(11, 8), 0.U(1.W)).asSInt
17+
protected val Uimm = Cat(io.inst(31, 12), 0.U(12.W)).asSInt
18+
protected val Jimm = Cat(io.inst(31), io.inst(19, 12), io.inst(20), io.inst(30, 25), io.inst(24, 21), 0.U(1.W)).asSInt
19+
protected val Zimm = io.inst(19, 15).zext
2020

2121
io.out := MuxLookup(
2222
io.sel,

0 commit comments

Comments
 (0)