chisel2-deprecated
chisel2-deprecated copied to clipboard
otherwise code block doesn't get right
package Rs232
import Chisel._
class Transmitter extends Module
{
val io = new Bundle {
val serOut = UInt(OUTPUT, 1)
val outData = Decoupled(UInt(width = 8)).flip
val counterInit = UInt(INPUT, 16)
}
val shifter = Reg(UInt(width = 9))
val freqCounter = Reg(UInt(width = 17))
val shiftCounter = Reg(init = UInt("b10000", width = 5))
val busy = Reg(init = Bool(false))
//val busy = ~shiftCounter(4)
io.outData.ready := ~busy
io.serOut := shifter(0)
when (io.outData.fire()) {
freqCounter := io.counterInit
shifter := Cat(io.outData.bits, UInt(0))
shiftCounter := UInt(9)
busy := Bool(true)
} .elsewhen (~freqCounter(16) && busy) {
freqCounter := freqCounter - UInt(1)
} .elsewhen (~shiftCounter(4)) {
shifter := Cat(UInt(1), shifter(8, 1))
shiftCounter := shiftCounter - UInt(1)
freqCounter := io.counterInit
} .otherwise {
//get executed???
busy := Bool(false)
}
}
busy get false, once it become true. any easy way I can debug to see how this happen, or I can only dig into the generated c++ code?
from generated c++ code, the otherwise get execute if "when" clause is false, Is this a bug?
What is the expected behavior? Also, so that we can reproduce the issue, what are the test inputs and expected outputs?