Removed unneccessary clock input for memory components
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Sun, 15 Sep 2019 12:12:32 +0000 (14:12 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Sun, 15 Sep 2019 12:12:42 +0000 (14:12 +0200)
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/ModelAm2900MainMemoryAdapter.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/ModelAm2900MicroInstructionMemoryAdapter.java
net.mograsim.machine/src/net/mograsim/machine/mi/components/CoreMicroInstructionMemory.java
net.mograsim.machine/src/net/mograsim/machine/mi/components/ModelMicroInstructionMemory.java
net.mograsim.machine/src/net/mograsim/machine/standard/memory/CoreWordAddressableMemory.java
net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelWordAddressableMemory.java
net.mograsim.machine/test/net/mograsim/machine/standard/memory/WordAddressableMemoryTest.java

index 5c4f52f..ef1e58c 100644 (file)
@@ -28,9 +28,8 @@ public class ModelAm2900MainMemoryAdapter implements ComponentAdapter<ModelAm290
                ReadWriteEnd data = logicWiresPerPin.get(modelComponent.getDataPin()).createReadWriteEnd();
                ReadEnd address = logicWiresPerPin.get(modelComponent.getAddressPin()).createReadOnlyEnd();
                ReadEnd mode = logicWiresPerPin.get(modelComponent.getReadWritePin()).createReadOnlyEnd();
-               ReadEnd clock = logicWiresPerPin.get(modelComponent.getClockPin()).createReadOnlyEnd();
                CoreWordAddressableMemory mem = new CoreWordAddressableMemory(timeline, 2,
-                               new WordAddressableMemory(modelComponent.getDefinition()), data, mode, address, clock);
+                               new WordAddressableMemory(modelComponent.getDefinition()), data, mode, address);
                modelComponent.setCoreModelBinding(mem);
        }
 }
index fde7321..b390ab5 100644 (file)
@@ -27,9 +27,8 @@ public class ModelAm2900MicroInstructionMemoryAdapter implements ComponentAdapte
        {
                ReadWriteEnd data = logicWiresPerPin.get(modelComponent.getDataPin()).createReadWriteEnd();
                ReadEnd address = logicWiresPerPin.get(modelComponent.getAddressPin()).createReadOnlyEnd();
-               ReadEnd clock = logicWiresPerPin.get(modelComponent.getClockPin()).createReadOnlyEnd();
                CoreMicroInstructionMemory mem = new CoreMicroInstructionMemory(timeline, 2,
-                               new StandardMicroInstructionMemory(modelComponent.getDefinition()), data, address, clock);
+                               new StandardMicroInstructionMemory(modelComponent.getDefinition()), data, address);
                modelComponent.setCoreModelBinding(mem);
        }
 
index 29793c5..eb47209 100644 (file)
@@ -13,29 +13,28 @@ import net.mograsim.machine.mi.MicroInstructionMemory;
 
 public class CoreMicroInstructionMemory extends BasicCoreComponent
 {
-       private final ReadWriteEnd data;
-       private final ReadEnd address, clock;
-       private final MicroInstructionMemory memory;
-       
-       
-       public CoreMicroInstructionMemory(Timeline timeline, int processTime, MicroInstructionMemory memory, ReadWriteEnd data, ReadEnd address, ReadEnd clock)
+       private final ReadWriteEnd                              data;
+       private final ReadEnd                                   address;
+       private final MicroInstructionMemory    memory;
+
+
+       public CoreMicroInstructionMemory(Timeline timeline, int processTime, MicroInstructionMemory memory, ReadWriteEnd data, ReadEnd address)
        {
                super(timeline, processTime);
                this.memory = memory;
                this.data = data;
                this.address = address;
-               this.clock = clock;
        }
 
        public MicroInstructionMemory getMemory()
        {
                return memory;
        }
-       
+
        @Override
        public List<ReadEnd> getAllInputs()
        {
-               return List.of(address, clock);
+               return List.of(address);
        }
 
        @Override
@@ -47,12 +46,9 @@ public class CoreMicroInstructionMemory extends BasicCoreComponent
        @Override
        protected TimelineEventHandler compute()
        {
-               if(clock.getValue() != Bit.ONE)
-                       return null;
-               
-               if (!address.hasNumericValue())
+               if(!address.hasNumericValue())
                {
-                       return e -> data.feedSignals(Bit.U.toVector(data.width()));
+                       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();
                BitVector storedData = memory.getCell(addressed).toBitVector();
index 34e7e80..58dc4d0 100644 (file)
@@ -8,7 +8,7 @@ import net.mograsim.machine.mi.MicroInstructionMemoryDefinition;
 
 public abstract class ModelMicroInstructionMemory extends ModelMemory
 {
-       private final Pin addrPin, dataPin, clock;
+       private final Pin addrPin, dataPin;
        private CoreMicroInstructionMemory memory;
        private final MicroInstructionMemoryDefinition definition;
        
@@ -18,7 +18,6 @@ public abstract class ModelMicroInstructionMemory extends ModelMemory
                this.definition = definition;
                addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, width / 2, 0));
                addPin(dataPin = new Pin(model, this, "D", definition.getMicroInstructionDefinition().sizeInBits(), PinUsage.OUTPUT, 0, 30));
-               addPin(clock = new Pin(model, this, "C", 1, PinUsage.INPUT, 0, 60));
 
                init();
        }
@@ -38,11 +37,6 @@ public abstract class ModelMicroInstructionMemory extends ModelMemory
                return dataPin;
        }
 
-       public Pin getClockPin()
-       {
-               return clock;
-       }
-
        public CoreMicroInstructionMemory getCoreMemory()
        {
                return memory;
index addb34c..afad26a 100644 (file)
@@ -21,7 +21,7 @@ public class CoreWordAddressableMemory extends BasicCoreComponent
        private final static Bit read = Bit.ONE;
 
        private ReadWriteEnd data;
-       private ReadEnd rWBit, address, clock;
+       private ReadEnd rWBit, address;
 
        /**
         * @param data    The bits of this ReadEnd are the value that is written to/read from memory; The bit width of this wire is the width of
@@ -30,7 +30,7 @@ public class CoreWordAddressableMemory extends BasicCoreComponent
         * @param address The bits of this ReadEnd address the memory cell to read/write
         */
        public CoreWordAddressableMemory(Timeline timeline, int processTime, MainMemory memory, ReadWriteEnd data,
-                       ReadEnd rWBit, ReadEnd address, ReadEnd clock)
+                       ReadEnd rWBit, ReadEnd address)
        {
                super(timeline, processTime);
                MainMemoryDefinition definition = memory.getDefinition();
@@ -43,11 +43,9 @@ public class CoreWordAddressableMemory extends BasicCoreComponent
                this.data = data;
                this.rWBit = rWBit;
                this.address = address;
-               this.clock = clock;
                data.registerObserver(this);
                rWBit.registerObserver(this);
                address.registerObserver(this);
-               clock.registerObserver(this);
                
                this.memory = memory;
        }
@@ -55,13 +53,10 @@ public class CoreWordAddressableMemory extends BasicCoreComponent
        @Override
        protected TimelineEventHandler compute()
        {
-               if(clock.getValue() != Bit.ONE)
-                       return null;
-               
                if (!address.hasNumericValue())
                {
                        if (read.equals(rWBit.getValue()))
-                               return e -> data.feedSignals(Bit.U.toVector(data.width()));
+                               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.clearSignals();
                }
                long addressed = address.getUnsignedValue();
index 7e5296d..edb5666 100644 (file)
@@ -8,7 +8,7 @@ import net.mograsim.machine.ModelMemory;
 
 public abstract class ModelWordAddressableMemory extends ModelMemory
 {
-       private final Pin addrPin, dataPin, rWPin, clock;
+       private final Pin addrPin, dataPin, rWPin;
        private CoreWordAddressableMemory memory;
        private MainMemoryDefinition definition;
 
@@ -20,7 +20,6 @@ public abstract class ModelWordAddressableMemory extends ModelMemory
                addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, width, 20));
                addPin(dataPin = new Pin(model, this, "D", definition.getCellWidth(), PinUsage.TRISTATE, width, 50));
                addPin(rWPin = new Pin(model, this, "RW", 1, PinUsage.INPUT, width, 80));
-               addPin(clock = new Pin(model, this, "C", 1, PinUsage.INPUT, width, 110));
 
                init();
        }
@@ -45,11 +44,6 @@ public abstract class ModelWordAddressableMemory extends ModelMemory
                return rWPin;
        }
 
-       public Pin getClockPin()
-       {
-               return clock;
-       }
-
        public void setCoreModelBinding(CoreWordAddressableMemory memory)
        {
                this.memory = memory;
index 02a4090..7b50d12 100644 (file)
@@ -24,17 +24,13 @@ class WordAddressableMemoryTest {
                CoreWire rW = new CoreWire(t, 1, 2);
                CoreWire data = new CoreWire(t, 16, 2);
                CoreWire address = new CoreWire(t, 64, 2);
-               CoreWire clock = new CoreWire(t, 1, 2);
                ReadWriteEnd rWI = rW.createReadWriteEnd();
                ReadWriteEnd dataI = data.createReadWriteEnd();
                ReadWriteEnd addressI = address.createReadWriteEnd();
-               ReadWriteEnd clockI = clock.createReadWriteEnd();
 
                @SuppressWarnings("unused")
                CoreWordAddressableMemory memory = new CoreWordAddressableMemory(t, 4, new WordAddressableMemory(MainMemoryDefinition.create(64, 16, 4096L, Long.MAX_VALUE)), data.createReadWriteEnd(),
-                               rW.createReadOnlyEnd(), address.createReadOnlyEnd(), clock.createReadOnlyEnd());
-
-               clockI.feedSignals(Bit.ONE);
+                               rW.createReadOnlyEnd(), address.createReadOnlyEnd());
                
                Random r = new Random();
                for (long j = 1; j > 0; j *= 2)