@@ -1409,17 +1409,17 @@ Function: verilog_synthesist::instantiate_ports
14091409
14101410void verilog_synthesist::instantiate_ports (
14111411 const irep_idt &instance,
1412- const exprt &inst,
1412+ const verilog_instt::instancet &inst,
14131413 const symbolt &symbol,
14141414 const replace_mapt &replace_map,
14151415 transt &trans)
14161416{
1417- if (inst.operands ().size ()== 0 )
1417+ if (inst.connections ().empty () )
14181418 return ;
14191419
14201420 // named port connection?
14211421
1422- if (to_multi_ary_expr ( inst). op0 ().id () == ID_named_port_connection)
1422+ if (inst. connections (). front ().id () == ID_named_port_connection)
14231423 {
14241424 const irept::subt &ports = symbol.type .find (ID_ports).get_sub ();
14251425
@@ -1430,47 +1430,50 @@ void verilog_synthesist::instantiate_ports(
14301430 to_symbol_expr ((const exprt &)(port)).get_identifier ());
14311431
14321432 // no requirement that all ports are connected
1433- for (const auto &o_it : inst.operands ())
1433+ for (const auto &connection : inst.connections ())
14341434 {
1435- if (o_it.operands ().size ()==2 )
1436- {
1437- const auto &op0 = to_symbol_expr (to_binary_expr (o_it).op0 ());
1438- const exprt &op1 = to_binary_expr (o_it).op1 ();
1435+ auto &named_connection = to_verilog_named_port_connection (connection);
1436+ const auto &port = to_symbol_expr (named_connection.port ());
1437+ const exprt &value = named_connection.value ();
14391438
1440- if (op1.is_not_nil ())
1441- {
1442- bool is_output = output_identifiers.find (op0.get_identifier ()) !=
1443- output_identifiers.end ();
1444- instantiate_port (
1445- is_output, op0, op1, replace_map, inst.source_location (), trans);
1446- }
1439+ if (value.is_not_nil ())
1440+ {
1441+ bool is_output = output_identifiers.find (port.get_identifier ()) !=
1442+ output_identifiers.end ();
1443+ instantiate_port (
1444+ is_output, port, value, replace_map, inst.source_location (), trans);
14471445 }
14481446 }
14491447 }
14501448 else // just a list without names
14511449 {
14521450 const irept::subt &ports = symbol.type .find (ID_ports).get_sub ();
14531451
1454- if (inst.operands ().size ()!= ports.size ())
1452+ if (inst.connections ().size () != ports.size ())
14551453 {
14561454 throw errort ().with_location (inst.source_location ())
14571455 << " wrong number of ports: expected " << ports.size () << " but got "
1458- << inst.operands ().size ();
1456+ << inst.connections ().size ();
14591457 }
14601458
14611459 irept::subt::const_iterator p_it=
14621460 ports.begin ();
14631461
1464- for (const auto &o_it : inst.operands ())
1462+ for (const auto &connection : inst.connections ())
14651463 {
1466- DATA_INVARIANT (o_it .is_not_nil (), " all ports must be connected" );
1464+ DATA_INVARIANT (connection .is_not_nil (), " all ports must be connected" );
14671465
14681466 auto &port = to_symbol_expr ((const exprt &)(*p_it));
14691467
14701468 bool is_output = port.get_bool (ID_output);
14711469
14721470 instantiate_port (
1473- is_output, port, o_it, replace_map, inst.source_location (), trans);
1471+ is_output,
1472+ port,
1473+ connection,
1474+ replace_map,
1475+ inst.source_location (),
1476+ trans);
14741477 p_it++;
14751478 }
14761479 }
0 commit comments