From 426a1e11700c8a6e3dfd96a49a1fdba5389ec05d Mon Sep 17 00:00:00 2001 From: hneemann Date: Sun, 14 Jul 2024 09:57:16 +0200 Subject: [PATCH] Highlights the input connection port in the multiplexer when the input is selected; closes #1299 --- distribution/ReleaseNotes.txt | 2 ++ src/main/dig/processor/Processor.dig | 22 +++++++++---------- .../digital/draw/shapes/MuxerShape.java | 22 +++++++++++++++++++ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/distribution/ReleaseNotes.txt b/distribution/ReleaseNotes.txt index a1880a35f6..ba2c24bcf5 100644 --- a/distribution/ReleaseNotes.txt +++ b/distribution/ReleaseNotes.txt @@ -7,6 +7,8 @@ HEAD, planned as v0.31 - Allows disabling LED's in the measurement graph - Adds drivers with inverted output - Adds a minified circuit as a new shape for embedded circuits +- Highlights the input connection port in the multiplexer when the + input is selected. - Allows recovering from oscillations. - Supports XDG_CONFIG_HOME environment variable - Fixes a bug in max path len calculation diff --git a/src/main/dig/processor/Processor.dig b/src/main/dig/processor/Processor.dig index 91bfdb1255..d0c36047fe 100644 --- a/src/main/dig/processor/Processor.dig +++ b/src/main/dig/processor/Processor.dig @@ -1,6 +1,6 @@ - 1 + 2 Description @@ -158,10 +158,6 @@ Single-Cycle CPU.}} Clock - - runRealTime - true - Label Clock @@ -777,13 +773,15 @@ Single-Cycle CPU.}} Data - 8000,961,8190,951,a90,a83,a25,a3a,10e1,afc,2bef,3d5f,c21,212f,38f9,3d20,105,116,a30, -a20,aa0,8035,3ac0,4380,2180,3505,2172,3505,2173,3503,3d03,2173,3801,aa3,401a,c01, -c11,c21,8014,2020,38eb,c31,8014,2030,38e6,1991,ffff,3e09,146,165,154,4400,3ddb,a70, -1031,8014,f00,8060,3ab0,c21,c01,8060,3ab0,c31,8014,b00,8060,3ab0,c31,8014,b00,8060, -3ab0,1021,1001,8060,3ab0,1021,1001,8060,3ab0,1031,8014,f00,8060,3ab0,1031,8014,f00, -8060,3ab0,c21,c31,8015,b00,3b0c,8014,2020,3707,8014,2030,3704,4380,2180,3501,c71, -3b0b,143,8014,1c40,242,246,4048,2cfe,ce1,3b0f + 8000,961,8190,951,a90,a83,a25,a3a,10e1,afc,2bef,3d5f,c21,212f +,38f9,3d20,105,116,a30,a20,aa0,8035,3ac0,4380,2180,3505,2172,3505 +,2173,3503,3d03,2173,3801,aa3,401a,c01,c11,c21,8014,2020,38eb +,c31,8014,2030,38e6,1991,ffff,3e09,146,165,154,4400,3ddb,a70,1031 +,8014,f00,8060,3ab0,c21,c01,8060,3ab0,c31,8014,b00,8060,3ab0,c31 +,8014,b00,8060,3ab0,1021,1001,8060,3ab0,1021,1001,8060,3ab0,1031 +,8014,f00,8060,3ab0,1031,8014,f00,8060,3ab0,c21,c31,8015,b00,3b0c +,8014,2020,3707,8014,2030,3704,4380,2180,3501,c71,3b0b,143,8014 +,1c40,242,246,4048,2cfe,ce1,3b0f lastDataFile diff --git a/src/main/java/de/neemann/digital/draw/shapes/MuxerShape.java b/src/main/java/de/neemann/digital/draw/shapes/MuxerShape.java index 862263f3f0..13baf46ca0 100644 --- a/src/main/java/de/neemann/digital/draw/shapes/MuxerShape.java +++ b/src/main/java/de/neemann/digital/draw/shapes/MuxerShape.java @@ -5,6 +5,8 @@ */ package de.neemann.digital.draw.shapes; +import de.neemann.digital.core.ObservableValue; +import de.neemann.digital.core.Value; import de.neemann.digital.core.element.ElementAttributes; import de.neemann.digital.core.element.Keys; import de.neemann.digital.core.element.PinDescriptions; @@ -14,6 +16,7 @@ import de.neemann.digital.draw.graphics.*; import static de.neemann.digital.draw.shapes.GenericShape.SIZE; +import static de.neemann.digital.draw.shapes.GenericShape.SIZE2; /** * The Muxer shape @@ -24,6 +27,8 @@ public class MuxerShape implements Shape { private final PinDescriptions inputs; private final PinDescriptions outputs; private Pins pins; + private ObservableValue selector; + private Value selectorValue; /** * Creates a new instance @@ -58,9 +63,16 @@ public Pins getPins() { @Override public Interactor applyStateMonitor(IOState ioState) { + selector = ioState.getInput(0); return null; } + @Override + public void readObservableValues() { + if (selector != null) + selectorValue = selector.getCopy(); + } + @Override public void drawTo(Graphic graphic, Style heighLight) { graphic.drawPolygon(new Polygon(true) @@ -69,5 +81,15 @@ public void drawTo(Graphic graphic, Style heighLight) { .add(SIZE * 2 - 1, inputCount * SIZE - 5) .add(1, inputCount * SIZE + 4), Style.NORMAL); graphic.drawText(new Vector(3, 2), "0", Orientation.LEFTTOP, Style.SHAPE_PIN); + + if (selectorValue != null) { + int in = (int) selectorValue.getValue() + 1; + Pins p = getPins(); + if (in < p.size()) { + Vector pos = p.get(in).getPos(); + int s = SIZE2 / 2; + graphic.drawCircle(pos.add(-s, -s), pos.add(s, s), Style.THIN); + } + } } }