Fixed a bug in Am2900; created dlatch8/80; relayouted some components
[Mograsim.git] / net.mograsim.machine / src / net / mograsim / machine / mi / components / CoreMicroInstructionMemory.java
index eb47209..7394028 100644 (file)
@@ -13,10 +13,9 @@ import net.mograsim.machine.mi.MicroInstructionMemory;
 
 public class CoreMicroInstructionMemory extends BasicCoreComponent
 {
-       private final ReadWriteEnd                              data;
-       private final ReadEnd                                   address;
-       private final MicroInstructionMemory    memory;
-
+       private final ReadWriteEnd data;
+       private final ReadEnd address;
+       private final MicroInstructionMemory memory;
 
        public CoreMicroInstructionMemory(Timeline timeline, int processTime, MicroInstructionMemory memory, ReadWriteEnd data, ReadEnd address)
        {
@@ -24,6 +23,8 @@ public class CoreMicroInstructionMemory extends BasicCoreComponent
                this.memory = memory;
                this.data = data;
                this.address = address;
+               memory.registerObserver(a -> update());
+               address.registerObserver(this);
        }
 
        public MicroInstructionMemory getMemory()
@@ -46,11 +47,11 @@ public class CoreMicroInstructionMemory extends BasicCoreComponent
        @Override
        protected TimelineEventHandler compute()
        {
-               if(!address.hasNumericValue())
+               if (!address.getValues().isBinary())
                {
-                       return e -> data.feedSignals(Bit.U.toVector(data.width()));//TODO don't always feed U, but decide to feed X or U.
+                       return e -> data.feedSignals(Bit.U.toVector(data.width()));// TODO don't always feed U, but decide to feed X or U.
                }
-               long addressed = address.getUnsignedValue();
+               long addressed = address.getValues().getUnsignedValueLong();
                BitVector storedData = memory.getCell(addressed).toBitVector();
                return e -> data.feedSignals(storedData);
        }