@@ -2433,12 +2433,11 @@ void print_verilog_port(std::ostream& os, size_t& unconn_count, const std::strin
2433
2433
}
2434
2434
};
2435
2435
2436
- // Port name
2437
- os << indent (depth) << " ." << port_name << " (" ;
2438
-
2439
2436
// Pins
2440
2437
if (nets.size () == 1 ) {
2441
2438
// Single-bit port
2439
+ // Port name
2440
+ os << indent (depth) << " ." << port_name << " (" ;
2442
2441
if (nets[0 ].empty ()) {
2443
2442
// Disconnected
2444
2443
if (type == PortType::INPUT || type == PortType::CLOCK) {
@@ -2451,6 +2450,7 @@ void print_verilog_port(std::ostream& os, size_t& unconn_count, const std::strin
2451
2450
// Connected
2452
2451
os << escape_verilog_identifier (nets[0 ]);
2453
2452
}
2453
+ os << " )" ;
2454
2454
} else {
2455
2455
// Check if all pins are unconnected
2456
2456
bool all_unconnected = true ;
@@ -2467,10 +2467,10 @@ void print_verilog_port(std::ostream& os, size_t& unconn_count, const std::strin
2467
2467
// Empty connection
2468
2468
} else {
2469
2469
// Individual bits
2470
- os << " {"
2471
- << " \n " ;
2472
2470
for (int ipin = (int )nets.size () - 1 ; ipin >= 0 ; --ipin) { // Reverse order to match endianess
2473
- os << indent (depth + 1 );
2471
+ // Port name
2472
+ std::string name = port_name + " [" + std::to_string (ipin) + " ]" ;
2473
+ os << indent (depth) << " ." << escape_verilog_identifier (name) << " (" ;
2474
2474
if (nets[ipin].empty ()) {
2475
2475
// Disconnected
2476
2476
if (type == PortType::INPUT || type == PortType::CLOCK) {
@@ -2486,15 +2486,14 @@ void print_verilog_port(std::ostream& os, size_t& unconn_count, const std::strin
2486
2486
// Connected
2487
2487
os << escape_verilog_identifier (nets[ipin]);
2488
2488
}
2489
+ os << " )" ;
2489
2490
if (ipin != 0 ) {
2490
2491
os << " ," ;
2491
2492
}
2492
2493
os << " \n " ;
2493
2494
}
2494
- os << indent (depth) + " }" ;
2495
2495
}
2496
2496
}
2497
- os << " )" ;
2498
2497
}
2499
2498
2500
2499
// /@brief Escapes the given identifier to be safe for verilog
0 commit comments