Fixed a bug in Am2900; created dlatch8/80; relayouted some components
[Mograsim.git] / net.mograsim.machine / src / net / mograsim / machine / Memory.java
index e421e47..0ff9bb4 100644 (file)
@@ -9,21 +9,28 @@ public interface Memory<T>
         * @throws IndexOutOfBoundsException
         */
        public T getCell(long address);
-       
+
        /**
         * Sets the data at the supplied address
+        * 
         * @throws IndexOutOfBoundsException
         */
        public void setCell(long address, T data);
-       
-       public long size();
-       
+
+       public default long size()
+       {
+               MemoryDefinition def = getDefinition();
+               return Long.max(0, def.getMaximalAddress() - def.getMinimalAddress() + 1);
+       }
+
        /**
         * Registers an observer to be notified when a memory cell is modified
         */
        public void registerObserver(MemoryObserver ob);
-       
+
        public void deregisterObserver(MemoryObserver ob);
-       
+
        public void notifyObservers(long address);
+
+       public MemoryDefinition getDefinition();
 }