Skip to content

Commit 9f8c2fe

Browse files
committed
Fix for sequences in named properties
Sequences that are in named properties now get the proper weak/strong semantics. This is achieved by moving the code that assigns the implicit weak/strong semantics from the type checker to the synthesis pass, where named properties are already expanded.
1 parent ffa161e commit 9f8c2fe

File tree

6 files changed

+48
-48
lines changed

6 files changed

+48
-48
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
named_property4.sv
33

44
^EXIT=10$
55
^SIGNAL=0$
66
--
77
^warning: ignoring
88
--
9-
This triggers an internal error.

src/verilog/verilog_synthesis.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,38 @@ exprt verilog_synthesist::synth_expr_rec(exprt expr, symbol_statet symbol_state)
130130
UNREACHABLE;
131131
}
132132

133+
// 1800-2017 16.12.2 Sequence property
134+
// Sequences are by default _weak_ when used in assert property
135+
// or assume property, and are _strong_ when used in cover property.
136+
// This flips when below the SVA not operator.
137+
void verilog_synthesist::set_default_sequence_semantics(
138+
exprt &expr,
139+
sva_sequence_semanticst semantics)
140+
{
141+
if(expr.id() == ID_sva_sequence_property)
142+
{
143+
// apply
144+
if(semantics == sva_sequence_semanticst::WEAK)
145+
expr.id(ID_sva_implicit_weak);
146+
else
147+
expr.id(ID_sva_implicit_strong);
148+
}
149+
else if(expr.id() == ID_sva_not)
150+
{
151+
// flip
152+
semantics = semantics == sva_sequence_semanticst::WEAK
153+
? sva_sequence_semanticst::STRONG
154+
: sva_sequence_semanticst::WEAK;
155+
156+
set_default_sequence_semantics(to_sva_not_expr(expr).op(), semantics);
157+
}
158+
else
159+
{
160+
for(auto &op : expr.operands())
161+
set_default_sequence_semantics(op, semantics);
162+
}
163+
}
164+
133165
/*******************************************************************\
134166
135167
Function: verilog_synthesist::synthesis_constant
@@ -2326,6 +2358,12 @@ void verilog_synthesist::synth_assert_assume_cover(
23262358
cond = sva_cover_exprt(cond);
23272359
}
23282360

2361+
// 1800-2017 16.12.2 Sequence property
2362+
if(statement.id() == ID_verilog_cover_property)
2363+
set_default_sequence_semantics(cond, sva_sequence_semanticst::STRONG);
2364+
else
2365+
set_default_sequence_semantics(cond, sva_sequence_semanticst::WEAK);
2366+
23292367
symbol.value = std::move(cond);
23302368
}
23312369

@@ -2401,6 +2439,12 @@ void verilog_synthesist::synth_assert_assume_cover(
24012439
else
24022440
PRECONDITION(false);
24032441

2442+
// 1800-2017 16.12.2 Sequence property
2443+
if(module_item.id() == ID_verilog_cover_property)
2444+
set_default_sequence_semantics(cond, sva_sequence_semanticst::STRONG);
2445+
else
2446+
set_default_sequence_semantics(cond, sva_sequence_semanticst::WEAK);
2447+
24042448
symbol.value = std::move(cond);
24052449
}
24062450

src/verilog/verilog_synthesis_class.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
1515
#include <util/std_expr.h>
1616
#include <util/string_hash.h>
1717

18+
#include "sva_expr.h"
1819
#include "verilog_expr.h"
1920
#include "verilog_symbol_table.h"
2021
#include "verilog_typecheck_base.h"
@@ -235,6 +236,8 @@ class verilog_synthesist:
235236
const membert &member,
236237
assignmentt::datat &data);
237238

239+
static void set_default_sequence_semantics(exprt &, sva_sequence_semanticst);
240+
238241
// module items
239242
virtual void convert_module_items(symbolt &);
240243
void synth_module_item(const verilog_module_itemt &, transt &);

src/verilog/verilog_typecheck.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,12 +1060,6 @@ void verilog_typecheckt::convert_assert_assume_cover(
10601060
convert_sva(cond);
10611061
require_sva_property(cond);
10621062

1063-
// 1800-2017 16.12.2 Sequence property
1064-
if(module_item.id() == ID_verilog_cover_property)
1065-
set_default_sequence_semantics(cond, sva_sequence_semanticst::STRONG);
1066-
else
1067-
set_default_sequence_semantics(cond, sva_sequence_semanticst::WEAK);
1068-
10691063
// We create a symbol for the property.
10701064
// The 'value' of the symbol is set by synthesis.
10711065
const irep_idt &identifier = module_item.identifier();
@@ -1131,12 +1125,6 @@ void verilog_typecheckt::convert_assert_assume_cover(
11311125
convert_sva(cond);
11321126
require_sva_property(cond);
11331127

1134-
// 1800-2017 16.12.2 Sequence property
1135-
if(statement.id() == ID_verilog_cover_property)
1136-
set_default_sequence_semantics(cond, sva_sequence_semanticst::STRONG);
1137-
else
1138-
set_default_sequence_semantics(cond, sva_sequence_semanticst::WEAK);
1139-
11401128
// We create a symbol for the property.
11411129
// The 'value' is set by synthesis.
11421130
const irep_idt &identifier = statement.identifier();

src/verilog/verilog_typecheck_expr.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,6 @@ class verilog_typecheck_exprt:public verilog_typecheck_baset
209209
[[nodiscard]] exprt convert_ternary_sva(ternary_exprt);
210210
[[nodiscard]] exprt convert_other_sva(exprt);
211211

212-
static void set_default_sequence_semantics(exprt &, sva_sequence_semanticst);
213-
214212
// system functions
215213
exprt bits(const exprt &);
216214
std::optional<mp_integer> bits_rec(const typet &) const;

src/verilog/verilog_typecheck_sva.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -480,35 +480,3 @@ exprt verilog_typecheck_exprt::convert_sva_rec(exprt expr)
480480
return convert_other_sva(expr);
481481
}
482482
}
483-
484-
// 1800-2017 16.12.2 Sequence property
485-
// Sequences are by default _weak_ when used in assert property
486-
// or assume property, and are _strong_ when used in cover property.
487-
// This flips when below the SVA not operator.
488-
void verilog_typecheck_exprt::set_default_sequence_semantics(
489-
exprt &expr,
490-
sva_sequence_semanticst semantics)
491-
{
492-
if(expr.id() == ID_sva_sequence_property)
493-
{
494-
// apply
495-
if(semantics == sva_sequence_semanticst::WEAK)
496-
expr.id(ID_sva_implicit_weak);
497-
else
498-
expr.id(ID_sva_implicit_strong);
499-
}
500-
else if(expr.id() == ID_sva_not)
501-
{
502-
// flip
503-
semantics = semantics == sva_sequence_semanticst::WEAK
504-
? sva_sequence_semanticst::STRONG
505-
: sva_sequence_semanticst::WEAK;
506-
507-
set_default_sequence_semantics(to_sva_not_expr(expr).op(), semantics);
508-
}
509-
else
510-
{
511-
for(auto &op : expr.operands())
512-
set_default_sequence_semantics(op, semantics);
513-
}
514-
}

0 commit comments

Comments
 (0)