[dv] dvsim -t xrun enhancement
Today I tried running OT on a different laptop with Cadence XLM tool. I made small mistakes (call it rusted due to out of touch with OT flow) and one of them is:
util/dvsim/dvsim.py -t xrun hw/ip/uart/dv/uart_sim_cfg.hjson -i uart_smoke -r 1
I was sure that -t was wrong, but wanted to see what happens and I got:
INFO: [dvsim] [proj_root]: /home/srini/proj/OpenTitan/Git_OT_Google/opentitan
CRITICAL: [utils] Failed to parse "/home/srini/proj/OpenTitan/Git_OT_Google/opentitan/hw/dv/tools/dvsim/xrun.hjson" possibly due to bad path or syntax error.
[Errno 2] No such file or directory: '/home/srini/proj/OpenTitan/Git_OT_Google/opentitan/hw/dv/tools/dvsim/xrun.hjson'
How about 2 enhancements:
- Add xrun as some sort of alias to xcelium - as more users are familiar with the term xrun (and is easier to type :-) )
- dvsim can give better error message here.
Thanks
Will probably take the option 2 route.
I think we've intentionally avoided dvsim having a list of known simulators. But we could probably do something like check for a file that should exist for a supported simulator, and give a helpful error message if it doesn't. Here, it would be something like hw/dv/tools/dvsim/{tool}.hjson.
I've taken another look, and a tidier error message would be quite difficult. As things stand, dvsim's Python code doesn't know anything about known tools. In fact, the tools/dvsim/{tool}.hjson file gets included by common_sim_cfg.hjson, so the Python code itself doesn't even know the directory where it expects the file to exist.
The current behaviour looks like this:
$ util/dvsim/dvsim.py hw/top_earlgrey/dv/chip_sim_cfg.hjson --tool=foo
INFO: [dvsim] [proj_root]: /home/rjs/work/opentitan
CRITICAL: [utils] Failed to parse "/home/rjs/work/opentitan/hw/dv/tools/dvsim/foo.hjson" possibly due to bad path or syntax error.
[Errno 2] No such file or directory: '/home/rjs/work/opentitan/hw/dv/tools/dvsim/foo.hjson'
and I'm not so sure there's something cleaner that we can do, without somehow encoding a "blessed" list of tools in the Python code itself.
Thanks. To an external user such as me, maintaining a "blessed" list of tools in a large project such as OT makes perfect sense, I would understand if your team does not buy-in to that, however.
How about adding an extra line as:
util/dvsim/dvsim.py hw/top_earlgrey/dv/chip_sim_cfg.hjson --tool=foo
INFO: [dvsim] [proj_root]: /home/srini/proj/OpenTitan_Git/ot_rpro/opentitan
CRITICAL: [utils] Maybe an unsupported/incorrect tool option is specified as -t
Failed to parse /home/srini/proj/OpenTitan_Git/ot_rpro/opentitan/hw/dv/tools/dvsim/foo.hjson possibly due to bad path or syntax error.
[Errno 2] No such file or directory: '/home/srini/proj/OpenTitan_Git/ot_rpro/opentitan/hw/dv/tools/dvsim/foo.hjson'
I tweaked/hacked utils.py to be:
except Exception as e:
msg = "Maybe an unsupported/incorrect tool option is specified as -t \n"
msg += "Failed to parse " + hjson_file + " possibly due to bad path or syntax error.\n" + str(e)
log.fatal(msg)
Oof. I've just done a little bit of digging here and things are rather complicated.
The path to the tool-specific path gets inferred from the tool value when expanding common_sim_cfg.hjson. So the dvsim code itself doesn't really know that this particular import comes from --tool.
What's more, the common_sim_cfg.hjson file gets included explicitly by all the blocks, so the dvsim tool doesn't theoretically even know how --tool gets translated to "an hjson file that must exist".
I can think of two possible "right answers":
- Make dvsim a little more constrained and teach it that an hjson file whose name is based on
--toolmust always exist in some particular place. That would solve this problem, but it's rather ugly and potentially stops dvsim becoming more configurable in the future. - Add (yet another) new
hjsonkey, which allows the user to give something like a map from include path to error message. That would allowcommon_sim_cfg.hjsonto say "if {tool}.hjson doesn't exist, complain about the --tool argument".