YosysHQ / yosys

Yosys Open SYnthesis Suite
https://yosyshq.net/yosys/
ISC License
3.42k stars 872 forks source link

box_derive: New command to derive modules for boxes #4404

Closed povik closed 4 months ago

povik commented 4 months ago

In certain uses cases you want to derive modules for blackbox instances, which are otherwise ignored by the hierarchy process. Here we add a new command, box_derive, by which one can ask to have modules derived for a selected set of blackbox instances.

I can think of two use cases:

An incomplete test is attached.

povik commented 4 months ago

Help sample (updated after rename):


    box_derive [-base <base_module>] [-naming_attr <attr>] [selection]

As part of the assembly of the design hierarchy done by the 'hierarchy' command,
specializations of parametric modules are derived on demand: for each choice of
parameter values appearing in the design, a copy of the parametric module is
derived which is specialized to that choice.

This derivation process ignores blackboxes and whiteboxes (boxes). To supplement,
this 'box_derive' command can be used to request the derivation of modules based
on box instances appearing in the design, which is desirable in certain use
cases. Only the selected cells are considered as the instances that steer the
derivation process.

    -base <base_module>
        instead of deriving the module that directly corresponds to each box
        instance, derive a specialization of <base_module> (this option applies
        to all selected box cells)

    -naming_attr <attr>
        once a specialization is derived, use the value of the module attribute
        <attr> for a name which should be used for the derived module (this
        replaces the internal Yosys naming scheme in which the names of derived
        modules start with '$paramod$')
povik commented 4 months ago

Bikeshed: should this not be called just blackbox_derive? We have blackbox already, so it'd be inconsistent otherwise.

I don't have a strong preference, you could say this shouldn't be blackbox_derive because that gets to be too long.

povik commented 4 months ago

box_derive also an option

whitequark commented 4 months ago

box_derive seems nice, considering you also handle whiteboxes.