intel / rohd

The Rapid Open Hardware Development (ROHD) framework is a framework for describing and verifying hardware in the Dart programming language.
https://intel.github.io/rohd-website
BSD 3-Clause "New" or "Revised" License
371 stars 66 forks source link

Avoid module creation for simple constant scenarios in gates #429

Open mkorbel1 opened 10 months ago

mkorbel1 commented 10 months ago

Motivation

Sometimes it's easy to initialize some variable to 0 or 1, and then do multiple operator functions on it afterwards like &, ~, and |. There are some common rules that we can use to avoid creating gates when not necessary. For example:

Skipping over these scenarios would allow for boosts in simulation performance and cleaner generated verilog.

Desired solution

Modify the operator overrides in Logic to avoid creation of Modules if it can instead directly compute a Logic to return (like in above situations).

Note that this won't completely avoid all the applicable scenarios alone since there could be things like 0 assigned to another signal which is then used in a gate. Perhaps some optimization in the generation of verilog after assignment collapsing could help even more.

Alternatives considered

No response

Additional details

No response

mjayasim9 commented 9 months ago

Will work on this!

mkorbel1 commented 9 months ago

We should probably make it impossible to put onto a Const to avoid weird surprises when this optimization happens