-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the verilator generation code to call dut->eval() instead (#252)
of dut->_eval_settle(dut->__VlSymsp) Test in SecondClockDrivesRegisterSpec will only work with this change. GCDSpec has code to do regression work to make sure the above change did not significantly slow the verilator simulation.
- Loading branch information
Showing
3 changed files
with
113 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/test/scala/examples/SecondClockDrivesRegisterSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package examples | ||
|
||
import chisel3._ | ||
import chisel3.experimental.MultiIOModule | ||
import chisel3.iotesters.PeekPokeTester | ||
import chisel3.util.Counter | ||
import org.scalatest.{FreeSpec, Matchers} | ||
|
||
|
||
class SecondClockDrivesRegisterSpec extends FreeSpec with Matchers { | ||
class SecondClock extends MultiIOModule { | ||
val inClock = IO(Input(Bool())) | ||
val out = IO(Output(UInt(8.W))) | ||
|
||
withClock(inClock.asClock) { | ||
out := Counter(true.B, 8)._1 | ||
} | ||
} | ||
|
||
class SecondClockTester(c: SecondClock) extends PeekPokeTester(c) { | ||
poke(c.inClock, 0) | ||
expect(c.out, 0) | ||
|
||
// Main clock should do nothing | ||
step(1) | ||
expect(c.out, 0) | ||
step(1) | ||
expect(c.out, 0) | ||
|
||
// Output should advance on rising edge, even without main clock edge | ||
poke(c.inClock, 1) | ||
expect(c.out, 1) | ||
|
||
step(1) | ||
expect(c.out, 1) | ||
|
||
// Repeated, 1should do nothing | ||
poke(c.inClock, 1) | ||
expect(c.out, 1) | ||
|
||
// and again | ||
poke(c.inClock, 0) | ||
expect(c.out, 1) | ||
poke(c.inClock, 1) | ||
expect(c.out, 2) | ||
} | ||
|
||
"poking a clock should flip register" - { | ||
|
||
"should work with Treadle" in { | ||
iotesters.Driver.execute(Array(), () => new SecondClock) { c => | ||
new SecondClockTester(c) | ||
} should be(true) | ||
} | ||
|
||
"should work with Verilator" in { | ||
iotesters.Driver.execute(Array("--backend-name", "verilator"), () => new SecondClock) { c => | ||
new SecondClockTester(c) | ||
} should be(true) | ||
} | ||
} | ||
} |