Skip to content

Commit a77eee6

Browse files
authored
[svsim] Initialize ports to zero (#4651)
Avoid problems with VCS xprop (either xmerge or tmerge) when using svsim due to these features (seemingly) introducing spurious clock transitions when enabled. The change introduced in ab7c417 changes the behavior of svsim such that the simulation body would run after all initial blocks. Before this, the simulation body ran during the testbench's initial block which would race with other initial blocks. However, after this change, VCS xprop simulations started failing. As far as I can tell, this is due to xprop introducing a clock transition for the clock variable in the testbench after initial blocks, but before the simulation body. This would then cause a number of assertions to evaluate and fail the simulation. Fix this by initializing the variables used to drive inputs to the DUT to zero instead of leaving them uninitialized. An alternative approach would be to use 2-state variables. This may create problems with active-low asynchronous resets and trivial reset schemes that do not show a reset edge. With this commit, when an asynchronous reset is applied, it will have to go through a `1 -> 0 -> 1` transition so that flops that need to be reset see an edge (due to the longstanding annoyance of Verilog where an active low asynchronous reset flop is coded as if it was sensitive to a negative reset edge when it is actually level sensitive). Signed-off-by: Schuyler Eldridge <[email protected]>
1 parent e4cf63f commit a77eee6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

svsim/src/main/scala/Workspace.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ final class Workspace(
9797
l("module ", Workspace.testbenchModuleName, ";")
9898
for ((port, index) <- ports) {
9999
if (port.isSettable) {
100-
l(" reg [$bits(", dut.instanceName, ".", port.name, ")-1:0] ", port.name, ";")
100+
l(" reg [$bits(", dut.instanceName, ".", port.name, ")-1:0] ", port.name, " = '0;")
101101
} else {
102102
l(" wire [$bits(", dut.instanceName, ".", port.name, ")-1:0] ", port.name, ";")
103103
}

0 commit comments

Comments
 (0)