Search in sources :

Example 6 with Parser

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

the class ExpressionListenerOptimizeJKTest method testSimple.

public void testSimple() throws IOException, ParseException, FormatterException, ExpressionException {
    TestEL exp = new TestEL();
    ExpressionListener elojk = new ExpressionListenerOptimizeJK(exp);
    Expression e1, e2;
    elojk.resultFound("Sn+1", e1 = new Parser("(Sn*A)+(!Sn*B)").parse().get(0));
    elojk.resultFound("Sn+1", e2 = new Parser("(Sn*A)+(!C*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)

Example 7 with Parser

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

the class KarnaughMapTest method testSimple2_singleVar.

public void testSimple2_singleVar() throws IOException, ParseException, KarnaughException {
    Expression exp = new Parser("A").parse().get(0);
    KarnaughMap c = new KarnaughMap(Variable.vars(2), exp);
    assertEquals(1, 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 8 with Parser

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

the class KarnaughMapTest method testSimple4.

public void testSimple4() throws IOException, ParseException, KarnaughException {
    Expression exp = new Parser("(¬A ¬C ¬D) ∨ (A B C) ∨ (A ¬B D) ∨ (¬A ¬B C) ∨ (¬B ¬C ¬D)").parse().get(0);
    KarnaughMap c = new KarnaughMap(Variable.vars(4), exp);
    assertEquals(5, 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 9 with Parser

use of de.neemann.digital.analyse.parser.Parser 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());
}
Also used : Expression(de.neemann.digital.analyse.expression.Expression) Parser(de.neemann.digital.analyse.parser.Parser)

Example 10 with Parser

use of de.neemann.digital.analyse.parser.Parser 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;
}
Also used : ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) Expression(de.neemann.digital.analyse.expression.Expression) Model(de.neemann.digital.core.Model) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Circuit(de.neemann.digital.draw.elements.Circuit) ModelCreator(de.neemann.digital.draw.model.ModelCreator) Parser(de.neemann.digital.analyse.parser.Parser) CircuitBuilder(de.neemann.digital.builder.circuit.CircuitBuilder)

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