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);
}
}
{
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);
}
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
@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();
public abstract class ModelMicroInstructionMemory extends ModelMemory
{
- private final Pin addrPin, dataPin, clock;
+ private final Pin addrPin, dataPin;
private CoreMicroInstructionMemory memory;
private final MicroInstructionMemoryDefinition definition;
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();
}
return dataPin;
}
- public Pin getClockPin()
- {
- return clock;
- }
-
public CoreMicroInstructionMemory getCoreMemory()
{
return memory;
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
* @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();
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;
}
@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();
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;
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();
}
return rWPin;
}
- public Pin getClockPin()
- {
- return clock;
- }
-
public void setCoreModelBinding(CoreWordAddressableMemory memory)
{
this.memory = memory;
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)