Skip to content

Commit

Permalink
[topgen] Add class to load a complete topcfg properly
Browse files Browse the repository at this point in the history
At the moment, topgen simplies serializes the complete topcfg using
hjson.dumps() but this poses a few problems. The biggest one is that
it is a mix of manual conversion to dict (when calling as_dict()
in the various topgen functions) and automatic (when calling _asdict()
from hjson.dumps). Furthermore, it turns out that we are missing some
fields that probably were never added to _asdict().

This commit introduces a new class (CompleteTopCfg) whose sole purpose
is to take the produced Hjson and reconstruct an in-memory topcfg that
is *exactly* equivalent (in Pythonic types) to the ones that was dumped.
This requires to sometimes reconstruct some classes, sometimes not.
Classes that need to be reconstruct get a new method (fromdict) and
the CompleteTopCfg does as much automatic deserializing as possible,
then some manual fixing.

There is also a small tweak to how clock groups are handled: in
alert_lpgs, the clock groups are all elements of the clocks.groups
but because of the naive serializing, a full copy is made. This
commit introduces GroupProxy that behaves like a Group for all
purposes but serializes only to the group name. This makes the
resulting hjson clearer and the deserialization easier.

Since this process is quite fragile, when topgen is running it will
actually check that this works by dumping the Hjson, reloading it
with the CompleteTopCfg and then checking that the two are equivalent.

Signed-off-by: Amaury Pouly <[email protected]>
  • Loading branch information
pamaury committed Jan 7, 2025
1 parent 1dc0bad commit 28efbb6
Show file tree
Hide file tree
Showing 12 changed files with 2,704 additions and 678 deletions.
1,452 changes: 1,125 additions & 327 deletions hw/top_darjeeling/data/autogen/top_darjeeling.gen.hjson

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_aon_n
shadow_path: rstmgr_aon_resets.rst_por_aon_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_aon_shadowed
lpg_path: rstmgr_aon_rst_en.por_aon
clock: aon
}
{
Expand All @@ -92,6 +95,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_n
shadow_path: rstmgr_aon_resets.rst_por_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_shadowed
lpg_path: rstmgr_aon_rst_en.por
parent: por_aon
clock: main
}
Expand All @@ -106,6 +112,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_io_n
shadow_path: rstmgr_aon_resets.rst_por_io_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_io_shadowed
lpg_path: rstmgr_aon_rst_en.por_io
parent: por_aon
clock: io
}
Expand All @@ -120,6 +129,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_io_div2_n
shadow_path: rstmgr_aon_resets.rst_por_io_div2_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_io_div2_shadowed
lpg_path: rstmgr_aon_rst_en.por_io_div2
parent: por_aon
clock: io_div2
}
Expand All @@ -134,6 +146,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_io_div4_n
shadow_path: rstmgr_aon_resets.rst_por_io_div4_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_io_div4_shadowed
lpg_path: rstmgr_aon_rst_en.por_io_div4
parent: por_aon
clock: io_div4
}
Expand All @@ -149,6 +164,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_usb_n
shadow_path: rstmgr_aon_resets.rst_por_usb_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_usb_shadowed
lpg_path: rstmgr_aon_rst_en.por_usb
parent: por_aon
clock: usb
}
Expand All @@ -164,6 +182,9 @@
shadowed: true
sw: false
path: rstmgr_aon_resets.rst_lc_n
shadow_path: rstmgr_aon_resets.rst_lc_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_shadowed
lpg_path: rstmgr_aon_rst_en.lc
parent: lc_src
clock: main
}
Expand All @@ -178,6 +199,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_lc_aon_n
shadow_path: rstmgr_aon_resets.rst_lc_aon_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_aon_shadowed
lpg_path: rstmgr_aon_rst_en.lc_aon
parent: lc_src
clock: aon
}
Expand All @@ -192,6 +216,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_lc_io_n
shadow_path: rstmgr_aon_resets.rst_lc_io_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_io_shadowed
lpg_path: rstmgr_aon_rst_en.lc_io
parent: lc_src
clock: io
}
Expand All @@ -206,6 +233,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_lc_io_div2_n
shadow_path: rstmgr_aon_resets.rst_lc_io_div2_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_io_div2_shadowed
lpg_path: rstmgr_aon_rst_en.lc_io_div2
parent: lc_src
clock: io_div2
}
Expand All @@ -221,6 +251,9 @@
shadowed: true
sw: false
path: rstmgr_aon_resets.rst_lc_io_div4_n
shadow_path: rstmgr_aon_resets.rst_lc_io_div4_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_io_div4_shadowed
lpg_path: rstmgr_aon_rst_en.lc_io_div4
parent: lc_src
clock: io_div4
}
Expand All @@ -236,6 +269,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_lc_usb_n
shadow_path: rstmgr_aon_resets.rst_lc_usb_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_usb_shadowed
lpg_path: rstmgr_aon_rst_en.lc_usb
parent: lc_src
clock: usb
}
Expand All @@ -250,6 +286,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_sys_n
shadow_path: rstmgr_aon_resets.rst_sys_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.sys_shadowed
lpg_path: rstmgr_aon_rst_en.sys
parent: sys_src
clock: main
}
Expand All @@ -264,6 +303,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_sys_io_div4_n
shadow_path: rstmgr_aon_resets.rst_sys_io_div4_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.sys_io_div4_shadowed
lpg_path: rstmgr_aon_rst_en.sys_io_div4
parent: sys_src
clock: io_div4
}
Expand All @@ -278,6 +320,9 @@
shadowed: false
sw: true
path: rstmgr_aon_resets.rst_spi_device_n
shadow_path: rstmgr_aon_resets.rst_spi_device_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.spi_device_shadowed
lpg_path: rstmgr_aon_rst_en.spi_device
parent: lc_src
clock: io_div4
}
Expand All @@ -292,6 +337,9 @@
shadowed: false
sw: true
path: rstmgr_aon_resets.rst_spi_host0_n
shadow_path: rstmgr_aon_resets.rst_spi_host0_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.spi_host0_shadowed
lpg_path: rstmgr_aon_rst_en.spi_host0
parent: lc_src
clock: io_div4
}
Expand All @@ -306,6 +354,9 @@
shadowed: false
sw: true
path: rstmgr_aon_resets.rst_i2c0_n
shadow_path: rstmgr_aon_resets.rst_i2c0_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.i2c0_shadowed
lpg_path: rstmgr_aon_rst_en.i2c0
parent: lc_src
clock: io_div4
}
Expand All @@ -323,6 +374,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_n
shadow_path: rstmgr_aon_resets.rst_por_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_shadowed
lpg_path: rstmgr_aon_rst_en.por
parent: por_aon
clock: main
}
Expand All @@ -337,6 +391,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_io_n
shadow_path: rstmgr_aon_resets.rst_por_io_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_io_shadowed
lpg_path: rstmgr_aon_rst_en.por_io
parent: por_aon
clock: io
}
Expand All @@ -351,6 +408,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_io_div2_n
shadow_path: rstmgr_aon_resets.rst_por_io_div2_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_io_div2_shadowed
lpg_path: rstmgr_aon_rst_en.por_io_div2
parent: por_aon
clock: io_div2
}
Expand All @@ -365,6 +425,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_io_div4_n
shadow_path: rstmgr_aon_resets.rst_por_io_div4_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_io_div4_shadowed
lpg_path: rstmgr_aon_rst_en.por_io_div4
parent: por_aon
clock: io_div4
}
Expand All @@ -380,6 +443,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_por_usb_n
shadow_path: rstmgr_aon_resets.rst_por_usb_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.por_usb_shadowed
lpg_path: rstmgr_aon_rst_en.por_usb
parent: por_aon
clock: usb
}
Expand All @@ -395,6 +461,9 @@
shadowed: true
sw: false
path: rstmgr_aon_resets.rst_lc_n
shadow_path: rstmgr_aon_resets.rst_lc_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_shadowed
lpg_path: rstmgr_aon_rst_en.lc
parent: lc_src
clock: main
}
Expand All @@ -409,6 +478,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_lc_aon_n
shadow_path: rstmgr_aon_resets.rst_lc_aon_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_aon_shadowed
lpg_path: rstmgr_aon_rst_en.lc_aon
parent: lc_src
clock: aon
}
Expand All @@ -423,6 +495,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_lc_io_n
shadow_path: rstmgr_aon_resets.rst_lc_io_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_io_shadowed
lpg_path: rstmgr_aon_rst_en.lc_io
parent: lc_src
clock: io
}
Expand All @@ -437,6 +512,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_lc_io_div2_n
shadow_path: rstmgr_aon_resets.rst_lc_io_div2_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_io_div2_shadowed
lpg_path: rstmgr_aon_rst_en.lc_io_div2
parent: lc_src
clock: io_div2
}
Expand All @@ -452,6 +530,9 @@
shadowed: true
sw: false
path: rstmgr_aon_resets.rst_lc_io_div4_n
shadow_path: rstmgr_aon_resets.rst_lc_io_div4_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_io_div4_shadowed
lpg_path: rstmgr_aon_rst_en.lc_io_div4
parent: lc_src
clock: io_div4
}
Expand All @@ -467,6 +548,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_lc_usb_n
shadow_path: rstmgr_aon_resets.rst_lc_usb_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.lc_usb_shadowed
lpg_path: rstmgr_aon_rst_en.lc_usb
parent: lc_src
clock: usb
}
Expand All @@ -481,6 +565,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_sys_n
shadow_path: rstmgr_aon_resets.rst_sys_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.sys_shadowed
lpg_path: rstmgr_aon_rst_en.sys
parent: sys_src
clock: main
}
Expand All @@ -495,6 +582,9 @@
shadowed: false
sw: false
path: rstmgr_aon_resets.rst_sys_io_div4_n
shadow_path: rstmgr_aon_resets.rst_sys_io_div4_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.sys_io_div4_shadowed
lpg_path: rstmgr_aon_rst_en.sys_io_div4
parent: sys_src
clock: io_div4
}
Expand All @@ -509,6 +599,9 @@
shadowed: false
sw: true
path: rstmgr_aon_resets.rst_spi_device_n
shadow_path: rstmgr_aon_resets.rst_spi_device_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.spi_device_shadowed
lpg_path: rstmgr_aon_rst_en.spi_device
parent: lc_src
clock: io_div4
}
Expand All @@ -523,6 +616,9 @@
shadowed: false
sw: true
path: rstmgr_aon_resets.rst_spi_host0_n
shadow_path: rstmgr_aon_resets.rst_spi_host0_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.spi_host0_shadowed
lpg_path: rstmgr_aon_rst_en.spi_host0
parent: lc_src
clock: io_div4
}
Expand All @@ -537,6 +633,9 @@
shadowed: false
sw: true
path: rstmgr_aon_resets.rst_i2c0_n
shadow_path: rstmgr_aon_resets.rst_i2c0_shadowed_n
shadow_lpg_path: rstmgr_aon_rst_en.i2c0_shadowed
lpg_path: rstmgr_aon_rst_en.i2c0
parent: lc_src
clock: io_div4
}
Expand Down
Loading

0 comments on commit 28efbb6

Please sign in to comment.