Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BMC: include macros in trace #518

Merged
merged 1 commit into from
May 22, 2024
Merged
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
15 changes: 15 additions & 0 deletions regression/ebmc/traces/verilog1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CORE
verilog1.v
--bound 9 --numbered-trace
^\[.*\] .* REFUTED$
^Counterexample with 10 states:$
^main\.P@0 = 123$
^main\.Q@0 = 124$
^main\.data@0 = 1$
^main\.P@9 = 123$
^main\.Q@9 = 124$
^main\.data@9 = 10$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
14 changes: 14 additions & 0 deletions regression/ebmc/traces/verilog1.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module main(input clk);

parameter P = 123;
parameter Q = P + 1;

reg [31:0] data;
initial data = 1;

always @(posedge clk)
data = data + 1;

always assert p1: data != 10;

endmodule
41 changes: 27 additions & 14 deletions src/trans-word-level/trans_trace_word_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,33 @@ trans_tracet compute_trans_trace(
symbol.type.id()!=ID_module &&
symbol.type.id()!=ID_module_instance)
{
exprt indexed_symbol_expr(ID_symbol, symbol.type);

indexed_symbol_expr.set(ID_identifier,
timeframe_identifier(t, symbol.name));

exprt value_expr=decision_procedure.get(indexed_symbol_expr);
if(value_expr==indexed_symbol_expr)
value_expr=nil_exprt();

trans_tracet::statet::assignmentt assignment;
assignment.rhs.swap(value_expr);
assignment.lhs=symbol.symbol_expr();

state.assignments.push_back(assignment);
if(symbol.is_macro)
{
if(symbol.value.is_constant())
{
trans_tracet::statet::assignmentt assignment;
assignment.rhs = symbol.value;
assignment.lhs = symbol.symbol_expr();
Comment on lines +65 to +67
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think trans_tracet::statet::assignmentt should only be constructible with two or three (the source location) arguments, unless use with containers absolutely requires the presence of a default constructor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do as separate PR.

state.assignments.push_back(assignment);
}
}
else
{
exprt indexed_symbol_expr(ID_symbol, symbol.type);

indexed_symbol_expr.set(
ID_identifier, timeframe_identifier(t, symbol.name));
Comment on lines +73 to +76
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this not use symbol_exprt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change, as separate PR.


exprt value_expr = decision_procedure.get(indexed_symbol_expr);
if(value_expr == indexed_symbol_expr)
value_expr = nil_exprt();

trans_tracet::statet::assignmentt assignment;
assignment.rhs.swap(value_expr);
assignment.lhs = symbol.symbol_expr();

state.assignments.push_back(assignment);
}
}
}
}
Expand Down