Skip to content

Commit

Permalink
simulator: add test for failed expects.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Jun 6, 2024
1 parent f320d82 commit 6dc98b7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/scala/chiselTests/simulator/SimulatorSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ class SimulatorSpec extends AnyFunSpec with Matchers {
assert(result === 12)
}

it("reports failed expects correctly") {
val simulator = new VerilatorSimulator("test_run_dir/simulator/GCDSimulator")
a[PeekPokeAPI.FailedExpectationException[_]] must be thrownBy {
simulator
.simulate(new GCD()) { module =>
import PeekPokeAPI._
val gcd = module.wrapped
gcd.io.a.poke(24.U)
gcd.io.b.poke(36.U)
gcd.io.loadValues.poke(1.B)
gcd.clock.step()
gcd.io.loadValues.poke(0.B)
gcd.clock.step(10)
gcd.io.result.expect(5)
}
.result
}
}

it("runs a design that includes an external module") {
class Bar extends ExtModule with HasExtModuleInline {
val a = IO(Output(Bool()))
Expand Down

0 comments on commit 6dc98b7

Please sign in to comment.