Skip to content

Commit 6376b45

Browse files
authored
Merge pull request #1456 from diffblue/verilog_function_callt_is_system_function_call
Verilog: introduce `verilog_function_callt::is_system_function_call()`
2 parents de4bd43 + 783909e commit 6376b45

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

src/verilog/verilog_expr.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,20 @@ typet verilog_declaratort::merged_type(const typet &declaration_type) const
5050
return result;
5151
}
5252

53+
static bool is_system_function_identifier(const exprt &function)
54+
{
55+
return function.id() == ID_symbol &&
56+
has_prefix(id2string(to_symbol_expr(function).get_identifier()), "$");
57+
}
58+
5359
bool function_call_exprt::is_system_function_call() const
5460
{
55-
return function().id() == ID_symbol &&
56-
has_prefix(
57-
id2string(to_symbol_expr(function()).get_identifier()), "$");
61+
return is_system_function_identifier(function());
62+
}
63+
64+
bool verilog_function_callt::is_system_function_call() const
65+
{
66+
return is_system_function_identifier(function());
5867
}
5968

6069
void verilog_module_sourcet::show(std::ostream &out) const

src/verilog/verilog_expr.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,7 @@ inline verilog_ift &to_verilog_if(exprt &expr)
14431443
return static_cast<verilog_ift &>(expr);
14441444
}
14451445

1446+
/// task or function enable
14461447
class verilog_function_callt:public verilog_statementt
14471448
{
14481449
public:
@@ -1460,7 +1461,9 @@ class verilog_function_callt:public verilog_statementt
14601461
{
14611462
return op0();
14621463
}
1463-
1464+
1465+
bool is_system_function_call() const;
1466+
14641467
exprt::operandst &arguments()
14651468
{
14661469
return op1().operands();

src/verilog/verilog_typecheck.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -869,17 +869,14 @@ Function: verilog_typecheckt::convert_function_call_or_task_enable
869869
void verilog_typecheckt::convert_function_call_or_task_enable(
870870
verilog_function_callt &statement)
871871
{
872-
irep_idt base_name=
873-
to_symbol_expr(statement.function()).get_identifier();
874-
875-
// We ignore everyting that starts with a '$',
876-
// e.g., $display etc
877-
878-
if(!base_name.empty() && base_name[0]=='$')
872+
if(statement.is_system_function_call())
879873
{
874+
// we ignore all of these
880875
}
881876
else
882877
{
878+
irep_idt base_name = to_symbol_expr(statement.function()).get_identifier();
879+
883880
// look it up
884881
const irep_idt full_identifier =
885882
id2string(module_identifier) + "." + id2string(base_name);

0 commit comments

Comments
 (0)