Skip to content

Commit 436c304

Browse files
committed
Verilog: {} and {{}} do not need parentheses
This changes the precedence of concatenation and replication when generating Verilog from expressions such that no additional parentheses are generated.
1 parent a52c32b commit 436c304

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

regression/verilog/SVA/immediate3.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
immediate3.sv
33
--bound 0
4-
^\[full_adder\.assert\.1\] always \(\{ full_adder\.carry, full_adder\.sum \}\) == full_adder\.a \+ full_adder\.b \+ full_adder\.c: PROVED up to bound 0$
4+
^\[full_adder\.assert\.1\] always \{ full_adder\.carry, full_adder\.sum \} == full_adder\.a \+ full_adder\.b \+ full_adder\.c: PROVED up to bound 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/verilog/SVA/static_final1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
static_final1.sv
33
--bound 0
4-
^\[full_adder\.p0\] always \(\{ full_adder\.carry, full_adder\.sum \}\) == full_adder\.a \+ full_adder\.b \+ full_adder\.c: PROVED up to bound 0$
4+
^\[full_adder\.p0\] always \{ full_adder\.carry, full_adder\.sum \} == full_adder\.a \+ full_adder\.b \+ full_adder\.c: PROVED up to bound 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/verilog/expressions/concatenation3.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ concatenation3.sv
33
--bound 0
44
^EXIT=0$
55
^SIGNAL=0$
6-
^\[.*\] always \(\{ 5'bxz01\?, 4'b10zx \}\) === 9'bxz01\?10zx: PROVED up to bound 0$
6+
^\[.*\] always \{ 5'bxz01\?, 4'b10zx \} === 9'bxz01\?10zx: PROVED up to bound 0$
77
--
88
^warning: ignoring

src/verilog/expr2verilog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ expr2verilogt::convert(const exprt &src, verilog_precedencet &precedence)
11361136

11371137
else if(src.id()==ID_replication)
11381138
return convert_replication(
1139-
to_replication_expr(src), precedence = verilog_precedencet::REPLICATION);
1139+
to_replication_expr(src), precedence = verilog_precedencet::CONCAT);
11401140

11411141
else if(src.id()==ID_array)
11421142
return convert_array(src, precedence);

src/verilog/expr2verilog_class.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class sva_ranged_predicate_exprt;
1919

2020
// Precedences (higher means binds more strongly).
2121
// Follows Table 11-2 in IEEE 1800-2017.
22-
//
22+
// We deviate from the table for the precedence of concatenation
23+
// and replication, which act like parenteses.
2324
enum class verilog_precedencet
2425
{
2526
MAX = 19,
@@ -39,8 +40,7 @@ enum class verilog_precedencet
3940
IF = 5, // ?:
4041
IMPLIES = 4, // ->
4142
ASSIGN = 3, // = += -= etc.
42-
CONCAT = 2, // { } concatenation
43-
REPLICATION = 1, // {{ }} replication
43+
CONCAT = 18, // { } concatenation, {{ }} replication
4444
MIN = 0 // anything even weaker, e.g., SVA
4545
};
4646

0 commit comments

Comments
 (0)