Skip to content

Commit 2892ee0

Browse files
authored
Fix verification generation for event driven simulators (#2455)
Event driven simulators (such as vivado xsim and synopsys vcs) behave fundamentally differently than cycle based simulators like icarus and verilator. Rather than taking a full cycle step at a time, individual values within a cycle can be updated independently of each other, which makes the current way of combinationally checking disjoint guards invalid. We can fix this issue by only performing disjoint checks at the positive edge of the clock, which is fine because it's the only time that we truly care about the guards being disjoint. Without these fixes you have to turn off verification to run calyx verilog through commercial simulators.
1 parent 5e32e02 commit 2892ee0

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

calyx/backend/src/verilog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ fn emit_component<F: io::Write>(
647647
if let Some(check) =
648648
emit_guard_disjoint_check(dst, asgns, &pool, true)
649649
{
650-
writeln!(f, "always_comb begin")?;
650+
writeln!(f, "always_ff @(posedge clk) begin")?;
651651
writeln!(f, " {check}")?;
652652
writeln!(f, "end")?;
653653
}

tests/backend/verilog/data-instance.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ assign data_add_multi_left =
145145
_guard1 ? 2'd2 :
146146
_guard3 ? 2'd3 :
147147
'x;
148-
always_comb begin
148+
always_ff @(posedge clk) begin
149149
if(~$onehot0({_guard3, _guard1})) begin
150150
$fatal(2, "Multiple assignment to port `data_add_multi.left'.");
151151
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
[70] %Error: Assertion failed in TOP.toplevel.main: Multiple assignment to port `r.in'.
1+
[90] %Error: Assertion failed in TOP.toplevel.main: Multiple assignment to port `r.in'.
22
%Error: Verilog $stop

0 commit comments

Comments
 (0)