Fixed a bug in Am2900; created dlatch8/80; relayouted some components
[Mograsim.git] / net.mograsim.machine / src / net / mograsim / machine / Memory.java
1 package net.mograsim.machine;
2
3 public interface Memory<T>
4 {
5         /**
6          * @param address The address of the desired data. Must be non-negative
7          * @return The data at the requested address
8          * 
9          * @throws IndexOutOfBoundsException
10          */
11         public T getCell(long address);
12
13         /**
14          * Sets the data at the supplied address
15          * 
16          * @throws IndexOutOfBoundsException
17          */
18         public void setCell(long address, T data);
19
20         public default long size()
21         {
22                 MemoryDefinition def = getDefinition();
23                 return Long.max(0, def.getMaximalAddress() - def.getMinimalAddress() + 1);
24         }
25
26         /**
27          * Registers an observer to be notified when a memory cell is modified
28          */
29         public void registerObserver(MemoryObserver ob);
30
31         public void deregisterObserver(MemoryObserver ob);
32
33         public void notifyObservers(long address);
34
35         public MemoryDefinition getDefinition();
36 }