public class CoreMicroInstructionMemory extends BasicCoreComponent
{
private final ReadWriteEnd data;
- private final ReadEnd address, clock;
+ private final ReadEnd address;
private final MicroInstructionMemory memory;
-
-
- public CoreMicroInstructionMemory(Timeline timeline, int processTime, MicroInstructionMemory memory, ReadWriteEnd data, ReadEnd address, ReadEnd clock)
+
+ 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;
+ memory.registerObserver(a -> update());
+ address.registerObserver(this);
}
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.getValues().isBinary())
{
- 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();
+ long addressed = address.getValues().getUnsignedValueLong();
BitVector storedData = memory.getCell(addressed).toBitVector();
return e -> data.feedSignals(storedData);
}