Skip to content

Commit 8ba84a1

Browse files
authored
Merge pull request #251 from diffblue/verilog_synthesis_expr
synthesise command-line expressions
2 parents 9967bb2 + f544b7c commit 8ba84a1

File tree

5 files changed

+92
-5
lines changed

5 files changed

+92
-5
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
counter_in_module1.sv
33
--ranking-function instance.counter
44
^\[main\.property\.p0\] always \(eventually main.instance.counter == 0\): SUCCESS$
55
^EXIT=0$
66
^SIGNAL=0$
77
--
88
--
9-
We currently don't support hierarchical identifiers in the ranking function.

src/verilog/verilog_language.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,13 @@ bool verilog_languaget::to_expr(
283283

284284
// typecheck it
285285
result=verilog_typecheck(expr, module, get_message_handler(), ns);
286+
if(result)
287+
return true;
288+
289+
// synthesize it
290+
result = verilog_synthesis(expr, module, get_message_handler(), ns);
291+
if(result)
292+
return true;
286293

287294
// save some memory
288295
verilog_parser.clear();

src/verilog/verilog_synthesis.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3110,3 +3110,65 @@ bool verilog_synthesis(
31103110
ns, symbol_table, module, options, message_handler);
31113111
return verilog_synthesis.typecheck_main();
31123112
}
3113+
3114+
/*******************************************************************\
3115+
3116+
Function: verilog_synthesis
3117+
3118+
Inputs:
3119+
3120+
Outputs:
3121+
3122+
Purpose:
3123+
3124+
\*******************************************************************/
3125+
3126+
bool verilog_synthesis(
3127+
exprt &expr,
3128+
const irep_idt &module_identifier,
3129+
message_handlert &message_handler,
3130+
const namespacet &ns)
3131+
{
3132+
optionst options;
3133+
symbol_tablet symbol_table;
3134+
3135+
const auto errors_before =
3136+
message_handler.get_message_count(messaget::M_ERROR);
3137+
3138+
verilog_synthesist verilog_synthesis(
3139+
ns, symbol_table, module_identifier, options, message_handler);
3140+
3141+
try
3142+
{
3143+
expr = verilog_synthesis.synth_expr(
3144+
expr, verilog_synthesist::symbol_statet::SYMBOL);
3145+
}
3146+
3147+
catch(int e)
3148+
{
3149+
verilog_synthesis.error();
3150+
}
3151+
3152+
catch(const char *e)
3153+
{
3154+
verilog_synthesis.error() << e << messaget::eom;
3155+
}
3156+
3157+
catch(const std::string &e)
3158+
{
3159+
verilog_synthesis.error() << e << messaget::eom;
3160+
}
3161+
3162+
catch(const verilog_typecheck_baset::errort &e)
3163+
{
3164+
if(e.what().empty())
3165+
verilog_synthesis.error();
3166+
else
3167+
{
3168+
verilog_synthesis.error().source_location = e.source_location();
3169+
verilog_synthesis.error() << e.what() << messaget::eom;
3170+
}
3171+
}
3172+
3173+
return message_handler.get_message_count(messaget::M_ERROR) != errors_before;
3174+
}

src/verilog/verilog_synthesis.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ bool verilog_synthesis(
1919
message_handlert &,
2020
const optionst &);
2121

22+
bool verilog_synthesis(
23+
exprt &,
24+
const irep_idt &module_identifier,
25+
message_handlert &,
26+
const namespacet &);
27+
2228
#endif

src/verilog/verilog_synthesis_class.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ class verilog_synthesist:
5858

5959
virtual void typecheck();
6060

61+
enum class symbol_statet
62+
{
63+
NONE,
64+
SYMBOL,
65+
CURRENT,
66+
FINAL
67+
};
68+
69+
[[nodiscard]] exprt synth_expr(exprt expr, symbol_statet symbol_state);
70+
6171
protected:
6272
const optionst &options;
6373

@@ -114,8 +124,12 @@ class verilog_synthesist:
114124
typedef std::list<exprt> invarst;
115125
invarst invars;
116126

117-
enum class constructt { INITIAL, ALWAYS, OTHER };
118-
enum class symbol_statet { NONE, SYMBOL, CURRENT, FINAL };
127+
enum class constructt
128+
{
129+
INITIAL,
130+
ALWAYS,
131+
OTHER
132+
};
119133
constructt construct;
120134
event_guardt event_guard;
121135

@@ -226,7 +240,6 @@ class verilog_synthesist:
226240
void synth_while(const verilog_whilet &);
227241
void synth_repeat(const verilog_repeatt &);
228242
void synth_function_call_or_task_enable(const verilog_function_callt &);
229-
[[nodiscard]] exprt synth_expr(exprt expr, symbol_statet symbol_state);
230243
void synth_assign(const exprt &, bool blocking);
231244
void synth_assert(const verilog_assertt &);
232245
void synth_assume(const verilog_assumet &);

0 commit comments

Comments
 (0)