1 package net.mograsim.machine;
3 public interface Memory<T>
6 * @param address The address of the desired data. Must be non-negative
7 * @return The data at the requested address
9 * @throws IndexOutOfBoundsException
11 public T getCell(long address);
14 * Sets the data at the supplied address
16 * @throws IndexOutOfBoundsException
18 public void setCell(long address, T data);
20 public default long size()
22 MemoryDefinition def = getDefinition();
23 return Long.max(0, def.getMaximalAddress() - def.getMinimalAddress() + 1);
27 * Registers an observer to be notified when a memory cell is modified
29 public void registerCellModifiedListener(MemoryCellModifiedListener ob);
31 public void deregisterCellModifiedListener(MemoryCellModifiedListener ob);
33 public MemoryDefinition getDefinition();
35 public static interface MemoryCellModifiedListener
37 public void update(long address);