Merge branch 'development' of https://gitlab.lrz.de/lrr-tum/students/eragp-misim...
[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          * @throws IndexOutOfBoundsException
16          */
17         public void setCell(long address, T data);
18         
19         public default long size()
20         {
21                 MemoryDefinition def = getDefinition();
22                 return Long.max(0, def.getMaximalAddress() - def.getMinimalAddress());
23         }
24         
25         /**
26          * Registers an observer to be notified when a memory cell is modified
27          */
28         public void registerObserver(MemoryObserver ob);
29         
30         public void deregisterObserver(MemoryObserver ob);
31         
32         public void notifyObservers(long address);
33         
34         public MemoryDefinition getDefinition();
35 }