You may know "output reg" in Verilog, very helpful feature.
But in Chisel I can't find how to do similar things. When I need register output I should do this:
package filter
import chisel3._
class TestReg extends Module {
val io = IO( new Bundle {
val din = Input(SInt(32.W))
val ena = Input(Bool())
val dout = Output(SInt())
})
val dout = RegInit(0.S(32.W))
when (io.ena) {
dout := io.din + 77.S
}
io.dout <> dout
}
Is there a more "short" way to create output reg?
What I'm looking for is to define Reg in IO bundle and write into it as into register
Something like this:
class TestReg extends Module {
val io = IO( new Bundle {
val din = Input(SInt(32.W))
val ena = Input(Bool())
val dout = Output(RegInit(0.S(32.W)))
})
when (io.ena) {
io.dout := io.din + 77.S
}
}