X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Feditors%2FSimulationViewEditor.java;h=4dd346bda8bcc1f0d0912741b23a965351fb6c5d;hb=894ae8a03d4ce70978078b74a33c71063ef05335;hp=f83dfa7631f786e8abb584cc9cc58cf20c12bcda;hpb=2751f62b61e692c1dbc90b708114c5b50a73d7c0;p=Mograsim.git diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/SimulationViewEditor.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/SimulationViewEditor.java index f83dfa76..4dd346bd 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/SimulationViewEditor.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/SimulationViewEditor.java @@ -29,8 +29,13 @@ import net.mograsim.logic.core.components.CoreClock; import net.mograsim.logic.model.LogicExecuter; import net.mograsim.logic.model.LogicUICanvas; import net.mograsim.machine.Machine; +import net.mograsim.machine.Memory.MemoryCellModifiedListener; +import net.mograsim.machine.mi.AssignableMicroInstructionMemory; import net.mograsim.plugin.nature.MachineContext; import net.mograsim.plugin.nature.ProjectMachineContext; +import net.mograsim.plugin.tables.DisplaySettings; +import net.mograsim.plugin.tables.mi.ActiveInstructionPreviewContentProvider; +import net.mograsim.plugin.tables.mi.InstructionTable; //TODO what if we open multiple editors? //TODO actually save / load register and latch states @@ -48,6 +53,8 @@ public class SimulationViewEditor extends EditorPart private LogicUICanvas canvas; private Label noMachineLabel; + private MemoryCellModifiedListener currentRegisteredCellListener; + @Override public void createPartControl(Composite parent) { @@ -79,13 +86,27 @@ public class SimulationViewEditor extends EditorPart sbseButton.setEnabled(true); pauseButton.setEnabled(true); simSpeedSlider.setEnabled(true); + + if (machine != null) + machine.getMicroInstructionMemory().deregisterCellModifiedListener(currentRegisteredCellListener); + machine = machineOptional.get(); canvas = new LogicUICanvas(parent, SWT.NONE, machine.getModel()); + canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(canvas); userInput.buttonDrag = 3; userInput.buttonZoom = 2; userInput.enableUserInput(); + // initialize Instruction preview + InstructionTable instPreview = new InstructionTable(parent, new DisplaySettings()); + instPreview.getTableViewer().getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + instPreview.setContentProvider(new ActiveInstructionPreviewContentProvider(instPreview.getTableViewer())); + AssignableMicroInstructionMemory mIMemory = machine.getMicroInstructionMemory(); + instPreview.bindMicroInstructionMemory(mIMemory); + currentRegisteredCellListener = a -> instPreview.refresh(); + mIMemory.registerCellModifiedListener(currentRegisteredCellListener); + GridData uiData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH); canvas.setLayoutData(uiData); @@ -113,11 +134,13 @@ public class SimulationViewEditor extends EditorPart if (((CoreClock) o).isOn()) { exec.pauseLiveExecution(); - Display.getDefault().asyncExec(() -> - { - pauseButton.setSelection(false); - setPauseText(pauseButton, false); - }); + if (!pauseButton.isDisposed()) + Display.getDefault().asyncExec(() -> + { + if (!pauseButton.isDisposed()) + pauseButton.setSelection(false); + setPauseText(pauseButton, false); + }); } };