schoeberl / chisel-book

Digital Design with Chisel
727 stars 135 forks source link

Question about arbitrateSimp #43

Open pdnm opened 1 year ago

pdnm commented 1 year ago

Hi @schoeberl,

In arbitrateSimp, regEmpty is updated to true when (out.ready), but what if out.ready is true when regEmpty is true?

The following test fails while I think it should pass:

class ArbiterTester extends AnyFlatSpec with ChiselScalatestTester {
  "arbiter" should "work" in {
    test(new ArbiterSimpleTree(2, UInt(4.W))) { dut =>
      dut.io.in(0).valid.poke(true)
      dut.io.in(0).bits.poke(14.U)
      dut.io.in(1).valid.poke(false)
      dut.io.out.ready.poke(false)
      dut.clock.step()
      dut.io.out.ready.poke(true)
      dut.clock.step()
      dut.io.out.valid.expect(true) 
      dut.io.out.bits.expect(14.U) 
    }
  }
}

Please help advice, thanks!