Skip to content

Commit fd2ea51

Browse files
Merge pull request #5133 from YosysHQ/krys/functional_ordering
Maintain port ordering for functional backend
2 parents 700ba98 + 6e3922e commit fd2ea51

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

kernel/functional.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,13 @@ class FunctionalIRConstruction {
518518
if (cell->type.in(ID($assert), ID($assume), ID($live), ID($fair), ID($cover), ID($check)))
519519
queue.emplace_back(cell);
520520
}
521-
for (auto wire : module->wires()) {
522-
if (wire->port_input)
521+
// we are relying here on unsorted pools iterating last-in-first-out
522+
for (auto riter = module->ports.rbegin(); riter != module->ports.rend(); ++riter) {
523+
auto *wire = module->wire(*riter);
524+
if (wire && wire->port_input) {
523525
factory.add_input(wire->name, ID($input), Sort(wire->width));
524-
if (wire->port_output) {
526+
}
527+
if (wire && wire->port_output) {
525528
auto &output = factory.add_output(wire->name, ID($output), Sort(wire->width));
526529
output.set_value(enqueue(DriveChunk(DriveChunkWire(wire, 0, wire->width))));
527530
}

0 commit comments

Comments
 (0)