Skip to content

Commit

Permalink
Highlights the input connection port in the multiplexer when the inpu…
Browse files Browse the repository at this point in the history
…t is selected; closes #1299
  • Loading branch information
hneemann committed Jul 14, 2024
1 parent 7e3ebcd commit 426a1e1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
2 changes: 2 additions & 0 deletions distribution/ReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 10 additions & 12 deletions src/main/dig/processor/Processor.dig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<circuit>
<version>1</version>
<version>2</version>
<attributes>
<entry>
<string>Description</string>
Expand Down Expand Up @@ -158,10 +158,6 @@ Single-Cycle CPU.}}</string>
<visualElement>
<elementName>Clock</elementName>
<elementAttributes>
<entry>
<string>runRealTime</string>
<boolean>true</boolean>
</entry>
<entry>
<string>Label</string>
<string>Clock</string>
Expand Down Expand Up @@ -777,13 +773,15 @@ Single-Cycle CPU.}}</string>
</entry>
<entry>
<string>Data</string>
<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</data>
<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</data>
</entry>
<entry>
<string>lastDataFile</string>
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/de/neemann/digital/draw/shapes/MuxerShape.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
}
}
}

0 comments on commit 426a1e1

Please sign in to comment.