Skip to content

Commit 783909e

Browse files
committed
Verilog: introduce verilog_function_callt::is_system_function_call()
To remove the duplication of the logic that detects system function/task identifiers, introduce a method that identifies system task/function call statements.
1 parent 1a1b633 commit 783909e

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
@@ -1413,6 +1413,7 @@ inline verilog_ift &to_verilog_if(exprt &expr)
14131413
return static_cast<verilog_ift &>(expr);
14141414
}
14151415

1416+
/// task or function enable
14161417
class verilog_function_callt:public verilog_statementt
14171418
{
14181419
public:
@@ -1430,7 +1431,9 @@ class verilog_function_callt:public verilog_statementt
14301431
{
14311432
return op0();
14321433
}
1433-
1434+
1435+
bool is_system_function_call() const;
1436+
14341437
exprt::operandst &arguments()
14351438
{
14361439
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)