mirror of
https://github.com/hneemann/Digital.git
synced 2025-10-01 17:00:34 -04:00
Added outputs for state variables if a circuit is created only if
there is no combinatorial outputs with the same name.
This commit is contained in:
parent
1abd921038
commit
7c9d656c91
@ -37,12 +37,13 @@ public class CircuitBuilder implements BuilderInterface<CircuitBuilder> {
|
|||||||
|
|
||||||
private final VariableVisitor variableVisitor;
|
private final VariableVisitor variableVisitor;
|
||||||
private final ShapeFactory shapeFactory;
|
private final ShapeFactory shapeFactory;
|
||||||
|
private final ArrayList<FragmentVariable> fragmentVariables;
|
||||||
|
private final ArrayList<Fragment> fragments;
|
||||||
|
private final HashSet<String> combinatorialOutputs;
|
||||||
|
private final HashSet<String> createdNets;
|
||||||
|
private final ArrayList<FragmentVisualElement> flipflops;
|
||||||
|
private final boolean useJKff;
|
||||||
private int pos;
|
private int pos;
|
||||||
private ArrayList<FragmentVariable> fragmentVariables;
|
|
||||||
private ArrayList<Fragment> fragments;
|
|
||||||
private HashSet<String> createdNets = new HashSet<>();
|
|
||||||
private ArrayList<FragmentVisualElement> flipflops;
|
|
||||||
private boolean useJKff;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new builder.
|
* Creates a new builder.
|
||||||
@ -67,6 +68,8 @@ public class CircuitBuilder implements BuilderInterface<CircuitBuilder> {
|
|||||||
fragmentVariables = new ArrayList<>();
|
fragmentVariables = new ArrayList<>();
|
||||||
fragments = new ArrayList<>();
|
fragments = new ArrayList<>();
|
||||||
flipflops = new ArrayList<>();
|
flipflops = new ArrayList<>();
|
||||||
|
combinatorialOutputs = new HashSet<>();
|
||||||
|
createdNets = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,6 +86,9 @@ public class CircuitBuilder implements BuilderInterface<CircuitBuilder> {
|
|||||||
name = ((NamedExpression) expression).getName();
|
name = ((NamedExpression) expression).getName();
|
||||||
expression = ((NamedExpression) expression).getExpression();
|
expression = ((NamedExpression) expression).getExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
combinatorialOutputs.add(name);
|
||||||
|
|
||||||
Fragment fr = createFragment(expression);
|
Fragment fr = createFragment(expression);
|
||||||
fragments.add(new FragmentExpression(fr, new FragmentVisualElement(Out.DESCRIPTION, shapeFactory).setAttr(Keys.LABEL, name)));
|
fragments.add(new FragmentExpression(fr, new FragmentVisualElement(Out.DESCRIPTION, shapeFactory).setAttr(Keys.LABEL, name)));
|
||||||
expression.traverse(variableVisitor);
|
expression.traverse(variableVisitor);
|
||||||
@ -346,17 +352,22 @@ public class CircuitBuilder implements BuilderInterface<CircuitBuilder> {
|
|||||||
ArrayList<String> list = new ArrayList<>(createdNets);
|
ArrayList<String> list = new ArrayList<>(createdNets);
|
||||||
Collections.sort(list);
|
Collections.sort(list);
|
||||||
for (String name : list) {
|
for (String name : list) {
|
||||||
VisualElement t = new VisualElement(Tunnel.DESCRIPTION.getName()).setShapeFactory(shapeFactory);
|
String oName = name;
|
||||||
t.getElementAttributes().set(Keys.NETNAME, name);
|
if (name.endsWith("n")) oName = name.substring(0, name.length() - 1);
|
||||||
t.setPos(new Vector(xPos, y));
|
if (!combinatorialOutputs.contains(oName)) {
|
||||||
t.setRotation(2);
|
VisualElement t = new VisualElement(Tunnel.DESCRIPTION.getName()).setShapeFactory(shapeFactory);
|
||||||
circuit.add(t);
|
t.getElementAttributes().set(Keys.NETNAME, name);
|
||||||
VisualElement o = new VisualElement(Out.DESCRIPTION.getName()).setShapeFactory(shapeFactory);
|
t.setPos(new Vector(xPos, y));
|
||||||
o.getElementAttributes().set(Keys.LABEL, name);
|
t.setRotation(2);
|
||||||
o.setPos(new Vector(xPos + SIZE, y));
|
circuit.add(t);
|
||||||
circuit.add(o);
|
VisualElement o = new VisualElement(Out.DESCRIPTION.getName()).setShapeFactory(shapeFactory);
|
||||||
circuit.add(new Wire(new Vector(xPos, y), new Vector(xPos + SIZE, y)));
|
|
||||||
y += SIZE * 2;
|
o.getElementAttributes().set(Keys.LABEL, oName);
|
||||||
|
o.setPos(new Vector(xPos + SIZE, y));
|
||||||
|
circuit.add(o);
|
||||||
|
circuit.add(new Wire(new Vector(xPos, y), new Vector(xPos + SIZE, y)));
|
||||||
|
y += SIZE * 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user