[topgen] Use OrderedDicts in more places
In Python 3.5, dicts are not ordered. This causes issues when
regenerating output generated by iterating over a dict, which happens
frequently in topgen.
This commit comprehensively spreads the use of OrderedDict in topgen
such that we can re-generate tops in CI (which uses python 3.5) without
issues.
Signed-off-by: Sam Elliott <selliott@lowrisc.org>
diff --git a/util/topgen.py b/util/topgen.py
index 338d869..08f5e74 100755
--- a/util/topgen.py
+++ b/util/topgen.py
@@ -498,36 +498,36 @@
# This includes two groups of clocks
# Clocks fed from the always-on source
# Clocks fed to the powerup group
- ft_clks = {
- clk: src
+ ft_clks = OrderedDict([
+ (clk, src)
for grp in grps for (clk, src) in grp['clocks'].items()
if src_aon_attr[src] or grp['name'] == 'powerup'
- }
+ ])
# root-gate clocks
- rg_clks = {
- clk: src
+ rg_clks = OrderedDict([
+ (clk, src)
for grp in grps for (clk, src) in grp['clocks'].items()
if grp['name'] != 'powerup' and grp['sw_cg'] == 'no' and
not src_aon_attr[src]
- }
+ ])
# direct sw control clocks
- sw_clks = {
- clk: src
+ sw_clks = OrderedDict([
+ (clk, src)
for grp in grps for (clk, src) in grp['clocks'].items()
if grp['sw_cg'] == 'yes' and not src_aon_attr[src]
- }
+ ])
# sw hint clocks
- hint_clks = {
- clk: src
+ hint_clks = OrderedDict([
+ (clk, src)
for grp in grps for (clk, src) in grp['clocks'].items()
if grp['sw_cg'] == 'hint' and not src_aon_attr[src]
- }
+ ])
- out = StringIO()
for idx, tpl in enumerate(tpls):
+ out = ""
with tpl.open(mode='r', encoding='UTF-8') as fin:
tpl = Template(fin.read())
try: