Skip to content

Commit c14c55f

Browse files
author
Daniel Kroening
committed
get_modules no longer has a dependency on bmct
1 parent 9070e3d commit c14c55f

File tree

2 files changed

+66
-25
lines changed

2 files changed

+66
-25
lines changed

src/hw-cbmc/hw_cbmc_parse_options.cpp

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,16 @@ int hw_cbmc_parse_optionst::doit()
8686
prop_convt &prop_conv=cbmc_solver->prop_conv();
8787
hw_bmct hw_bmc(options, symbol_table, ui_message_handler, prop_conv);
8888

89-
if(cmdline.isset("bound"))
90-
hw_bmc.unwind_no_timeframes=safe_string2unsigned(cmdline.get_value("bound"))+1;
91-
else
92-
hw_bmc.unwind_no_timeframes=1;
93-
9489
goto_functionst goto_functions;
9590

96-
int get_goto_program_ret=get_goto_program(options, hw_bmc, goto_functions);
91+
int get_goto_program_ret=get_goto_program(
92+
options, hw_bmc.bmc_constraints, goto_functions);
9793
if(get_goto_program_ret!=-1)
9894
return get_goto_program_ret;
9995

96+
hw_bmc.unwind_no_timeframes=get_bound();
97+
hw_bmc.unwind_module=get_top_module();
98+
10099
label_properties(goto_functions);
101100

102101
if(cmdline.isset("show-properties"))
@@ -115,7 +114,7 @@ int hw_cbmc_parse_optionst::doit()
115114

116115
/*******************************************************************\
117116
118-
Function: hw_cbmc_parse_optionst::get_modules
117+
Function: hw_cbmc_parse_optionst::get_top_module
119118
120119
Inputs:
121120
@@ -125,28 +124,71 @@ Function: hw_cbmc_parse_optionst::get_modules
125124
126125
\*******************************************************************/
127126

128-
int hw_cbmc_parse_optionst::get_modules(bmct &bmc)
127+
irep_idt hw_cbmc_parse_optionst::get_top_module()
129128
{
130-
//
131-
// unwinding of transition systems
132-
//
133-
134129
std::string top_module;
135130

136131
if(cmdline.isset("module"))
137132
top_module=cmdline.get_value("module");
138133
else if(cmdline.isset("top"))
139134
top_module=cmdline.get_value("top");
140135

141-
if(top_module!="")
136+
if(top_module=="")
137+
return irep_idt();
138+
139+
return get_module(
140+
symbol_table, top_module, get_message_handler()).name;
141+
}
142+
143+
/*******************************************************************\
144+
145+
Function: hw_cbmc_parse_optionst::get_bound
146+
147+
Inputs:
148+
149+
Outputs:
150+
151+
Purpose: add additional (synchonous) modules
152+
153+
\*******************************************************************/
154+
155+
unsigned hw_cbmc_parse_optionst::get_bound()
156+
{
157+
if(cmdline.isset("bound"))
158+
return safe_string2unsigned(cmdline.get_value("bound"))+1;
159+
else
160+
return 1;
161+
}
162+
163+
/*******************************************************************\
164+
165+
Function: hw_cbmc_parse_optionst::get_modules
166+
167+
Inputs:
168+
169+
Outputs:
170+
171+
Purpose: add additional (synchonous) modules
172+
173+
\*******************************************************************/
174+
175+
int hw_cbmc_parse_optionst::get_modules(expr_listt &bmc_constraints)
176+
{
177+
//
178+
// unwinding of transition systems
179+
//
180+
181+
irep_idt top_module=get_top_module();
182+
183+
if(!top_module.empty())
142184
{
143185
try
144186
{
145-
const symbolt &symbol=
146-
get_module(symbol_table, top_module, get_message_handler());
147-
148187
if(cmdline.isset("gen-interface"))
149188
{
189+
const symbolt &symbol=
190+
namespacet(symbol_table).lookup(top_module);
191+
150192
if(cmdline.isset("outfile"))
151193
{
152194
std::ofstream out(cmdline.get_value("outfile").c_str());
@@ -164,10 +206,6 @@ int hw_cbmc_parse_optionst::get_modules(bmct &bmc)
164206
return 0; // done
165207
}
166208

167-
hw_bmct &hw_bmc=dynamic_cast<hw_bmct &>(bmc);
168-
169-
hw_bmc.unwind_module=symbol.name;
170-
171209
//
172210
// map HDL variables to C variables
173211
//
@@ -176,10 +214,10 @@ int hw_cbmc_parse_optionst::get_modules(bmct &bmc)
176214

177215
map_vars(
178216
symbol_table,
179-
symbol.name,
180-
hw_bmc.bmc_constraints,
181-
ui_message_handler,
182-
hw_bmc.unwind_no_timeframes);
217+
top_module,
218+
bmc_constraints,
219+
get_message_handler(),
220+
get_bound());
183221
}
184222

185223
catch(int e) { return 6; }

src/hw-cbmc/hw_cbmc_parse_options.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class hw_cbmc_parse_optionst:public cbmc_parse_optionst
2727
}
2828

2929
protected:
30-
virtual int get_modules(bmct &bmc);
30+
virtual int get_modules(expr_listt &bmc_constraints);
31+
32+
irep_idt get_top_module();
33+
unsigned get_bound();
3134
};
3235

3336
#endif

0 commit comments

Comments
 (0)