Skip to content

Commit cdab375

Browse files
authored
Merge pull request #671 from diffblue/paren-concat
Verilog: `{}` and `{{}}` do not need parentheses
2 parents 7fb3600 + ae8584b commit cdab375

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
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: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@ 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 parentheses.
2324
enum class verilog_precedencet
2425
{
2526
MAX = 19,
26-
MEMBER = 18, // [ ] bit-select ( ) parenthesis :: .
27-
NOT = 17, // unary ! ~ & | ~& ~| ^ ~^ ^~ + -
28-
POWER = 16, // ** power
29-
MULT = 15, // * / %
30-
ADD = 14, // + -
31-
SHIFT = 13, // << >> <<< >>>
32-
RELATION = 12, // > >= < <=
33-
EQUALITY = 11, // == != === !== ==? !=?
34-
BITAND = 10, // &
35-
XOR = 9, // ^ ~^ ^~ (binary)
36-
BITOR = 8, // |
37-
AND = 7, // &&
38-
OR = 6, // ||
39-
IF = 5, // ?:
40-
IMPLIES = 4, // ->
41-
ASSIGN = 3, // = += -= etc.
42-
CONCAT = 2, // { } concatenation
43-
REPLICATION = 1, // {{ }} replication
44-
MIN = 0 // anything even weaker, e.g., SVA
27+
MEMBER = 18, // [ ] bit-select ( ) parenthesis :: .
28+
NOT = 17, // unary ! ~ & | ~& ~| ^ ~^ ^~ + -
29+
POWER = 16, // ** power
30+
MULT = 15, // * / %
31+
ADD = 14, // + -
32+
SHIFT = 13, // << >> <<< >>>
33+
RELATION = 12, // > >= < <=
34+
EQUALITY = 11, // == != === !== ==? !=?
35+
BITAND = 10, // &
36+
XOR = 9, // ^ ~^ ^~ (binary)
37+
BITOR = 8, // |
38+
AND = 7, // &&
39+
OR = 6, // ||
40+
IF = 5, // ?:
41+
IMPLIES = 4, // ->
42+
ASSIGN = 3, // = += -= etc.
43+
CONCAT = 18, // { } concatenation, {{ }} replication
44+
MIN = 0 // anything even weaker, e.g., SVA
4545
};
4646

4747
class expr2verilogt

0 commit comments

Comments
 (0)