Closed akashlevy closed 4 days ago
Fwiw the ports field on modules is holding the ordered port names too
Should we use that instead? Iterate through port names and get module->wire(port)
?
Should we use that instead? Iterate through port names and get
module->wire(port)
?
That sounds like a nice improvement!
I'm on it :)
Patch looks good to me.
Let’s wait for green CI and merge
What are the reasons/motivation for this change?
write_verilog
is incredibly slow for modules with lots of ports. We have some modules with thousands of ports andwrite_verilog
can take hours to run. Related to issue #3845 perhaps.This is because port dumping is
O(N^2)
runtime, whereN
is the number of ports in the design. This poor runtime behavior arises due to the nestedfor
loop (see lines 2337-2349); each loop can iterate up to the number of ports in the design.Explain how this is achieved.
We reduce the runtime to
O(N)
by pre-building aport_id
towire
vector, then using a singlefor
loop.If applicable, please suggest to reviewers how they can test the change.
Passes all tests.