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

[Arcilator] Allow running verif.simulation ops #8233

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

fabianschuiki
Copy link
Contributor

Add the LowerVerifSimulations pass to the Arc dialect. This pass converts any verif.simulation ops in the input into a test harness module and a func.func that instantiates the module and applies the necessary stimulus to it using arc.sim.* ops.

Also add the pass to the arcilator pipeline. This allows the user to run any verif.simulation ops in the input design by specifying the --run --jit-entry=<simulation-name> command line options. We may want to streamline this in the future.

Also add an integration test which verifies an adder circuit and prints the simulation results.

@fabianschuiki fabianschuiki added Arc Involving the `arc` dialect verif labels Feb 12, 2025
@fabianschuiki fabianschuiki force-pushed the fschuiki/arcilator-verif-simulation branch from 8a3a802 to 5a66259 Compare February 12, 2025 20:48
%failure = seq.compreg %6, %clock reset %init, %false : i1
%6 = comb.or %failure, %5 : i1

// Print some statistics about the test.
Copy link
Member

Choose a reason for hiding this comment

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

Nice use of DPI!

Copy link
Member

@maerhart maerhart left a comment

Choose a reason for hiding this comment

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

Really cool work! 😎


SmallVector<StringAttr> symbols;
getOperation().walk([&](verif::SimulationOp op) {
auto *symbolTableOp = SymbolTable::getNearestSymbolTable(op);
Copy link
Member

Choose a reason for hiding this comment

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

Is there a need to have verif.simulation nested in arbitrary ops or could we require builtin.module as parent to simplify this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would definitely be an option! I wasn't entirely sure though if we support HWModules nested in other operations – I think we might, for stuff like sv.ifdef and similar. But we could definitely just force the verif.* tests to be in a builtin.module.

lib/Dialect/Arc/Transforms/LowerVerifSimulations.cpp Outdated Show resolved Hide resolved
lib/Dialect/Arc/Transforms/LowerVerifSimulations.cpp Outdated Show resolved Hide resolved
lib/Dialect/Arc/Transforms/LowerVerifSimulations.cpp Outdated Show resolved Hide resolved
lib/Dialect/Arc/Transforms/LowerVerifSimulations.cpp Outdated Show resolved Hide resolved
Comment on lines +176 to +183
// Compute `exit_code | (exit_code != 0)` as a way of guaranteeing that
// the exit code will be non-zero even if bits are truncated by the operating
// system.
Copy link
Member

Choose a reason for hiding this comment

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

Smart way to deal with the fact that exit typically ANDs with 0xFF. Maybe worth mentioning in the simulation op documentation that on non-zero exit code the least significant bit is always set? But I guess also not really, because we are very vague about that anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'm less and less convinced that we should actually have a multi-bit exit code at all. Maybe a success line would be better…

test/Dialect/Arc/lower-verif-simulations.mlir Show resolved Hide resolved
lib/Dialect/Arc/Transforms/LowerVerifSimulations.cpp Outdated Show resolved Hide resolved
integration_test/arcilator/JIT/verif-simulation.mlir Outdated Show resolved Hide resolved
@fabianschuiki fabianschuiki force-pushed the fschuiki/verif-simulation branch from 2ab5136 to d99eb7a Compare February 13, 2025 21:43
@fabianschuiki fabianschuiki force-pushed the fschuiki/arcilator-verif-simulation branch from 5a66259 to bdf9e04 Compare February 13, 2025 21:43
Base automatically changed from fschuiki/verif-simulation to main February 14, 2025 16:18
@fabianschuiki fabianschuiki force-pushed the fschuiki/arcilator-verif-simulation branch from bdf9e04 to 588a431 Compare February 14, 2025 16:20
Add the `LowerVerifSimulations` pass to the Arc dialect. This pass
converts any `verif.simulation` ops in the input into a test harness
module and a `func.func` that instantiates the module and applies the
necessary stimulus to it using `arc.sim.*` ops.

Also add the pass to the arcilator pipeline. This allows the user to
run any `verif.simulation` ops in the input design by specifying the
`--run --jit-entry=<simulation-name>` command line options. We may want
to streamline this in the future.

Also add an integration test which verifies an adder circuit and prints
the simulation results.
@fabianschuiki fabianschuiki force-pushed the fschuiki/arcilator-verif-simulation branch from 588a431 to 61bb05d Compare February 18, 2025 18:15
@fabianschuiki fabianschuiki merged commit c017dff into main Feb 18, 2025
5 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/arcilator-verif-simulation branch February 18, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arc Involving the `arc` dialect verif
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants