use of de.neemann.digital.analyse.expression.Expression in project Digital by hneemann.
the class KarnaughMapTest method testSimple_BUG.
public void testSimple_BUG() throws IOException, ParseException, KarnaughException {
Expression exp = new Parser("(¬A B ¬C) ∨ (A C) ∨ ¬B").parse().get(0);
KarnaughMap c = new KarnaughMap(Variable.vars(3), exp);
assertEquals(3, c.size());
Iterator<KarnaughMap.Cover> it = c.iterator();
assertEquals(1, it.next().getSize());
assertEquals(2, it.next().getSize());
assertEquals(4, it.next().getSize());
}
use of de.neemann.digital.analyse.expression.Expression in project Digital by hneemann.
the class KarnaughMapTest method testBUG_1.
// in 4x4 map a 8 cell block is drawn in wrong orientation
public void testBUG_1() throws IOException, ParseException, KarnaughException {
Expression exp = new Variable("D");
KarnaughMap c = new KarnaughMap(Variable.vars(4), exp);
assertEquals(1, c.size());
KarnaughMap.Cover co = c.iterator().next();
assertTrue(co.isDisconnected());
assertFalse(co.onlyEdges());
assertTrue(co.isVerticalDivided());
exp = new Variable("B");
c = new KarnaughMap(Variable.vars(4), exp);
assertEquals(1, c.size());
co = c.iterator().next();
assertTrue(co.isDisconnected());
assertFalse(co.onlyEdges());
assertFalse(co.isVerticalDivided());
}
use of de.neemann.digital.analyse.expression.Expression in project Digital by hneemann.
the class BuilderExpressionCreatorTest method testSimple.
public void testSimple() throws FormatterException, ExpressionException, ElementNotFoundException, PinException, NodeException, AnalyseException, BacktrackException {
Variable a = v("A");
Variable b = v("B");
Expression xor = or(and(a, not(b)), and(not(a), b));
ExpressionListenerStore els = new ExpressionListenerStore(null);
els.resultFound("xor", xor);
els.close();
Model m = create(els, ExpressionModifier.IDENTITY);
assertEquals(5, m.size());
assertEquals(2, m.findNode(And.class).size());
assertEquals(1, m.findNode(Or.class).size());
assertEquals(2, m.findNode(Not.class).size());
check(m);
m = create(els, new de.neemann.digital.analyse.expression.modify.NAnd());
assertEquals(5, m.size());
assertEquals(2, m.findNode(Not.class).size());
assertEquals(3, m.findNode(NAnd.class).size());
check(m);
m = create(els, new de.neemann.digital.analyse.expression.modify.NOr());
assertEquals(6, m.size());
assertEquals(3, m.findNode(Not.class).size());
assertEquals(3, m.findNode(NOr.class).size());
check(m);
}
use of de.neemann.digital.analyse.expression.Expression in project Digital by hneemann.
the class TestResultTest method getModel.
private Model getModel(String func) throws IOException, ParseException, BuilderException, PinException, NodeException, ElementNotFoundException {
ArrayList<Expression> exp = new Parser(func).parse();
ElementLibrary library = new ElementLibrary();
CircuitBuilder cb = new CircuitBuilder(new ShapeFactory(library));
cb.addCombinatorial("Y", exp.get(0));
Circuit circ = cb.createCircuit();
Model model = new ModelCreator(circ, library).createModel(false);
model.init();
return model;
}
use of de.neemann.digital.analyse.expression.Expression in project Digital by hneemann.
the class DetermineJKStateMachineTest method testSimpleBUG.
public void testSimpleBUG() throws Exception {
Expression e = or(b, nota);
DetermineJKStateMachine jk = new DetermineJKStateMachine("a", e);
assertEquals("1", toStr(jk.getSimplifiedJ()));
assertEquals("¬b", toStr(jk.getSimplifiedK()));
assertFalse(jk.isDFF());
}
Aggregations