Search in sources :

Example 26 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class FormatToExpressionTest method testFormatExp.

public void testFormatExp() throws Exception {
    Variable a = v("A");
    Variable b = v("B");
    Expression e = and(not(or(not(a), not(b))), not(and(not(a), not(b))));
    assertEquals("!(!A || !B) && !(!A && !B)", FormatToExpression.FORMATTER_JAVA.format(e));
    assertEquals("\\nicht{\\nicht{A} \\oder \\nicht{B}} \\und \\nicht{\\nicht{A} \\und \\nicht{B}}", FormatToExpression.FORMATTER_LATEX.format(e));
    assertEquals("NOT (NOT A OR NOT B) AND NOT (NOT A AND NOT B)", FormatToExpression.FORMATTER_DERIVE.format(e));
    assertEquals("~(~A + ~B) ~(~A ~B)", FormatToExpression.FORMATTER_LOGISIM.format(e));
    assertEquals("¬(¬A ∨ ¬B) ∧ ¬(¬A ∧ ¬B)", FormatToExpression.FORMATTER_UNICODE.format(e));
    assertEquals("!(!A + !B) * !(!A * !B)", FormatToExpression.FORMATTER_SHORT.format(e));
    assertEquals("!(!A + !B) !(!A !B)", FormatToExpression.FORMATTER_SHORTER.format(e));
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) NamedExpression(de.neemann.digital.analyse.expression.NamedExpression)

Example 27 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class FormatToExpressionTest method testFormatExpNot.

public void testFormatExpNot() throws Exception, FormatterException {
    Variable a = new Variable("A");
    Expression e = not(a);
    assertEquals("¬A", FormatToExpression.FORMATTER_UNICODE.format(e));
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) NamedExpression(de.neemann.digital.analyse.expression.NamedExpression)

Example 28 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class FormatToExpressionTest method testFormatTable.

public void testFormatTable() throws Exception {
    Variable a = new Variable("A");
    Variable b = new Variable("B");
    Expression e = and(not(or(not(a), not(b))), not(and(not(a), not(b))));
    assertEquals("AB|Y\n" + "00|0\n" + "01|0\n" + "10|0\n" + "11|1\n", new FormatToTable().format(e));
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) NamedExpression(de.neemann.digital.analyse.expression.NamedExpression)

Example 29 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class FormatToExpressionTest method testFormatLatex.

public void testFormatLatex() throws Exception {
    Variable a = new Variable("A");
    Variable b = new Variable("B");
    Expression e = and(not(or(not(a), not(b))), not(and(not(a), not(b))));
    assertEquals("\\begin{tabular}{cc|c}\n" + "$A$&$B$&$Y$\\\\\n" + "\\hline\n" + "0&0&0\\\\\n" + "0&1&0\\\\\n" + "1&0&0\\\\\n" + "1&1&1\\\\\n" + "\\end{tabular}\n", new FormatToTableLatex().format(e));
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) NamedExpression(de.neemann.digital.analyse.expression.NamedExpression)

Example 30 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class FormatToExpressionTest method testFormatExp2.

public void testFormatExp2() throws Exception {
    Variable a = v("A");
    Variable b = v("B");
    Variable c = v("C");
    Expression e = or(and(a, not(b), c), and(a, not(b), not(c)));
    assertEquals("(A !B C) + (A !B !C)", FormatToExpression.FORMATTER_SHORTER.format(e));
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) NamedExpression(de.neemann.digital.analyse.expression.NamedExpression)

Aggregations

Variable (de.neemann.digital.analyse.expression.Variable)51 Expression (de.neemann.digital.analyse.expression.Expression)34 ContextFiller (de.neemann.digital.analyse.expression.ContextFiller)10 NamedExpression (de.neemann.digital.analyse.expression.NamedExpression)8 ArrayList (java.util.ArrayList)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 BoolTableByteArray (de.neemann.digital.analyse.quinemc.BoolTableByteArray)6 FormatToExpression (de.neemann.digital.analyse.expression.format.FormatToExpression)5 TestExecuter (de.neemann.digital.TestExecuter)4 Circuit (de.neemann.digital.draw.elements.Circuit)4 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)4 ModelCreator (de.neemann.digital.draw.model.ModelCreator)4 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)4 ExpressionException (de.neemann.digital.analyse.expression.ExpressionException)3 BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)3 TableReducer (de.neemann.digital.analyse.quinemc.TableReducer)3 TruthTable (de.neemann.digital.analyse.TruthTable)2 FormatterException (de.neemann.digital.analyse.expression.format.FormatterException)2 FuseMapFillerException (de.neemann.digital.builder.jedec.FuseMapFillerException)2 JedecWriter (de.neemann.digital.builder.jedec.JedecWriter)2