Skip to content

Commit 4ab77d7

Browse files
authored
Merge pull request #1008 from diffblue/smvlang-xnor
SMV: xnor operator
2 parents 2ae3ac7 + a0eeca9 commit 4ab77d7

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
* SystemVerilog: typedefs from package scopes
44
* SystemVerilog: assignment patterns with keys for structs
5-
* SMV: LTL V operator
5+
* SMV: LTL V operator, xnor operator
66

77
# EBMC 5.5
88

regression/smv/expressions/xnor1.desc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
xnor1.smv
3+
4+
^\[spec1\] G x: PROVED$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--

regression/smv/expressions/xnor1.smv

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
MODULE main
2+
3+
VAR x : boolean;
4+
5+
ASSIGN init(x) := TRUE;
6+
ASSIGN next(x) := x xnor x;
7+
8+
LTLSPEC G x

src/smvlang/expr2smv.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,12 @@ bool expr2smvt::convert(
552552
else if(src.id()==ID_implies)
553553
return convert_binary(src, dest, "->", precedence = precedencet::IMPLIES);
554554

555+
else if(src.id() == ID_xor)
556+
return convert_binary(src, dest, "xor", precedence = precedencet::OR);
557+
558+
else if(src.id() == ID_xnor)
559+
return convert_binary(src, dest, "xnor", precedence = precedencet::OR);
560+
555561
else if(
556562
src.id() == ID_AG || src.id() == ID_EG || src.id() == ID_AF ||
557563
src.id() == ID_EF || src.id() == ID_AX || src.id() == ID_EX ||

src/smvlang/parser.y

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static void new_module(YYSTYPE &module)
280280
%right IMPLIES_Token
281281
%left EQUIV_Token
282282
%left IF_Token
283-
%left xor_Token
283+
%left xor_Token xnor_Token
284284
%left OR_Token
285285
%left AND_Token
286286
%left NOT_Token
@@ -676,6 +676,7 @@ term : variable_name
676676
| term EQUIV_Token term { binary($$, $1, ID_smv_iff, $3); }
677677
| term IMPLIES_Token term { binary($$, $1, ID_implies, $3); }
678678
| term xor_Token term { j_binary($$, $1, ID_xor, $3); }
679+
| term xnor_Token term { binary($$, $1, ID_xnor, $3); }
679680
| term OR_Token term { j_binary($$, $1, ID_or, $3); }
680681
| term AND_Token term { j_binary($$, $1, ID_and, $3); }
681682
| NOT_Token term { init($$, ID_not); mto($$, $2); }

src/smvlang/smv_typecheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ void smv_typecheckt::typecheck_expr_rec(
698698
}
699699
else if(
700700
expr.id() == ID_and || expr.id() == ID_or || expr.id() == ID_xor ||
701-
expr.id() == ID_not || expr.id() == ID_implies)
701+
expr.id() == ID_xnor || expr.id() == ID_not || expr.id() == ID_implies)
702702
{
703703
for(auto &op : expr.operands())
704704
typecheck_expr_rec(op, mode);

0 commit comments

Comments
 (0)