diff options
| author | jackkoenig | 2016-10-26 16:40:36 -0700 |
|---|---|---|
| committer | Jack Koenig | 2017-02-02 22:53:03 -0800 |
| commit | dd51b917566e6b30c3f123ca22a0393e73c2afe8 (patch) | |
| tree | f81fce104ccc3405c7924c76618483750a4350bb /src/test/scala/chiselTests | |
| parent | b0a328492383108509c322189ed2803f671d7a59 (diff) | |
Revamp VendingMachine.scala as cookbook example
* Move to cookbook
* Change FSM implementation to use switch & is
* Add non-FSM implementation
* Add execution-driven test
Diffstat (limited to 'src/test/scala/chiselTests')
| -rw-r--r-- | src/test/scala/chiselTests/VendingMachine.scala | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/src/test/scala/chiselTests/VendingMachine.scala b/src/test/scala/chiselTests/VendingMachine.scala deleted file mode 100644 index 712b5b7a..00000000 --- a/src/test/scala/chiselTests/VendingMachine.scala +++ /dev/null @@ -1,69 +0,0 @@ -// See LICENSE for license details. - -package chiselTests - -import chisel3._ -import chisel3.util._ - -class VendingMachine extends Module { - val io = IO(new Bundle { - val nickel = Input(Bool()) - val dime = Input(Bool()) - val valid = Output(Bool()) - }) - val c = 5.U(3.W) - val sIdle :: s5 :: s10 :: s15 :: sOk :: Nil = Enum(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)) - } -} -*/ - -class VendingMachineSpec extends ChiselPropSpec { - property("VendingMachine should elaborate") { - elaborate { new VendingMachine } - } - - ignore("VendingMachineTester should return the correct result") { } -} |
