diff options
| author | Henry Cook | 2015-08-12 19:32:43 -0700 |
|---|---|---|
| committer | Henry Cook | 2015-08-12 19:32:57 -0700 |
| commit | 85d7403f9bf7bc2b3520f924736c237f21f70ebd (patch) | |
| tree | 64560f779063a419395a2fb8a31ea52c52af4404 /src/test/scala/ChiselTests/VendingMachine.scala | |
| parent | 7e69966362b1dbd9835695250494857f3a3767c8 (diff) | |
being to convert tests to scala-test; tests compile and run
Diffstat (limited to 'src/test/scala/ChiselTests/VendingMachine.scala')
| -rw-r--r-- | src/test/scala/ChiselTests/VendingMachine.scala | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/src/test/scala/ChiselTests/VendingMachine.scala b/src/test/scala/ChiselTests/VendingMachine.scala deleted file mode 100644 index 7fbfcc62..00000000 --- a/src/test/scala/ChiselTests/VendingMachine.scala +++ /dev/null @@ -1,56 +0,0 @@ -package ChiselTests -import Chisel._ -import Chisel.testers._ - -class VendingMachine extends Module { - val io = new Bundle { - val nickel = Bool(dir = INPUT) - val dime = Bool(dir = INPUT) - val valid = Bool(dir = OUTPUT) } - val c = UInt(5, width = 3) - val sIdle :: s5 :: s10 :: s15 :: sOk :: Nil = Enum(UInt(), 5) - val state = Reg(init = sIdle) - when (state === sIdle) { - when (io.nickel) { state := s5 } - when (io.dime) { state := s10 } - } - when (state === s5) { - when (io.nickel) { state := s10 } - when (io.dime) { state := s15 } - } - when (state === s10) { - when (io.nickel) { state := s15 } - when (io.dime) { state := sOk } - } - when (state === s15) { - when (io.nickel) { state := sOk } - when (io.dime) { state := sOk } - } - when (state === sOk) { - state := sIdle - } - io.valid := (state === sOk) -} - - -class VendingMachineTester(c: VendingMachine) extends Tester(c) { - var money = 0 - var isValid = false - for (t <- 0 until 20) { - val coin = rnd.nextInt(3)*5 - val isNickel = coin == 5 - val isDime = coin == 10 - - // Advance circuit - poke(c.io.nickel, int(isNickel)) - poke(c.io.dime, int(isDime)) - step(1) - - // Advance model - money = if (isValid) 0 else (money + coin) - isValid = money >= 20 - - // Compare - expect(c.io.valid, int(isValid)) - } -} |
