Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# EBMC 5.8

* SMV: use NuSMV's operator precedence, as opposed to CMU SMV's
* AIG/netlist engine: fix for conversion of extract bits operator
* Verilog: semantic fix for output register ports
* SystemVerilog: cover sequence
Expand Down
4 changes: 2 additions & 2 deletions regression/ebmc/smv-netlist/s_until1.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CORE
s_until1.sv
--smv-netlist
^LTLSPEC \(\!node144\) U node151$
^LTLSPEC \(TRUE\) U node158$
^LTLSPEC \!node144 U node151$
^LTLSPEC TRUE U node158$
^EXIT=0$
^SIGNAL=0$
--
2 changes: 1 addition & 1 deletion regression/ebmc/smv-word-level/smv1.desc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ smv1.smv
^INIT range_type = 1$
^INIT signed_bit_vector = 0sd20_1$
^INIT unsigned_bit_vector = 0ud20_1$
^TRANS next\(bool_type\) = \(!bool_type\)$
^TRANS next\(bool_type\) = !bool_type$
^TRANS next\(range_type\) = 2$
^TRANS next\(signed_bit_vector\) = 0sd20_2$
^TRANS next\(unsigned_bit_vector\) = 0ud20_2$
Expand Down
4 changes: 2 additions & 2 deletions regression/smv/word/bitwise1.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CORE
bitwise1.smv

^\[.*\] \(!0ud8_123\) = 0ud8_132: PROVED .*$
^\[.*\] \(!0sd8_123\) = -0sd8_124: PROVED .*$
^\[.*\] !0ud8_123 = 0ud8_132: PROVED .*$
^\[.*\] !0sd8_123 = -0sd8_124: PROVED .*$
^\[.*\] \(0ud8_123 \& 0ud8_7\) = 0ud8_3: PROVED .*$
^\[.*\] \(0ud8_123 \| 0ud8_7\) = 0ud8_127: PROVED .*$
^\[.*\] \(0ud8_123 xor 0ud8_7\) = 0ud8_124: PROVED .*$
Expand Down
4 changes: 2 additions & 2 deletions regression/smv/word/bitwise1.smv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
MODULE main

-- negation
SPEC (!uwconst(123, 8)) = uwconst(132, 8)
SPEC (!swconst(123, 8)) = swconst(-124, 8)
SPEC !uwconst(123, 8) = uwconst(132, 8)
SPEC !swconst(123, 8) = swconst(-124, 8)

-- and
SPEC (uwconst(123, 8) & uwconst(7, 8)) = uwconst(3, 8)
Expand Down
40 changes: 30 additions & 10 deletions src/smvlang/expr2smv_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ class expr2smvt

// In NuSMV 2.6., ! (not) has a high precedence (above ::), whereas
// in the CMU SMV implementation it has the same as other boolean operators.
// We use the CMU SMV precedence for !.
// We use the NuSMV precedence for !.
// Like CMU SMV, we give the same precedence to -> and <->, to avoid ambiguity.
// Note that the precedence of mod in the CMU SMV differs from NuSMV's.
// We use NuSMV's.
enum class precedencet
{
MAX = 16,
INDEX = 15, // [ ] , [ : ]
CONCAT = 14, // ::
NOT = 14, // !
UMINUS = 13, // - (unary minus)
MULT = 12, // * / mod
PLUS = 11, // + -
SHIFT = 10, // << >>
UNION = 9, // union
IN = 8, // in
REL = 7, // = != < > <= >=
TEMPORAL = 6, // AX, AF, etc.
NOT = 5, // !
CONCAT = 12, // ::
MULT = 11, // * / mod
PLUS = 10, // + -
SHIFT = 9, // << >>
UNION = 8, // union
IN = 7, // in
REL = 6, // = != < > <= >=
TEMPORAL = 5, // AX, AF, etc.
AND = 4, // &
OR = 3, // | xor xnor
IF = 2, // (• ? • : •)
Expand All @@ -74,6 +74,26 @@ class expr2smvt
-> <->
*/

/* From https://nusmv.fbk.eu/userman/v27/nusmv.pdf

The order of parsing precedence for operators from high to low is:
[ ] , [ : ]
!
- (unary minus)
::
* / mod
+ -
<< >>
union
in
= != < > <= >=
&
| xor xnor
(• ? • : •)
<->
->
*/

struct resultt
{
resultt(precedencet _p, std::string _s) : p(_p), s(std::move(_s))
Expand Down
8 changes: 3 additions & 5 deletions src/smvlang/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -328,20 +328,18 @@ static smv_parse_treet::modulet &new_module(YYSTYPE &module_name)
%right IMPLIES_Token
%left EQUIV_Token
%left IF_Token
%left xor_Token xnor_Token
%left OR_Token
%left OR_Token xor_Token xnor_Token
%left AND_Token
%left NOT_Token
%left EX_Token AX_Token EF_Token AF_Token EG_Token AG_Token E_Token A_Token U_Token R_Token V_Token F_Token G_Token H_Token O_Token S_Token T_Token X_Token Y_Token Z_Token EBF_Token ABF_Token EBG_Token ABG_Token
%left EQUAL_Token NOTEQUAL_Token LT_Token GT_Token LE_Token GE_Token
%left union_Token
%left in_Token
%left mod_Token /* Precedence from CMU SMV, different from NuSMV */
%left LTLT_Token GTGT_Token
%left PLUS_Token MINUS_Token
%left TIMES_Token DIVIDE_Token
%left TIMES_Token DIVIDE_Token mod_Token /* mod precedence from NuSMV, different from CMU SMV */
%left COLONCOLON_Token
%left UMINUS /* supplies precedence for unary minus */
%left NOT_Token /* precedence from NuSMV, different from CMU SMV */
%left DOT_Token '[' '('

%%
Expand Down
Loading