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

[dv] Move sim_tops to {tool}.hjson #4366

Merged
merged 1 commit into from
Dec 3, 2020
Merged

Conversation

sriyerg
Copy link
Contributor

@sriyerg sriyerg commented Dec 2, 2020

Fixes #4340.

This change factors sim_tops out of common_sim_cfg.hjson in favor of being placed in {tool}.hjson instead. This is done to support Questa (support for which will be added soon).

The first commit fixes a bug in DVSim (prevent ${..} constuct from being treated as a substitution var).

The second moves sim_tops expansion out of the common hjson and moves it into individual tool-specific hjson. How tops are to be specified is also changed - there is no need to add -top prefix to each top level. This is factored in the tool hjson already.

Copy link
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to discuss the escaping change a bit more carefully, but my sed suggestion should decouple that from getting things working for Questa. Maybe split up the PR to get the Questa side fixed quickly?

wildcard_re = re.compile(r"{([A-Za-z0-9\_]+)}")
wildcard_re = re.compile(r"(?<!\$){([A-Za-z0-9\_]+)}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, ok, but this is a bit magical. I wonder whether it would be better to have some sort of explicit escaping (like Python's format function). So shell code that absolutely needed the braces (unusual) would end up looking like ${{foo}}.

@@ -23,6 +23,8 @@
"-c-opts -I{DSIM_HOME}/include",
"-timescale 1ns/1ps",
"-f {sv_flist}",
// List multiple tops for the simulation. Prepend each top level with `-top`.
'''{eval_cmd} tops=(`echo {sim_tops}`); echo "${tops[@]/#/-top }"''',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we discuss the escaping in the previous commit, you could do this with sed (and no escaping required):

echo {sim_tops} | sed -E 's/(\w+)/-top \1/g'

Maybe split out the previous commit into a separate PR, and we can figure out the best approach for that separately from this change?

Comment on lines 18 to 19
// List multiple tops for the simulation. Prepend each top level with `-top`.
'''{eval_cmd} tops=(`echo {sim_tops}`); echo "${tops[@]/#/-top }"''',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've got two {eval_cmd} lines in this file that both compute the same thing. Maybe put it in a separate variable to avoid the unneeded extra subprocess?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They operate on different variables. This one prefixes -top to top level designs the the other one prefixes -dir to coverage database directories. How would merging the two work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duh, I didn't read this carefully enough! You're completely right.

Copy link
Contributor

@weicaiyang weicaiyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Most simulators accept `-top top1 -top top2` switches at compile time
for indicating top level designs that need to be elaborated. Questa
  unfortunately needs it to be a runtime switch as opposed to build
  time. Support for Questa is in the works.

Signed-off-by: Srikrishna Iyer <sriyer@google.com>
Copy link
Contributor Author

@sriyerg sriyerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I dropped the first commit and replaced the echo with sed.

Comment on lines 18 to 19
// List multiple tops for the simulation. Prepend each top level with `-top`.
'''{eval_cmd} tops=(`echo {sim_tops}`); echo "${tops[@]/#/-top }"''',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They operate on different variables. This one prefixes -top to top level designs the the other one prefixes -dir to coverage database directories. How would merging the two work?

Copy link
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@sriyerg sriyerg merged commit 1c39e33 into lowRISC:master Dec 3, 2020
@sriyerg sriyerg deleted the sim-tops-fix branch December 3, 2020 09:01
sriyerg pushed a commit to sriyerg/opentitan that referenced this pull request Dec 4, 2020
This removes the `-top` switch with the recent changes in lowRISC#4366.

Signed-off-by: Srikrishna Iyer <sriyer@google.com>
sriyerg pushed a commit that referenced this pull request Dec 4, 2020
This removes the `-top` switch with the recent changes in #4366.

Signed-off-by: Srikrishna Iyer <sriyer@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dvsim: QSTA support - sim_tops needs to be moved to run_opts
4 participants