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
15 * @throws IndexOutOfBoundsException
17 public void setCell(long address, T data);
19 public default long size()
21 MemoryDefinition def = getDefinition();
22 return Long.max(0, def.getMaximalAddress() - def.getMinimalAddress() + 1);
26 * Registers an observer to be notified when a memory cell is modified
28 public void registerObserver(MemoryObserver ob);
30 public void deregisterObserver(MemoryObserver ob);
32 public void notifyObservers(long address);
34 public MemoryDefinition getDefinition();