def __getitem__(self, index):
        """Retrieve a memory row for simulation.

        A :class:`MemoryData` object can be indexed with an :class:`int` to construct a special
        value that can be used to read and write the selected memory row in a simulation testbench,
        without having to create a memory port.

        .. tip::

            Even in a simulation, the value returned by this function cannot be used in a module;
            it can only be used with :py:`sim.get()` and :py:`sim.set()`.

        Returns
        -------
        :class:`~amaranth.hdl.Value`, :ref:`assignable <lang-assignable>`
        """
        index = operator.index(index)
        if index not in range(self.depth):
            raise IndexError(f"Index {index} is out of bounds (memory has {self.depth} rows)")
        row = MemoryData._Row(self, index)
        if isinstance(self.shape, ShapeCastable):
            return self.shape(row)
        else:
            return row
Retrieve a memory row for simulation.

        A :class:`MemoryData` object can be indexed with an :class:`int` to construct a special
        value that can be used to read and write the selected memory row in a simulation testbench,
        without having to create a memory port.

        .. tip::

            Even in a simulation, the value returned by this function cannot be used in a module;
            it can only be used with :py:`sim.get()` and :py:`sim.set()`.

        Returns
        -------
        :class:`~amaranth.hdl.Value`, :ref:`assignable <lang-assignable>`
        
amaranth/hdl/_mem.py