From 88e1b4382640ee4e907e06572fe6794bc925f344 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Sun, 15 Sep 2019 14:12:32 +0200 Subject: [PATCH] Removed unneccessary clock input for memory components --- .../ModelAm2900MainMemoryAdapter.java | 3 +-- ...elAm2900MicroInstructionMemoryAdapter.java | 3 +-- .../CoreMicroInstructionMemory.java | 24 ++++++++----------- .../ModelMicroInstructionMemory.java | 8 +------ .../memory/CoreWordAddressableMemory.java | 11 +++------ .../memory/ModelWordAddressableMemory.java | 8 +------ .../memory/WordAddressableMemoryTest.java | 6 +---- 7 files changed, 18 insertions(+), 45 deletions(-) diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/ModelAm2900MainMemoryAdapter.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/ModelAm2900MainMemoryAdapter.java index 5c4f52f2..ef1e58c1 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/ModelAm2900MainMemoryAdapter.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/ModelAm2900MainMemoryAdapter.java @@ -28,9 +28,8 @@ public class ModelAm2900MainMemoryAdapter implements ComponentAdapter 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(); diff --git a/net.mograsim.machine/src/net/mograsim/machine/mi/components/ModelMicroInstructionMemory.java b/net.mograsim.machine/src/net/mograsim/machine/mi/components/ModelMicroInstructionMemory.java index 34e7e806..58dc4d06 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/mi/components/ModelMicroInstructionMemory.java +++ b/net.mograsim.machine/src/net/mograsim/machine/mi/components/ModelMicroInstructionMemory.java @@ -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; diff --git a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/CoreWordAddressableMemory.java b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/CoreWordAddressableMemory.java index addb34cb..afad26ab 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/CoreWordAddressableMemory.java +++ b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/CoreWordAddressableMemory.java @@ -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(); diff --git a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelWordAddressableMemory.java b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelWordAddressableMemory.java index 7e5296d4..edb56668 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelWordAddressableMemory.java +++ b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelWordAddressableMemory.java @@ -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; diff --git a/net.mograsim.machine/test/net/mograsim/machine/standard/memory/WordAddressableMemoryTest.java b/net.mograsim.machine/test/net/mograsim/machine/standard/memory/WordAddressableMemoryTest.java index 02a4090d..7b50d120 100644 --- a/net.mograsim.machine/test/net/mograsim/machine/standard/memory/WordAddressableMemoryTest.java +++ b/net.mograsim.machine/test/net/mograsim/machine/standard/memory/WordAddressableMemoryTest.java @@ -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) -- 2.17.1