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

[chiselsim] Add SimulatorAPI, reduce DefaultSimulator to nothing #4680

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

seldridge
Copy link
Member

@seldridge seldridge commented Feb 12, 2025

Add a new SimulatorAPI trait which provides methods for running
simulations. This will submsume the existing DefaultSimulator.simulate
method and extends it with an "ABI" for how to startup simulations of
Chisel-generated Verilog.

This API includes two methods:

  1. simulateRaw -- This is only usable with RawModules where there is
    no information about the clock and reset. This is the same as
    DefaultSimulator.simulate.

  2. simulate -- This is only usable with Modules where there is a
    defined clock and reset. This is the method which implements an "ABI"
    startup sequence which avoids problems with simulators, time zero
    behavior, and race conditions.

Remove all methods from DefaultSimulator and replace them with methods
provided by the SimulatorAPI. This is change to the unreleased
simulate method for DefaultSimulator in that this will now require a
Module and uses the standard ABI bringup procedure.
EphemeralSimulator is left unchanged.

Release Notes

Add a new ChiselSim trait, SimulatorAPI, which adds methods for running simulations.

@seldridge seldridge requested a review from jackkoenig February 12, 2025 03:10
@seldridge
Copy link
Member Author

@jackkoenig: I'm curious if you have any ideas on how to package up this API. Two options occurred to me:

  1. Just do trait mix-in:
class Foo extneds AnyFunSpec with Matchers with SimulatorAPI with PeekPokeAPI {
  /** body */
}
  1. Wildcard import pattern:
import chisel3.simulator.DefaultSimulator._

If (2), then what should the package/object be?

  1. Something else?

I'd plan to keep EphemeralSimulator around, but deprecate it.

@seldridge seldridge added the Feature New feature, will be included in release notes label Feb 12, 2025
@seldridge
Copy link
Member Author

seldridge commented Feb 12, 2025

Maybe for (3) we call this ChiselSim. I.e., "ChiselSim" is just the collection of APIs that you use for running simulations. I'd then propose two slightly different packagings of it:

package chisel3.simulator

trait ChiselSim extends PeekPokeAPI with SimulatorAPI
package chisel3.simulator.scalatest

import chisel3.simulator.{PeekPokeAPI, SimulatorAPI}

trait ChiselSim extends PeekPokeAPI with SimulatorAPI with WithTestingDirectory /** with other ScalaTest stuff */

Note: this can either or instead use the wildcard import approach with some slight changes to how WithTestingDirectory exposes its implicit in an object instead of in a trait.

@seldridge seldridge changed the title [chiselsim] Add SimulatorAPI, reduce DefaultSimulator to nothin [chiselsim] Add SimulatorAPI, reduce DefaultSimulator to nothing Feb 12, 2025
Add a new `SimulatorAPI` trait which provides methods for running
simulations.  This will submsume the existing `DefaultSimulator.simulate`
method and extends it with an "ABI" for how to startup simulations of
Chisel-generated Verilog.

This API includes two methods:

  1. simulateRaw -- This is only usable with `RawModule`s where there is
  no information about the clock and reset.  This is the same as
  `DefaultSimulator.simulate`.

  2. simulate -- This is only usable with `Module`s where there is a
  defined clock and reset.  This is the method which implements an "ABI"
  startup sequence which avoids problems with simulators, time zero
  behavior, and race conditions.

Signed-off-by: Schuyler Eldridge <[email protected]>
Remove all methods from `DefaultSimulator` and replace them with methods
provided by the `SimulatorAPI`.  This is change to the unreleased
`simulate` method for `DefaultSimulator` in that this will now require a
`Module` and uses the standard ABI bringup procedure.
`EphemeralSimulator` is left unchanged.

Signed-off-by: Schuyler Eldridge <[email protected]>
@seldridge seldridge force-pushed the dev/seldridge/SimulatorAPI branch from 71bb8bf to 98aa78c Compare February 13, 2025 02:33
@seldridge seldridge merged commit 98aa78c into main Feb 13, 2025
15 checks passed
@seldridge seldridge deleted the dev/seldridge/SimulatorAPI branch February 13, 2025 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant