@@ -1349,14 +1349,13 @@ Function: verilog_synthesist::instantiate_port
1349
1349
\*******************************************************************/
1350
1350
1351
1351
void verilog_synthesist::instantiate_port (
1352
- bool is_output,
1353
- const symbol_exprt &port,
1352
+ const module_typet::portt &port,
1354
1353
const exprt &value,
1355
1354
const replace_mapt &replace_map,
1356
1355
const source_locationt &source_location,
1357
1356
transt &trans)
1358
1357
{
1359
- irep_idt port_identifier = port.get_identifier ();
1358
+ irep_idt port_identifier = port.identifier ();
1360
1359
1361
1360
replace_mapt::const_iterator it = replace_map.find (port_identifier);
1362
1361
@@ -1372,7 +1371,7 @@ void verilog_synthesist::instantiate_port(
1372
1371
// Note that the types need not match.
1373
1372
exprt lhs, rhs;
1374
1373
1375
- if (is_output )
1374
+ if (port. output () )
1376
1375
{
1377
1376
lhs = value;
1378
1377
rhs = typecast_exprt::conditional_cast (it->second , value.type ());
@@ -1417,31 +1416,29 @@ void verilog_synthesist::instantiate_ports(
1417
1416
if (inst.connections ().empty ())
1418
1417
return ;
1419
1418
1419
+ auto &module_type = to_module_type (symbol.type );
1420
+
1420
1421
// named port connection?
1421
1422
1422
1423
if (inst.named_port_connections ())
1423
1424
{
1424
- const irept::subt &ports = symbol.type .find (ID_ports).get_sub ();
1425
-
1426
- std::set<irep_idt> output_identifiers;
1427
- for (auto &port : ports)
1428
- if (port.get_bool (ID_output))
1429
- output_identifiers.insert (
1430
- to_symbol_expr ((const exprt &)(port)).get_identifier ());
1425
+ const auto &ports = module_type.ports ();
1426
+ auto port_map = module_type.port_map ();
1431
1427
1432
1428
// no requirement that all ports are connected
1433
1429
for (const auto &connection : inst.connections ())
1434
1430
{
1435
1431
auto &named_connection = to_verilog_named_port_connection (connection);
1436
- const auto &port = to_symbol_expr (named_connection.port ());
1432
+ auto port_it =
1433
+ port_map.find (to_symbol_expr (named_connection.port ()).get_identifier ());
1434
+ CHECK_RETURN (port_it != port_map.end ());
1435
+ auto &port = port_it->second ;
1437
1436
const exprt &value = named_connection.value ();
1438
1437
1439
1438
if (value.is_not_nil ())
1440
1439
{
1441
- bool is_output = output_identifiers.find (port.get_identifier ()) !=
1442
- output_identifiers.end ();
1443
1440
instantiate_port (
1444
- is_output, port, value, replace_map, inst.source_location (), trans);
1441
+ port, value, replace_map, inst.source_location (), trans);
1445
1442
}
1446
1443
}
1447
1444
@@ -1456,17 +1453,15 @@ void verilog_synthesist::instantiate_ports(
1456
1453
1457
1454
// unconnected inputs may be given a default value
1458
1455
for (auto &port : ports)
1459
- if (port.get_bool (ID_input ))
1456
+ if (port.input ( ))
1460
1457
{
1461
- auto &port_symbol_expr = to_symbol_expr ((const exprt &)(port));
1462
- auto identifier = port_symbol_expr.get_identifier ();
1458
+ auto identifier = port.identifier ();
1463
1459
if (connected_ports.find (identifier) == connected_ports.end ())
1464
1460
{
1465
- auto &port_symbol = ns.lookup (port_symbol_expr );
1461
+ auto &port_symbol = ns.lookup (identifier );
1466
1462
if (port_symbol.value .is_not_nil ())
1467
1463
instantiate_port (
1468
- false ,
1469
- port_symbol_expr,
1464
+ port,
1470
1465
port_symbol.value ,
1471
1466
replace_map,
1472
1467
inst.source_location (),
@@ -1476,7 +1471,7 @@ void verilog_synthesist::instantiate_ports(
1476
1471
}
1477
1472
else // just a list without names
1478
1473
{
1479
- const irept::subt &ports = symbol. type . find (ID_ports). get_sub ();
1474
+ const auto &ports = module_type. ports ();
1480
1475
1481
1476
if (inst.connections ().size () != ports.size ())
1482
1477
{
@@ -1485,24 +1480,15 @@ void verilog_synthesist::instantiate_ports(
1485
1480
<< inst.connections ().size ();
1486
1481
}
1487
1482
1488
- irept::subt::const_iterator p_it=
1489
- ports.begin ();
1483
+ auto p_it = ports.begin ();
1490
1484
1491
1485
for (const auto &connection : inst.connections ())
1492
1486
{
1493
1487
DATA_INVARIANT (connection.is_not_nil (), " all ports must be connected" );
1494
1488
1495
- auto &port = to_symbol_expr ((const exprt &)(*p_it));
1496
-
1497
- bool is_output = port.get_bool (ID_output);
1498
-
1499
1489
instantiate_port (
1500
- is_output,
1501
- port,
1502
- connection,
1503
- replace_map,
1504
- inst.source_location (),
1505
- trans);
1490
+ *p_it, connection, replace_map, inst.source_location (), trans);
1491
+
1506
1492
p_it++;
1507
1493
}
1508
1494
}
0 commit comments