1 package net.mograsim.machine.mi;
3 import java.util.HashSet;
6 import net.mograsim.machine.MemoryObserver;
8 public class AssignableMicroInstructionMemory implements MicroInstructionMemory, MemoryObserver
10 private Set<MemoryObserver> observers = new HashSet<>();
11 MicroInstructionMemory real = null;
13 public AssignableMicroInstructionMemory(StandardMicroInstructionMemory standardMicroInstructionMemory)
15 real = standardMicroInstructionMemory;
16 real.registerObserver(this);
19 public void bind(MicroInstructionMemory real)
21 this.real.deregisterObserver(this);
23 real.registerObserver(this);
27 public MicroInstruction getCell(long address)
29 return real.getCell(address);
33 public void setCell(long address, MicroInstruction data)
35 real.setCell(address, data);
39 public void registerObserver(MemoryObserver ob)
45 public void deregisterObserver(MemoryObserver ob)
51 public void notifyObservers(long address)
53 observers.forEach(o -> o.update(address));
57 public MicroInstructionMemoryDefinition getDefinition()
59 return real.getDefinition();
63 public void update(long address)
65 notifyObservers(address);