Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[multitop] New bazel rules to describe HW #24791

Open
wants to merge 50 commits into
base: master
Choose a base branch
from

Conversation

pamaury
Copy link
Contributor

@pamaury pamaury commented Oct 15, 2024

The goal of this experiment is to design new rules to better describe the HW and eventually get rid of our current usage of all_files targets. The idea is that each IP contains a new target created by opentitan_ip where the RTL, doc and hjson files are listed. Then, those files targets are collected by an opentitan_top rule that puts together the entire list of doc, RTL and hjson files. One this is done, we start replace all direct usages of HW files by reference to this new top target where we selectively extra only the files we need. Eventually this should apply to:

  • all headers (C, rust, multi-top)
  • fusesoc
  • documentation

More is possible, for example we could point to testplans, we could separate RTL from DV, etc
This change will eventually be needed for multi-top because collecting all files as we currently do will not scale.

Finally, this PR contains another change: instead of pointing to //hw/ip/... for headers, we now collect everything in a new package //hw/top. There are several reasons for that:

  • we can start treating all IPs the same way, whether they are in hw/ip or hw/top_/ip/..., autogenerated or not
  • this moves us closer to a bazel-configuration-based top selection which will be used for multi-top
  • it solves the problem of IPs in hw/top that have top-specifiied parameters but those are not accessible when generating headers the way we currently do.

Since there are many IPs to convert and many files to patch, the approach in this PR is to create a script to automate most of the process. All commits before [util] Add script to convert... are manual. The rest is created automatically by the script to convert IPs and uses one by one, except for the last commit is manual.

Important remark: this does not duplicate any information that fusesoc has, this is completely orthogonal and only use coarse-grained globs to gather all files.

TODO:

  • pinmux: if Ipgen pinmux #24808 is merged before, will need to do a few tweaks
  • see if we need to handle the node attribute of previous C/rust headers to select the default register node, or if we need to generate several headers for some IPs (one per node)

TODO in follow-up PRs:

  • cleanup the OTBN python: it's a complete mess, the way data files are handled and the the way it hack sys.path to point to util/ is not great. I couldn't quite get rid of all_files due to that.

@pamaury pamaury force-pushed the multitop_hw branch 4 times, most recently from aa03af3 to 0148575 Compare October 18, 2024 14:37
@pamaury pamaury force-pushed the multitop_hw branch 9 times, most recently from 2a0ca50 to ad3f459 Compare October 29, 2024 13:44
@pamaury pamaury force-pushed the multitop_hw branch 2 times, most recently from 93278aa to 352da59 Compare October 29, 2024 16:22
@pamaury pamaury marked this pull request as ready for review October 29, 2024 20:18
@pamaury pamaury requested review from a team, msfschaffner and vogelpi as code owners October 29, 2024 20:18
@pamaury pamaury requested review from engdoreis and a-will and removed request for a team October 29, 2024 20:18
@pamaury pamaury changed the title [experiment][multitop] New bazel rules to describe HW [multitop] New bazel rules to describe HW Oct 30, 2024
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/entropy_src/data/entropy_src.hjson --top hw/top_earlgrey hw/ip/entropy_src

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/gpio/data/gpio.hjson --top hw/top_earlgrey hw/ip/gpio

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/hmac/data/hmac.hjson --top hw/top_earlgrey hw/ip/hmac

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/i2c/data/i2c.hjson --top hw/top_earlgrey hw/ip/i2c

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/keymgr/data/keymgr.hjson --top hw/top_earlgrey hw/ip/keymgr

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/kmac/data/kmac.hjson --top hw/top_earlgrey hw/ip/kmac

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/lc_ctrl/data/lc_ctrl.hjson --top hw/top_earlgrey hw/ip/lc_ctrl

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/otbn/data/otbn.hjson --top hw/top_earlgrey --keep-all-files hw/ip/otbn

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/otp_ctrl/data/otp_ctrl.hjson --top hw/top_earlgrey hw/ip/otp_ctrl

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/pattgen/data/pattgen.hjson --top hw/top_earlgrey hw/ip/pattgen

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --no-regs --top hw/top_earlgrey hw/ip/prim

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/pwm/data/pwm.hjson --top hw/top_earlgrey hw/ip/pwm

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/rom_ctrl/data/rom_ctrl.hjson --top hw/top_earlgrey hw/ip/rom_ctrl

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/rv_core_ibex/data/rv_core_ibex.hjson --top hw/top_earlgrey hw/ip/rv_core_ibex

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/rv_dm/data/rv_dm.hjson --top hw/top_earlgrey hw/ip/rv_dm

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/rv_timer/data/rv_timer.hjson --top hw/top_earlgrey hw/ip/rv_timer

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/spi_device/data/spi_device.hjson --top hw/top_earlgrey hw/ip/spi_device

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/spi_host/data/spi_host.hjson --top hw/top_earlgrey hw/ip/spi_host

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/sram_ctrl/data/sram_ctrl.hjson --top hw/top_earlgrey hw/ip/sram_ctrl

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/sysrst_ctrl/data/sysrst_ctrl.hjson --top hw/top_earlgrey hw/ip/sysrst_ctrl

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --no-regs --top hw/top_earlgrey hw/ip/tlul

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/uart/data/uart.hjson --top hw/top_earlgrey hw/ip/uart

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/ip/usbdev/data/usbdev.hjson --top hw/top_earlgrey hw/ip/usbdev

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/top_earlgrey/ip/ast/data/ast.hjson --top hw/top_earlgrey hw/top_earlgrey/ip/ast

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --hjson hw/top_earlgrey/ip/sensor_ctrl/data/sensor_ctrl.hjson --top hw/top_earlgrey hw/top_earlgrey/ip/sensor_ctrl

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --no-regs --top hw/top_earlgrey hw/top_earlgrey/ip/xbar

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --no-regs --top hw/top_earlgrey hw/top_earlgrey/ip/xbar_main

Signed-off-by: Amaury Pouly <[email protected]>
This commit was generated by running
/home/pamaury/project/opentitan/util/rewrite_hw.py -v -g --root /home/pamaury/project/opentitan --no-regs --top hw/top_earlgrey hw/top_earlgrey/ip/xbar_peri

Signed-off-by: Amaury Pouly <[email protected]>
This commit switches the HW targets (verilator, bitstream) to use
the target create by `opentitan_top`. This allows to remove many of
the hacky `all_files` targets used everywhere. This commit does keep
a few and even creates some, but tries to adhere to the following
convention: only use `glob()` or `all_files` for sub-directories
that contain no bazel targets and should be passed "as-is" to
fusesoc.

Signed-off-by: Amaury Pouly <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants