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

[WIP] Multi-top SW #24453

Draft
wants to merge 45 commits into
base: master
Choose a base branch
from
Draft

[WIP] Multi-top SW #24453

wants to merge 45 commits into from

Commits on Sep 30, 2024

  1. [bazel,sw] Refactor header generation for IP blocks

    Presently, every IP block exports Rust/C headers using rules in
    `autogen.bzl`. However, this is suboptimal because every time we
    want to make a change, it needs to be replicated in all IP blocks.
    Furthermore, IP blocks should not be concerned about how the hjson
    is used to create register definitions.
    
    This commit create a new macro `autogen_hjson_sw_headers` that every
    IP block must call to create all necessary SW artifacts.
    
    This commit introduces no functional change, all bazel targets are
    still exactly the same as before.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    39c8882 View commit details
    Browse the repository at this point in the history
  2. [topgen] Add missing dependency in BUILD file

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    56810c4 View commit details
    Browse the repository at this point in the history
  3. [topgen] Small code improvement

    The source tree location is computed once at the top, make sure that
    the rest of code uses this location instead of recomputing some path.
    This makes the code more consistent and understandable.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    e67ede3 View commit details
    Browse the repository at this point in the history
  4. [topgen] Include warning in generated C files

    The top-level C library files should include a warning about being
    generated and how they were generated.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    851caee View commit details
    Browse the repository at this point in the history
  5. [topgen] Render a list of clocks in top header

    This list will be useful for the multi-top support.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    0a2aa9d View commit details
    Browse the repository at this point in the history
  6. [topgen] Autogenerate the BUILD file sw/autogen

    Currently, this BUILD file is created manually which is not consistent.
    With this commit, it is now generated from a template. The generated content
    is exactly identical to the current one except for the warning message.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    34e31a9 View commit details
    Browse the repository at this point in the history
  7. [util] Add new tool to generate devicetables from templates

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    6e59764 View commit details
    Browse the repository at this point in the history
  8. [bazel,sw] Add DT header generation for IP blocks

    All IP blocks now generate a new bazel target for the IP-specific
    part of the devicetables.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    24cda4d View commit details
    Browse the repository at this point in the history
  9. [bazel] Collect all DT library for ealrgrey in a single bazel target

    We lack a unified scheme where we put the generated headers (C, rust, DT).
    Therefore we need a manual target for each tops that lists the DT library
    for all IP blocks. Maybe this can be autogenerated in the future.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    6a63bf7 View commit details
    Browse the repository at this point in the history
  10. [bazel] Add rule to autogenerate the top-specific DT code

    This commit introduces a new rule `autogen_dttool` to run the
    `dttool` and generate the top-specific DT code (dt_api.h,
    devicetables.c/h). It also introduces a convenience macro
    `autogen_top_dt` that will run `dttool` and create a necessary
    libraries to write the devicetables library.
    
    There is a small annoyance here due to two details of our
    current flow:
    - dttool needs access to all hjson files, not just the generate
      top configuration, but which hjson files were used is not
      recorded anywhere so it must be manually provided to the rule
    - we don't have a standard naming scheme for IP headers so the
      generate DT definitions are all over the place in hw/ip/<ip>/data,
      sometimes in /data/autogen, and so on. Therefore the devicetables
      depends on some manually specified (`dt_ip_deps`) deps.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    566bb76 View commit details
    Browse the repository at this point in the history
  11. [topgen] Add target in toplevel BUILD file to autogenerate top DT code

    In order to run the dttool using bazel, we need not only to provide
    information about the top but also point to the topgen-generated
    cfg (top_<name>.gen.hjson) AND the IP block hjson. Unfortunately,
    this latter information is currently not recorded anywhere but topgen
    knows it so it can render it in the bazel file.
    
    Note that even topgen cannot reliable generate the list of IP DT
    dependencies without some hacks because of our very inconsistent
    naming scheme. Therefore we for now point to `//hw/<top>:dt_headers`
    which is a manually created list.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    d0162e1 View commit details
    Browse the repository at this point in the history
  12. Regenerate top earlgrey

    All changes in this commit are autogenerated by running:
    ```
    util/topgen.py -t hw/top_earlgrey/data/top_earlgrey.hjson
    ```
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    68b0beb View commit details
    Browse the repository at this point in the history
  13. [bazel] Link devicetables in every opentitan binary

    Signed-off-by: Amaury Pouly <[email protected]>
    Co-authored-by: Alexander Williams <[email protected]>
    pamaury and a-will committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    efaf796 View commit details
    Browse the repository at this point in the history
  14. [make_new_dif] Add support for DT in autogenerated DIF-code

    This commit changes the generator as follows:
    - a new `dif_<ip>_init_from_dt` function to initialize from DT
      instead of from an IO region
    - the dif IRQ names and types are now defines/typedefs to the DT
      types: this ensures compatibility with existing code and an
      incremental transition
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    647da74 View commit details
    Browse the repository at this point in the history
  15. Regenerate DIFs

    All changes in this commit are autogenerated by running:
    ```
    util/make_new_dif.py --mode=regen --only=autogen
    ```
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    fde5716 View commit details
    Browse the repository at this point in the history
  16. [dif] Add devicetable dependency to all DIFs

    This is necessary since the autogen part of DIFs now depends on DT.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    Co-authored-by: Alexander Williams <[email protected]>
    pamaury and a-will committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    a1da913 View commit details
    Browse the repository at this point in the history
  17. [rv_plic,dif,unittest] Add some type casts

    The DT commit changed the type `dif_rv_plic_irq_id_t` from `uint32_t`
    to an enumeration. This makes certain implicit casts in the C++ code
    invalid now.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    ab500c5 View commit details
    Browse the repository at this point in the history
  18. [dif,rv_plic] Make dif_rv_plic_irq_id_t an alias for dt_irq_t

    This is for documentation purposes, to make it clear that DT IRQ
    IDs are PLIC IRQ IDs.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    87d9cff View commit details
    Browse the repository at this point in the history
  19. [tests] Fix i2c_target_smbus_arp_test

    The compiler is not happy about a missing case for kDtI2cIrqCount
    which is obviously invalid. Add a default to please the compiler.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    9d76c43 View commit details
    Browse the repository at this point in the history
  20. [sw] Port aon_timer_irq_test to devicetables

    Signed-off-by: Amaury Pouly <[email protected]>
    Co-authored-by: Alexander Williams <[email protected]>
    pamaury and a-will committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    240b600 View commit details
    Browse the repository at this point in the history
  21. [sw] Port sysrst_ctrl_outputs_test to device tables

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    02414f0 View commit details
    Browse the repository at this point in the history
  22. [bazel] Add a new /hw/top directory to point to the actual top

    In the future, we want SW to depend on top elements without knowing
    which top is it compiled for. The way to achieve this is to introduce
    a layer of indirection: SW would depend on e.g. //hw/top:something
    instead of //hw/top_earlgrey:something. Currently, this commit
    only points everything to earlgrey but more tops can be added in
    the future and the top selection becomes part of the bazel
    configuration using a config_setting.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    5120fb0 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    1dbd018 View commit details
    Browse the repository at this point in the history
  24. WIP englishbreakfast

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    fc8113e View commit details
    Browse the repository at this point in the history
  25. [topgen] Generate device tests in a top-specific directory

    Currently, topgen generates plic_all_irqs_test and alert_test
    in sw/device/tests/autogen. But this is incompatible with multi-top
    so change this behaviour to create a one directory per top in
    sw/device/test/autogen.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    97298e4 View commit details
    Browse the repository at this point in the history
  26. Regenerate top_earlgrey

    This commit contains two changes:
    - regenerate the top using
      util/topgen.py -t hw/top_earlgrey/data/top_earlgrey.hjson
    - manually tell git about the moved files
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    47675dd View commit details
    Browse the repository at this point in the history
  27. [gitignore] Remove ignore lines for english_breakfast

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    f37a75a View commit details
    Browse the repository at this point in the history
  28. Generate top_englishbreakfast

    We now treat english_breakfast as a proper top and we check-in the autogenerated
    files just like earlgrey.
    
    All files were generated using
      util/topgen.py -t hw/top_englishbreakfast/data/top_englishbreakfast.hjson
    and the new files were checked-in.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    6953773 View commit details
    Browse the repository at this point in the history
  29. [english_breakfast] Add BUILD file in data/ for consistency

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    6b2ce51 View commit details
    Browse the repository at this point in the history
  30. [english_breakfast] Create the various top-level BUILD files

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    149efbb View commit details
    Browse the repository at this point in the history
  31. [hw/top] Add support for english_breakfast

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    b4177fb View commit details
    Browse the repository at this point in the history
  32. [dif,pinmux] Add helper function to connect an MIO DT pin/pad.

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    a3e658c View commit details
    Browse the repository at this point in the history
  33. [test_rom] Make test_rom buildable for english breakfast.

    This commit converts just the necessary files to DT to be able
    to build the test_rom for english breakfast.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    4f03305 View commit details
    Browse the repository at this point in the history
  34. [topgen-fusesoc] Modify how the script handles output

    The script previously outputed to a dedicated temporary directory
    and deletes some files before generating them. Now that we are checking
    files in, we need to change this behaviour. The script now doesn't
    remote anything and outputs to hw/<top_name>.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    e50e47e View commit details
    Browse the repository at this point in the history
  35. Regenerate englishbreakfast

    All files were generated by running:
    ```
    ./util/topgen-fusesoc.py --files-root=. --topname=top_englishbreakfast
    ```
    and checking-in new files.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    c012fca View commit details
    Browse the repository at this point in the history
  36. [hw] Make verilator build work for both earlgrey and englishbreakfast

    The two tops do not quite use the same flow, in particular they use
    different flags to specify the fileset. This requires to tweak the
    fusesoc rule to make it more general.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    f3dff16 View commit details
    Browse the repository at this point in the history
  37. [topgen] Fix flake warning

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    6b0cf3a View commit details
    Browse the repository at this point in the history

Commits on Oct 7, 2024

  1. [rom_ctrl,util] Fix scrambling script to handle english breakfast

    The script assumes that scrambling is always enabled but in fact there
    is a setting for that and it is used on english breakfast.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    ca5db86 View commit details
    Browse the repository at this point in the history
  2. [hw/top] Add new config setting to select the top

    This setting is not yet wired with the rest of the build system.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    731f908 View commit details
    Browse the repository at this point in the history
  3. [bazel] Set copt and features on RV transition based on top

    With the upcoming change to use //hw/top:top to select the top,
    the per-top copts and feature will not be set on the command-line
    but instead added when transitioning to build RV targets.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    092a4b6 View commit details
    Browse the repository at this point in the history
  4. [english breakfast] Remove //sw/device:is_english_breakfast

    All select are now changed to use //hw/top:top
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    13bf78a View commit details
    Browse the repository at this point in the history
  5. [verilator] Create verilator exec env aliases in //hw/top

    To avoid a massive duplication, and as a first step toward a new
    exec_env-less system, we will move all exec_env to //hw/top so that
    they work for all tops. The easiest to change is verilator.
    For now, only convert the test_rom_test to point to this new env.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    5edffc8 View commit details
    Browse the repository at this point in the history
  6. [test_framework] Partially port the test framework to the DT

    This is enough to be able to run the test_rom_test in verilator
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    3655b9e View commit details
    Browse the repository at this point in the history

Commits on Oct 8, 2024

  1. [dttool] Add named constants for specific IP instances

    Some IP instances have a name, e.g. sram_ctrl_ret_aon
    and sram_ctrl_main. In some cases, it is important to refer to
    a specific instance, e.g. `kDtSramCtrl[<index of the ret_aon>]`.
    This commit generates names so that one can now do
    `kDtSramCtrl[kDtIndexSramCtrlRetAon]`.
    
    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Oct 8, 2024
    Configuration menu
    Copy the full SHA
    9245313 View commit details
    Browse the repository at this point in the history
  2. [ottf] Use named constant to access sram_ctrl_main

    Signed-off-by: Amaury Pouly <[email protected]>
    pamaury committed Oct 8, 2024
    Configuration menu
    Copy the full SHA
    21ab9f5 View commit details
    Browse the repository at this point in the history