Search in sources :

Example 1 with Parser

use of de.neemann.digital.analyse.parser.Parser in project Digital by hneemann.

the class KarnaughMapTest method testSimple2_singleAnd.

public void testSimple2_singleAnd() throws IOException, ParseException, KarnaughException {
    Expression exp = new Parser("A B").parse().get(0);
    KarnaughMap c = new KarnaughMap(Variable.vars(2), exp);
    assertEquals(1, c.size());
    for (KarnaughMap.Cover co : c) assertEquals(1, co.getSize());
}
Also used : Expression(de.neemann.digital.analyse.expression.Expression) Parser(de.neemann.digital.analyse.parser.Parser)

Example 2 with Parser

use of de.neemann.digital.analyse.parser.Parser in project Digital by hneemann.

the class KarnaughMapTest method testSimple3.

public void testSimple3() throws IOException, ParseException, KarnaughException {
    Expression exp = new Parser("(A ¬C) ∨ (¬A ¬B) ∨ (B C)").parse().get(0);
    KarnaughMap c = new KarnaughMap(Variable.vars(3), exp);
    assertEquals(3, c.size());
    for (KarnaughMap.Cover co : c) assertEquals(2, co.getSize());
}
Also used : Expression(de.neemann.digital.analyse.expression.Expression) Parser(de.neemann.digital.analyse.parser.Parser)

Example 3 with Parser

use of de.neemann.digital.analyse.parser.Parser in project Digital by hneemann.

the class KarnaughMapTest method testSimple2.

public void testSimple2() throws IOException, ParseException, KarnaughException {
    Expression exp = new Parser("(A ¬B) ∨ (¬A B)").parse().get(0);
    KarnaughMap c = new KarnaughMap(Variable.vars(2), exp);
    assertEquals(2, c.size());
    for (KarnaughMap.Cover co : c) assertEquals(1, co.getSize());
}
Also used : Expression(de.neemann.digital.analyse.expression.Expression) Parser(de.neemann.digital.analyse.parser.Parser)

Example 4 with Parser

use of de.neemann.digital.analyse.parser.Parser in project Digital by hneemann.

the class ExpressionListenerJKTest method testSimple.

public void testSimple() throws IOException, ParseException, FormatterException, ExpressionException {
    ExpressionListenerOptimizeJKTest.TestEL exp = new ExpressionListenerOptimizeJKTest.TestEL();
    ExpressionListener elojk = new ExpressionListenerJK(exp);
    Expression e1 = new Parser("(Sn*A)+(!Sn*B)").parse().get(0);
    elojk.resultFound("Sn+1", e1);
    elojk.close();
    assertEquals(3, exp.getList().size());
    assertEquals(e1, exp.getList().get(0));
    assertEquals("B", exp.getList().get(1).toString());
    assertEquals("not(A)", exp.getList().get(2).toString());
}
Also used : Expression(de.neemann.digital.analyse.expression.Expression) Parser(de.neemann.digital.analyse.parser.Parser)

Example 5 with Parser

use of de.neemann.digital.analyse.parser.Parser in project Digital by hneemann.

the class ExpressionListenerOptimizeJKTest method testSimpleSwap.

public void testSimpleSwap() throws IOException, ParseException, FormatterException, ExpressionException {
    TestEL exp = new TestEL();
    ExpressionListener elojk = new ExpressionListenerOptimizeJK(exp);
    Expression e1, e2;
    elojk.resultFound("Sn+1", e2 = new Parser("(Sn*A)+(!C*B)").parse().get(0));
    elojk.resultFound("Sn+1", e1 = new Parser("(Sn*A)+(!Sn*B)").parse().get(0));
    elojk.close();
    assertEquals(1, exp.getList().size());
    assertEquals(e1, exp.getList().get(0));
}
Also used : Expression(de.neemann.digital.analyse.expression.Expression) Parser(de.neemann.digital.analyse.parser.Parser)

Aggregations

Expression (de.neemann.digital.analyse.expression.Expression)11 Parser (de.neemann.digital.analyse.parser.Parser)11 NamedExpression (de.neemann.digital.analyse.expression.NamedExpression)1 CircuitBuilder (de.neemann.digital.builder.circuit.CircuitBuilder)1 Model (de.neemann.digital.core.Model)1 Circuit (de.neemann.digital.draw.elements.Circuit)1 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)1 ModelCreator (de.neemann.digital.draw.model.ModelCreator)1 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)1