Skip to content

Commit c9e186e

Browse files
committed
Verilog: fix for synthesis of continuous assignments
The LHS expression of continuous assignments needs to be synthesized.
1 parent 88a0e54 commit c9e186e

File tree

7 files changed

+61
-4
lines changed

7 files changed

+61
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
continuous_assignment1.sv
3+
--module main --bound 0
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module main;
2+
3+
wire [31:0] a;
4+
assign a[7:0] = 1;
5+
assign a[8+:24] = 1;
6+
7+
assert final (a == 'h101);
8+
9+
endmodule
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
continuous_assignment2.sv
3+
--module main --bound 0
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module main;
2+
3+
typedef struct {
4+
bit [31:0] f1, f2;
5+
} my_struct;
6+
7+
wire my_struct s;
8+
9+
assign s.f1 = 1;
10+
assign s.f2 = 2;
11+
12+
assert final (s.f1 == 1);
13+
assert final (s.f2 == 2);
14+
15+
endmodule
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
continuous_assignment3.sv
3+
--module main --bound 0
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module main;
2+
3+
wire [31:0] array[10];
4+
5+
assign array[0] = 0;
6+
assign array[1] = 1;
7+
8+
assert final (array[0] == 0);
9+
assert final (array[1] == 1);
10+
11+
endmodule

src/verilog/verilog_synthesis.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,8 +2439,6 @@ void verilog_synthesist::synth_force_rec(
24392439
else
24402440
DATA_INVARIANT(false, "unexpected assignment type");
24412441

2442-
auto rhs_synth = synth_expr(rhs, symbol_statet::CURRENT);
2443-
24442442
// If the symbol is marked as a state variable,
24452443
// turn it into a wire now.
24462444
if(symbol.is_state_var)
@@ -2451,8 +2449,11 @@ void verilog_synthesist::synth_force_rec(
24512449
writeable_symbol.is_state_var = false;
24522450
}
24532451

2454-
equal_exprt equality{lhs, rhs_synth};
2455-
invars.push_back(equality);
2452+
auto lhs_synth = synth_expr(lhs, symbol_statet::CURRENT);
2453+
auto rhs_synth = synth_expr(rhs, symbol_statet::CURRENT);
2454+
2455+
equal_exprt equality{std::move(lhs_synth), std::move(rhs_synth)};
2456+
invars.push_back(std::move(equality));
24562457
}
24572458

24582459
/*******************************************************************\

0 commit comments

Comments
 (0)