A collection of classes providing simple hardware specification, simulation, tracing, and testing suitable for teaching and research. Simplicity, usability, clarity, and extensibility are the overarching goals, rather than performance or optimization.
The observed behavior of iterating over an inspected memory changes depending on whether it's a normal simulation (Simulation or FastSimulation) or a compiled simulation.
Observe the following program:
import pyrtl
m = pyrtl.MemBlock(32, 32, 'm')
addr = pyrtl.Input(32, 'addr')
out = pyrtl.Output(32, 'out')
w = m[addr]
out <<= w
m[addr] <<= pyrtl.as_wires(w + 10).truncate(32)
Normal Simulation
Given the above, if you simulate it via Simulation and then iterate over the inspected memory, it will only print the key-value pairs of memory addresses it touched during simulation (with the implication that all other memory locations are at their initial value, whatever that may be):
sim = pyrtl.Simulation()
sim.step_multiple({
'addr': [0x0, 0x100, 0x102, 0x2345, 0x100, 0x102]
})
mv = sim.inspect_mem(m)
for addr, value in mv.items():
print(f"{hex(addr)}: {value}")
I think the first version makes much more sense, as it's easier to see through the noise. This means needing to update Compiled Simulation to be more judicious in what key-value pairs are returned during iteration. I've started adding another C function that can be called when the memory is being iterated, which will search for present elements in the hash map that currently represents memory in the C-made DLL.
The observed behavior of iterating over an inspected memory changes depending on whether it's a normal simulation (
Simulation
orFastSimulation
) or a compiled simulation.Observe the following program:
Normal Simulation
Given the above, if you simulate it via
Simulation
and then iterate over the inspected memory, it will only print the key-value pairs of memory addresses it touched during simulation (with the implication that all other memory locations are at their initial value, whatever that may be):Output:
Compiled Simulation
Output:
I think the first version makes much more sense, as it's easier to see through the noise. This means needing to update Compiled Simulation to be more judicious in what key-value pairs are returned during iteration. I've started adding another C function that can be called when the memory is being iterated, which will search for present elements in the hash map that currently represents memory in the C-made DLL.