Skip to content

Commit

Permalink
TestBench: step() - use eval() to settle combinatorials before invert…
Browse files Browse the repository at this point in the history
…ing clock
  • Loading branch information
JimKnowler committed Dec 30, 2020
1 parent 461885e commit 9eb29b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gtestverilog/lib/TestBench.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ namespace gtestverilog {
/// @brief simulate a single half clock step
/// @note This will invert the current value on port 'i_clk'
void step() {
// evaluate core to allow combinatorial values to settle first
m_core->eval();

// invert clock and evaluate again
m_core->i_clk = (m_core->i_clk) ? 0 : 1;
m_core->eval();

Expand Down
4 changes: 3 additions & 1 deletion gtestverilog/test/TestBench.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,6 @@ TEST(TestBench, ShouldSetClockPolarity1) {
testBench.tick();
ASSERT_EQ(1, core.i_clk);

}
}

// TODO: test that combinatorial logic is evaluated before modifying clock during each step

0 comments on commit 9eb29b8

Please sign in to comment.