use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class DependencyAnalyserTest method testBacktrackCompleteness.
public void testBacktrackCompleteness() throws Exception {
ToBreakRunner toBreakRunner = new ToBreakRunner("dig/backtrack/AllComponents.dig", false);
// create a set of all components used in the circuit
Circuit circuit = toBreakRunner.getCircuit();
Set<String> set = new HashSet<>();
for (VisualElement e : circuit.getElements()) set.add(e.getElementName());
// ensure all available components are included in test circuit
for (ElementLibrary.ElementContainer c : toBreakRunner.getLibrary()) {
if (!set.contains(c.getDescription().getName())) {
// nodes with state are allowed to be missing
Element n = c.getDescription().createElement(new ElementAttributes());
boolean ok = (n instanceof Node) && ((Node) n).hasState();
assertTrue("component " + c.getDescription().getName() + " is missing in test/resources/dig/backtrack/AllComponents.dig!", ok);
}
}
// check if backtracking is ok at all components!
ModelAnalyser m = new ModelAnalyser(toBreakRunner.getModel());
new DependencyAnalyser(m);
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class CircuitBuilderTest method testBuilderSequentialJK.
public void testBuilderSequentialJK() throws Exception {
Variable y0 = new Variable("Y_0");
Variable y1 = new Variable("Y_1");
// counter
Expression y0s = not(y0);
Expression y1s = or(not(y0), not(y1));
ElementLibrary library = new ElementLibrary();
Circuit circuit = new CircuitBuilder(new ShapeFactory(library), true).addSequential("Y_0", y0s).addSequential("Y_1", y1s).createCircuit();
ModelCreator m = new ModelCreator(circuit, library);
TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
te.check(0, 0);
te.checkC(1, 1);
te.checkC(0, 0);
te.checkC(1, 1);
te.checkC(0, 0);
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class CircuitBuilderTest method testBus.
public void testBus() throws Exception {
final ToBreakRunner runner = new ToBreakRunner("dig/circuitBuilder/busTest.dig", false);
// create truth table incl. ModelAnalyzerInfo
TruthTable tt = new ModelAnalyser(runner.getModel()).analyse();
assertEquals(8, tt.getVars().size());
assertEquals(8, tt.getResultCount());
// create expressions based on truth table
ExpressionListenerStore expr = new ExpressionListenerStore(null);
new ExpressionCreator(tt).create(expr);
// build a new circuit
CircuitBuilder circuitBuilder = new CircuitBuilder(runner.getLibrary().getShapeFactory(), false, tt.getVars()).setModelAnalyzerInfo(tt.getModelAnalyzerInfo());
new BuilderExpressionCreator(circuitBuilder).create(expr);
Circuit circuit = circuitBuilder.createCircuit();
// check
List<VisualElement> in = circuit.findElements(v -> v.equalsDescription(In.DESCRIPTION));
assertEquals(2, in.size());
checkPin(in.get(0), "A", "1,2,3,4");
checkPin(in.get(1), "B", "5,6,7,8");
List<VisualElement> out = circuit.findElements(v -> v.equalsDescription(Out.DESCRIPTION));
assertEquals(2, out.size());
checkPin(out.get(0), "S", "9,10,11,12");
checkPin(out.get(1), "U", "13,14,15,16");
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class NetListTest method testTunnel3.
public void testTunnel3() throws Exception {
Circuit c = new Circuit();
c.add(new Wire(new Vector(1, 1), new Vector(2, 1)));
addTunnel(c, new Vector(2, 1), "A");
c.add(new Wire(new Vector(3, 1), new Vector(4, 1)));
addTunnel(c, new Vector(3, 1), "A");
addTunnel(c, new Vector(4, 1), "C");
c.add(new Wire(new Vector(1, 4), new Vector(2, 4)));
addTunnel(c, new Vector(2, 4), "B");
addTunnel(c, new Vector(1, 4), "C");
c.add(new Wire(new Vector(3, 4), new Vector(4, 4)));
addTunnel(c, new Vector(3, 4), "B");
NetList ns = new NetList(c);
assertEquals(1, ns.size());
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class NetListTest method testSimple.
public void testSimple() throws Exception {
Circuit c = new Circuit();
c.add(new Wire(new Vector(1, 1), new Vector(1, 2)));
c.add(new Wire(new Vector(2, 1), new Vector(2, 2)));
c.add(new Wire(new Vector(1, 2), new Vector(2, 2)));
c.add(new Wire(new Vector(1, 1), new Vector(2, 1)));
NetList ns = new NetList(c);
assertEquals(1, ns.size());
}
Aggregations