@@ -1409,17 +1409,17 @@ Function: verilog_synthesist::instantiate_ports
1409
1409
1410
1410
void verilog_synthesist::instantiate_ports (
1411
1411
const irep_idt &instance,
1412
- const exprt &inst,
1412
+ const verilog_instt::instancet &inst,
1413
1413
const symbolt &symbol,
1414
1414
const replace_mapt &replace_map,
1415
1415
transt &trans)
1416
1416
{
1417
- if (inst.operands ().size ()== 0 )
1417
+ if (inst.connections ().empty () )
1418
1418
return ;
1419
1419
1420
1420
// named port connection?
1421
1421
1422
- if (to_multi_ary_expr ( inst). op0 ().id () == ID_named_port_connection)
1422
+ if (inst. connections (). front ().id () == ID_named_port_connection)
1423
1423
{
1424
1424
const irept::subt &ports = symbol.type .find (ID_ports).get_sub ();
1425
1425
@@ -1430,47 +1430,50 @@ void verilog_synthesist::instantiate_ports(
1430
1430
to_symbol_expr ((const exprt &)(port)).get_identifier ());
1431
1431
1432
1432
// no requirement that all ports are connected
1433
- for (const auto &o_it : inst.operands ())
1433
+ for (const auto &connection : inst.connections ())
1434
1434
{
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 ();
1439
1438
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);
1447
1445
}
1448
1446
}
1449
1447
}
1450
1448
else // just a list without names
1451
1449
{
1452
1450
const irept::subt &ports = symbol.type .find (ID_ports).get_sub ();
1453
1451
1454
- if (inst.operands ().size ()!= ports.size ())
1452
+ if (inst.connections ().size () != ports.size ())
1455
1453
{
1456
1454
throw errort ().with_location (inst.source_location ())
1457
1455
<< " wrong number of ports: expected " << ports.size () << " but got "
1458
- << inst.operands ().size ();
1456
+ << inst.connections ().size ();
1459
1457
}
1460
1458
1461
1459
irept::subt::const_iterator p_it=
1462
1460
ports.begin ();
1463
1461
1464
- for (const auto &o_it : inst.operands ())
1462
+ for (const auto &connection : inst.connections ())
1465
1463
{
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" );
1467
1465
1468
1466
auto &port = to_symbol_expr ((const exprt &)(*p_it));
1469
1467
1470
1468
bool is_output = port.get_bool (ID_output);
1471
1469
1472
1470
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);
1474
1477
p_it++;
1475
1478
}
1476
1479
}
0 commit comments