Skip to content

Be more careful with variants in OneShotCfg.gen_results - #159

Merged
rswarbrick merged 1 commit into
lowRISC:masterfrom
rswarbrick:variants-in-one-shot-cfg
Apr 6, 2026
Merged

rswarbrick merged 1 commit into
lowRISC:masterfrom
rswarbrick:variants-in-one-shot-cfg

Conversation

@rswarbrick

Copy link
Copy Markdown
Contributor

We don't necessarily know that all sub-configurations are of type SimCfg. Indeed, this failed for me at runtime when trying an FPV test.

We also don't know (from the types) that the sub-configuration defines _gen_results. Practically speaking, it does, so let's just move this to an explicit runtime check, which quiets the type checker.

# For the latter check, we don't necessarily know that item (the
# configuration that is being run) is a type that defines variant
# at all. If not, we just interpret the variant as None.
item_variant = getattr(item, "variant", None)

@AlexJones0 AlexJones0 Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: do you think variants are a ubiquitous enough concept in DVSim that we should just define self.variant: str | None = None in FlowCfg.__init__? At least for the sim code I've seen them used a lot, but maybe they're just very sim-specific?

From the examples I've seen, such as 32kB and 64kB OpenTitan rom_ctrl variants, it seems like it should be part of any flow?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I think they are! Historically, I suspect they got bolted in to whichever bits of dvsim needed them when the variants feature was added, but there's no reason that we shouldn't structure things sensibly now.

I've opened the cleanup issue as #165.

Comment thread src/dvsim/flow/one_shot.py Outdated
We don't necessarily know that all sub-configurations are of type
SimCfg. Indeed, this failed for me at runtime when trying an FPV test.

We also don't know (from the types) that the sub-configuration defines
_gen_results, because self.cfgs is a list of the base FlowCfg type.
Add a runtime check to make sure the elements are in fact OneShotCfg
instances.

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
@rswarbrick
rswarbrick force-pushed the variants-in-one-shot-cfg branch from 43d95f5 to 9fcca80 Compare April 4, 2026 18:00

@machshev machshev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Thanks @rswarbrick

@rswarbrick
rswarbrick added this pull request to the merge queue Apr 6, 2026
Merged via the queue into lowRISC:master with commit e662759 Apr 6, 2026
6 checks passed
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.

3 participants