Skip to content

Integrate the CXXSim simulator #324

Open
@whitequark

Description

@whitequark

A while ago I've implemented the Yosys cxxrtl backend, which is very similar to the current Python simulator conceptually while being significantly (10-100×) faster, competitive with Verilator.

nMigen should tightly integrate with this simulator, providing an interface identical to that of nmigen.sim.pysim.

CXXSim is currently developed in the cxxsim branch. You are encouraged to try it and report results!

Remaining tasks

See also #531 for Yosys-side view of these tasks.

Blockers (to be completed pre-merge)

  • CXXSim currently builds with -DNDEBUG because RTL contract violations (e.g. out of bounds memory reads) must not crash the host Python process. CXXRTL's VCD library currently ignores contract violations in NDEBUG builds, potentially hiding bugs.
    CXXRTL design is reset (in response to a simulator reset) in an unreliable way because of missing CXXRTL-side API
    VCD hierarchy does not match PySim's (missing top module)
    .gtkw files are not written
    write_vcd(traces=) are ignored
    Reset values of undriven values are ignored
    Simulator-only signals are not present in VCD files (cxxsim: simulator-only signals not included in VCD and GTKWave files #556)
    Resetting CXXRTL design corrupts debug information (cxxsim: random garbage in memory traces #565)
    CXXRTL-side Memory reads/writes from Python testbenches are not implemented in CXXSim (cxxsim: directly initializing memory #564)
    Python testbenches trying to wait on CXXRTL values of certain types trigger assertion failures

Non-blockers (may be completed post-merge)

  • Driving CXXRTL-side clocks of type WIRE does not trigger edge-sensitive logic connected to the clock; only driving clocks of type VALUE works properly
    Enumerated signals appear in their raw form in CXXRTL-generated VCD files
    Compilation fails out of box on macOS (Out-of-box CXXSim fails on MacOS #495); probably on other platforms too

Activity

added this to the 0.3 milestone on Feb 16, 2020
cestrauss

cestrauss commented on Nov 6, 2020

@cestrauss
pinned this issue on Nov 6, 2020
changed the title [-]Integrate cxxrtl simulator[/-] [+]Integrate the CXXSim simulator[/+] on Nov 6, 2020
whitequark

whitequark commented on Dec 3, 2020

@whitequark
MemberAuthor

CXXSim no longer ignores contract violations, and uses an appropriate method to reset the simulation.

Prepending the top module in CXXSim VCD files will require upstream changes, see new task in #531.

whitequark

whitequark commented on Dec 3, 2020

@whitequark
MemberAuthor

VCD hierarchy in CXXSim and PySim now matches.

whitequark

whitequark commented on Dec 5, 2020

@whitequark
MemberAuthor

CXXSim now writes GTKW files.

whitequark

whitequark commented on Dec 8, 2020

@whitequark
MemberAuthor

CXXSim will not support race-free memory read/write operations; see #531 (comment) for details.

modified the milestones: 0.3, 0.4 on Dec 14, 2021
robtaylor

robtaylor commented on Aug 16, 2022

@robtaylor

I'm happy to have a look at it on mac when time is right..

removed this from the 0.4 milestone on Feb 3, 2023
unpinned this issue on Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @whitequark@robtaylor@cestrauss

        Issue actions

          Integrate the CXXSim simulator · Issue #324 · amaranth-lang/amaranth