Skip to content

Commit 57743d9

Browse files
committed
wip
1 parent 98d4e82 commit 57743d9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

docs/simulator.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ The :mod:`amaranth.sim` module, also known as the simulator, makes it possible t
77

88
.. todo::
99

10-
- Update memory documentation with explanation of how to simulate memories
1110
- Check what happens when a testbench encounters a glitch and add a test
1211

1312

docs/stdlib/memory.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,17 @@ However, the memory read port is also configured to be *transparent* relative to
171171

172172

173173
Simulation
174-
==========
174+
++++++++++
175175

176-
.. todo::
176+
There are two ways to interact with a memory array in a simulator: requesting a read and/or write port that is used only in a testbench, or directly reading and writing memory contents. In most cases, directly accessing memory contents using :meth:`MemoryData.__getitem__ <amaranth.hdl.MemoryData.__getitem__>` is more convenient.
177177

178-
This section will be written once the simulator itself is documented.
178+
For example, this :doc:`testbench </simulator>` will clear the least significant bit of every memory row:
179+
180+
.. testcode::
181+
182+
async def testbench(ctx):
183+
for index in len(memory.data):
184+
ctx.set(memory.data[index], ctx.get(memory.data[index]) & ~1)
179185

180186

181187
Memory description

0 commit comments

Comments
 (0)