Skip to content

Commit a9a9214

Browse files
committed
Verilog: helper methods for port connections
Port connections of a module instance can be named or positional. This adds two helper methods to distinguish these two cases.
1 parent 30dfb5f commit a9a9214

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/verilog/verilog_expr.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,18 @@ class verilog_inst_baset : public verilog_module_itemt
854854
return operands();
855855
}
856856

857+
bool positional_port_connections() const
858+
{
859+
return !named_port_connections();
860+
}
861+
862+
bool named_port_connections() const
863+
{
864+
auto &connections = this->connections();
865+
return connections.empty() ||
866+
connections.front().id() == ID_named_port_connection;
867+
}
868+
857869
protected:
858870
using exprt::operands;
859871
};

src/verilog/verilog_synthesis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ void verilog_synthesist::instantiate_ports(
14191419

14201420
// named port connection?
14211421

1422-
if(inst.connections().front().id() == ID_named_port_connection)
1422+
if(inst.named_port_connections())
14231423
{
14241424
const irept::subt &ports = symbol.type.find(ID_ports).get_sub();
14251425

src/verilog/verilog_typecheck.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ void verilog_typecheckt::typecheck_port_connections(
110110
}
111111

112112
// named port connection?
113-
if(
114-
inst.connections().empty() ||
115-
inst.connections().front().id() == ID_named_port_connection)
113+
if(inst.named_port_connections())
116114
{
117115
// We don't require that all ports are connected.
118116

0 commit comments

Comments
 (0)