chisel2-deprecated icon indicating copy to clipboard operation
chisel2-deprecated copied to clipboard

otherwise code block doesn't get right

Open tiansongmao opened this issue 11 years ago • 2 comments

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?

tiansongmao avatar Oct 30 '14 07:10 tiansongmao

from generated c++ code, the otherwise get execute if "when" clause is false, Is this a bug?

tiansongmao avatar Oct 30 '14 07:10 tiansongmao

What is the expected behavior? Also, so that we can reproduce the issue, what are the test inputs and expected outputs?

sdtwigg avatar Oct 31 '14 21:10 sdtwigg