package net.mograsim.machine.mi;
import java.util.HashSet;
-import java.util.Set;
import net.mograsim.machine.standard.memory.MemoryException;
private MicroInstruction[] data;
private MicroInstructionMemoryDefinition definition;
private HashSet<MemoryCellModifiedListener> observers = new HashSet<>();
- private Set<ActiveMicroInstructionChangedListener> activeInstructionListeners = new HashSet<>();
- private long activeInstruction = -1;
public StandardMicroInstructionMemory(MicroInstructionMemoryDefinition definition)
{
observers.remove(ob);
}
- @Override
- public void registerActiveMicroInstructionChangedListener(ActiveMicroInstructionChangedListener ob)
- {
- activeInstructionListeners.add(ob);
- }
-
- @Override
- public void deregisterActiveMicroInstructionChangedListener(ActiveMicroInstructionChangedListener ob)
- {
- activeInstructionListeners.remove(ob);
- }
-
private void notifyMemoryChanged(long address)
{
observers.forEach(ob -> ob.update(address));
}
- private void notifyActiveInstructionChanged(long address)
- {
- activeInstructionListeners.forEach(o -> o.activeMicroInstructionChanged(address));
- }
-
@Override
public MicroInstructionMemoryDefinition getDefinition()
{
return definition;
}
-
- @Override
- public void setActiveInstruction(long address)
- {
- if (address != activeInstruction)
- {
- activeInstruction = address;
- notifyActiveInstructionChanged(address);
- }
- }
-
}