Skip to content

Commit 2d2eff5

Browse files
committed
[ot] scripts/opentitan: cfggen.py: use the new ot.top module
Signed-off-by: Emmanuel Blot <[email protected]>
1 parent efc7368 commit 2d2eff5

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

scripts/opentitan/cfggen.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def hjload(*_, **__): # noqa: E301
3434
from ot.lc_ctrl.const import LcCtrlConstants
3535
from ot.otp.const import OtpConstants
3636
from ot.otp.secret import OtpSecretConstants
37+
from ot.top import OpenTitanTop
3738
from ot.util.arg import ArgError
3839
from ot.util.log import configure_loggers
3940
from ot.util.misc import alphanum_key, to_bool
@@ -510,18 +511,14 @@ def _generate_pwrmgr(self, cfg: ConfigParser,
510511
def main():
511512
"""Main routine"""
512513
debug = True
513-
top_map = {
514-
'darjeeling': 'dj',
515-
'earlgrey': 'eg',
516-
}
517514
actions = ['config', 'clock']
518515
try:
519516
desc = sys.modules[__name__].__doc__.split('.', 1)[0].strip()
520517
argparser = ArgumentParser(description=f'{desc}.')
521518
files = argparser.add_argument_group(title='Files')
522519
files.add_argument('opentitan', nargs='?', metavar='OTDIR',
523520
help='OpenTitan root directory')
524-
files.add_argument('-T', '--top', choices=top_map.keys(),
521+
files.add_argument('-T', '--top', choices=OpenTitanTop.names,
525522
help='OpenTitan top name')
526523
files.add_argument('-o', '--out', metavar='CFG',
527524
help='Filename of the config file to generate')
@@ -576,7 +573,7 @@ def main():
576573
argparser.error('Top name is required if no top file is '
577574
'specified')
578575
top = f'top_{args.top}'
579-
topvar = top_map[args.top]
576+
topvar = OpenTitanTop.short_name(args.top)
580577
topcfg = joinpath(ot_dir, f'hw/{top}/data/autogen/{top}.gen.hjson')
581578
if not isfile(topcfg):
582579
argparser.error(f"No such file '{topcfg}'")
@@ -589,9 +586,9 @@ def main():
589586
ltop = cfg.top_name
590587
if not ltop:
591588
argparser.error('Unknown top name')
592-
log.info("Top: '%s'", cfg.top_name)
589+
log.info("Top: '%s'", ltop)
593590
ltop = ltop.lower()
594-
topvar = {k.lower(): v for k, v in top_map.items()}.get(ltop)
591+
topvar = OpenTitanTop.short_name(cfg.top_name)
595592
if not topvar:
596593
argparser.error(f'Unsupported top name: {cfg.top_name}')
597594
top = f'top_{ltop}'

0 commit comments

Comments
 (0)