Skip to content

cxxsim: directly initializing memory #564

Open
@cestrauss

Description

@cestrauss

We currently use code similar to this, in PySim, to re-initialize the memory state in one go, before a sub-test:

from nmigen import Module, Memory
from nmigen.sim import Simulator

m = Module()
mem = Memory(width=64, depth=8)
rdport = mem.read_port()
m.submodules.rdport = rdport


def process():
    yield mem._array[0].eq(0x5432123412345678)
    yield
    # both cxxsim and pysim passes
    assert (yield mem[0]) == 0x5432123412345678
    # only pysim passes
    assert (yield rdport.data) == 0x5432123412345678


for engine in ["pysim", "cxxsim"]:
    sim = Simulator(m, engine=engine)
    sim.add_clock(1e-6)
    sim.add_sync_process(process)
    sim.run()
    print(f"Engine {engine} OK.")

I suppose it's not really a CXXSim bug, since we shouldn't really be writing to some private Memory array. More of a feature request, I guess.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions