mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 07:17:13 -04:00
Probe does no bit size checking
This commit is contained in:
parent
aa711de5e9
commit
4606fe443e
@ -235,6 +235,10 @@ public class Model {
|
||||
return clocks.size() == 1 && breaks.size() == 1;
|
||||
}
|
||||
|
||||
public ArrayList<Signal> getSignals() {
|
||||
return signals;
|
||||
}
|
||||
|
||||
public static class Signal {
|
||||
|
||||
private final String name;
|
||||
|
@ -19,12 +19,6 @@ public class Out implements Element {
|
||||
.addAttribute(AttributeKey.Bits)
|
||||
.addAttribute(AttributeKey.Label);
|
||||
|
||||
public static final ElementTypeDescription PROBEDESCRIPTION
|
||||
= new ElementTypeDescription("Probe", Out.class, "in")
|
||||
.addAttribute(AttributeKey.Rotate)
|
||||
.addAttribute(AttributeKey.Bits)
|
||||
.addAttribute(AttributeKey.Label);
|
||||
|
||||
public static final ElementTypeDescription LEDDESCRIPTION
|
||||
= new ElementTypeDescription("LED", Out.class, "in")
|
||||
.addAttribute(AttributeKey.Rotate)
|
||||
|
51
src/main/java/de/neemann/digital/core/io/Probe.java
Normal file
51
src/main/java/de/neemann/digital/core/io/Probe.java
Normal file
@ -0,0 +1,51 @@
|
||||
package de.neemann.digital.core.io;
|
||||
|
||||
import de.neemann.digital.core.Model;
|
||||
import de.neemann.digital.core.NodeException;
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.element.AttributeKey;
|
||||
import de.neemann.digital.core.element.Element;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.ElementTypeDescription;
|
||||
|
||||
/**
|
||||
* @author hneemann
|
||||
*/
|
||||
public class Probe implements Element {
|
||||
|
||||
|
||||
public static final ElementTypeDescription DESCRIPTION
|
||||
= new ElementTypeDescription("Probe", Probe.class, "in")
|
||||
.addAttribute(AttributeKey.Rotate)
|
||||
.addAttribute(AttributeKey.Label);
|
||||
|
||||
private final String label;
|
||||
private ObservableValue value;
|
||||
|
||||
public Probe(ElementAttributes attributes) {
|
||||
label = attributes.get(AttributeKey.Label);
|
||||
}
|
||||
|
||||
public Probe(int bits) {
|
||||
label = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValue... inputs) throws NodeException {
|
||||
value = inputs[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObservableValue[] getOutputs() {
|
||||
return new ObservableValue[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerNodes(Model model) {
|
||||
model.addSignal(label, value);
|
||||
}
|
||||
|
||||
public ObservableValue getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import de.neemann.digital.core.flipflops.T_FF;
|
||||
import de.neemann.digital.core.io.Const;
|
||||
import de.neemann.digital.core.io.In;
|
||||
import de.neemann.digital.core.io.Out;
|
||||
import de.neemann.digital.core.io.Probe;
|
||||
import de.neemann.digital.core.memory.*;
|
||||
import de.neemann.digital.core.wiring.*;
|
||||
import de.neemann.digital.gui.components.terminal.Terminal;
|
||||
@ -46,7 +47,7 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
add(In.DESCRIPTION, menu);
|
||||
add(Out.DESCRIPTION, menu);
|
||||
add(Out.LEDDESCRIPTION, menu);
|
||||
add(Out.PROBEDESCRIPTION, menu);
|
||||
add(Probe.DESCRIPTION, menu);
|
||||
add(Clock.DESCRIPTION, menu);
|
||||
add(Reset.DESCRIPTION, menu);
|
||||
add(Break.DESCRIPTION, menu);
|
||||
|
@ -9,6 +9,7 @@ import de.neemann.digital.core.element.ElementTypeDescription;
|
||||
import de.neemann.digital.core.io.Const;
|
||||
import de.neemann.digital.core.io.In;
|
||||
import de.neemann.digital.core.io.Out;
|
||||
import de.neemann.digital.core.io.Probe;
|
||||
import de.neemann.digital.core.memory.RAMDualPort;
|
||||
import de.neemann.digital.core.memory.RAMSinglePort;
|
||||
import de.neemann.digital.core.wiring.*;
|
||||
@ -46,7 +47,7 @@ public final class ShapeFactory {
|
||||
map.put(Const.DESCRIPTION.getName(), attr -> new ConstShape(attr.get(AttributeKey.Value)));
|
||||
map.put(Out.DESCRIPTION.getName(), attr -> new OutputShape(attr.get(AttributeKey.Label)));
|
||||
map.put(Out.LEDDESCRIPTION.getName(), attr -> new LEDShape(attr.get(AttributeKey.Label), attr.get(AttributeKey.Color)));
|
||||
map.put(Out.PROBEDESCRIPTION.getName(), attr -> new ProbeShape(attr.get(AttributeKey.Label)));
|
||||
map.put(Probe.DESCRIPTION.getName(), attr -> new ProbeShape(attr.get(AttributeKey.Label)));
|
||||
map.put(Clock.DESCRIPTION.getName(), attr -> new ClockShape(attr.get(AttributeKey.Label)));
|
||||
map.put(Out.SEVENDESCRIPTION.getName(), attr -> new SevenSegShape(attr.get(AttributeKey.Label), attr.get(AttributeKey.Color)));
|
||||
map.put(Out.SEVENHEXDESCRIPTION.getName(), attr -> new SevenSegHexShape(attr.get(AttributeKey.Label), attr.get(AttributeKey.Color)));
|
||||
|
@ -1,58 +0,0 @@
|
||||
package de.neemann.digital.gui;
|
||||
|
||||
import de.neemann.digital.core.Model;
|
||||
import de.neemann.digital.core.ModelEvent;
|
||||
import de.neemann.digital.core.ModelStateObserver;
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.element.AttributeKey;
|
||||
import de.neemann.digital.core.io.In;
|
||||
import de.neemann.digital.core.io.Out;
|
||||
import de.neemann.digital.draw.library.ElementLibrary;
|
||||
import de.neemann.digital.draw.model.ModelDescription;
|
||||
import de.neemann.digital.draw.model.ModelEntry;
|
||||
|
||||
/**
|
||||
* @author hneemann
|
||||
*/
|
||||
public class TraceGenerator implements ModelStateObserver {
|
||||
|
||||
private final Model model;
|
||||
|
||||
public TraceGenerator(ModelDescription modelDescription, Model model, ElementLibrary library) {
|
||||
this.model = model;
|
||||
for (ModelEntry me : modelDescription) {
|
||||
String name = me.getVisualElement().getElementName();
|
||||
if (library.getElementType(name) == In.DESCRIPTION)
|
||||
register(me);
|
||||
if (library.getElementType(name) == Out.DESCRIPTION)
|
||||
register(me);
|
||||
if (library.getElementType(name) == Out.LEDDESCRIPTION)
|
||||
register(me);
|
||||
if (library.getElementType(name) == Out.PROBEDESCRIPTION)
|
||||
register(me);
|
||||
}
|
||||
model.addObserver(this);
|
||||
}
|
||||
|
||||
private void register(ModelEntry me) {
|
||||
ObservableValue value = me.getPins().get(0).getValue();
|
||||
String labelName = me.getVisualElement().getElementAttributes().get(AttributeKey.Label);
|
||||
if (value != null && labelName != null && labelName.length() > 0) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handleEvent(ModelEvent event) {
|
||||
switch (event.getType()) {
|
||||
case STEP:
|
||||
break;
|
||||
case STOPPED:
|
||||
model.removeObserver(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user