Search in sources :

Example 6 with BoolTableByteArray

use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.

the class BoolTableExpandedTest method checkTable.

private void checkTable(ArrayList<Signal> in1) {
    ArrayList<Signal> in2 = new Signals("a", "b", "c", "d").list();
    List<Variable> vars = new Vars("a", "b", "c", "d").list();
    check(new BoolTableByteArray(new byte[] { 1, 1, 0, 1 }), in1, in2, vars);
    check(new BoolTableByteArray(new byte[] { 0, 1, 1, 0 }), in1, in2, vars);
    check(new BoolTableByteArray(new byte[] { 1, 0, 0, 1 }), in1, in2, vars);
    check(new BoolTableByteArray(new byte[] { 0, 0, 0, 1 }), in1, in2, vars);
    check(new BoolTableByteArray(new byte[] { 0, 1, 1, 1 }), in1, in2, vars);
}
Also used : Signal(de.neemann.digital.core.Signal) Variable(de.neemann.digital.analyse.expression.Variable) BoolTableByteArray(de.neemann.digital.analyse.quinemc.BoolTableByteArray)

Example 7 with BoolTableByteArray

use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.

the class BuilderExpressionCreatorTest method testMultipleResults.

public void testMultipleResults() throws AnalyseException, FormatterException, ExpressionException {
    BoolTable table = new BoolTableByteArray(new byte[] { 2, 0, 0, 0, 1, 2, 0, 0, 1, 1, 2, 0, 1, 1, 1, 2 });
    TruthTable tt = new TruthTable(vars(4)).addResult("Y", table);
    ExpressionListenerStore els = new ExpressionListenerStore(null);
    new ExpressionCreator(tt).create(els);
    assertEquals(4, els.getResults().size());
}
Also used : BoolTableByteArray(de.neemann.digital.analyse.quinemc.BoolTableByteArray) BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) TruthTable(de.neemann.digital.analyse.TruthTable)

Example 8 with BoolTableByteArray

use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.

the class TruthTableTest method testGetByContext.

public void testGetByContext() throws Exception {
    ArrayList<Variable> vars = Variable.vars(5);
    TruthTable t = new TruthTable(vars).addResult();
    BoolTableByteArray result = (BoolTableByteArray) t.getResult(0);
    for (int i = 0; i < t.getRows(); i++) {
        result.set(i, i % 3);
    }
    ContextFiller fc = new ContextFiller(vars);
    for (int i = 0; i < t.getRows(); i++) {
        fc.setContextTo(i);
        assertEquals(i % 3, t.getByContext(0, fc));
    }
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) BoolTableByteArray(de.neemann.digital.analyse.quinemc.BoolTableByteArray) ContextFiller(de.neemann.digital.analyse.expression.ContextFiller)

Example 9 with BoolTableByteArray

use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.

the class TruthTableTest method testHexExportTwo.

public void testHexExportTwo() throws Exception {
    ArrayList<Variable> vars = Variable.vars(3);
    TruthTable t = new TruthTable(vars).addResult();
    BoolTableByteArray result = (BoolTableByteArray) t.getResult(0);
    for (int i = 0; i < t.getRows(); i++) {
        result.set(i, i % 2);
    }
    t.addResult();
    result = (BoolTableByteArray) t.getResult(1);
    for (int i = 0; i < t.getRows(); i++) {
        result.set(i, (i + 1) % 2);
    }
    StringWriter w = new StringWriter();
    t.saveHex(w);
    w.close();
    assertEquals("v2.0 raw\n" + "2\n" + "1\n" + "2\n" + "1\n" + "2\n" + "1\n" + "2\n" + "1\n", w.toString());
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) BoolTableByteArray(de.neemann.digital.analyse.quinemc.BoolTableByteArray) StringWriter(java.io.StringWriter)

Example 10 with BoolTableByteArray

use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.

the class TruthTableTest method testHexExportSingle.

public void testHexExportSingle() throws Exception {
    ArrayList<Variable> vars = Variable.vars(3);
    TruthTable t = new TruthTable(vars).addResult();
    BoolTableByteArray result = (BoolTableByteArray) t.getResult(0);
    for (int i = 0; i < t.getRows(); i++) {
        result.set(i, i % 2);
    }
    StringWriter w = new StringWriter();
    t.saveHex(w);
    w.close();
    assertEquals("v2.0 raw\n" + "0\n" + "1\n" + "0\n" + "1\n" + "0\n" + "1\n" + "0\n" + "1\n", w.toString());
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) BoolTableByteArray(de.neemann.digital.analyse.quinemc.BoolTableByteArray) StringWriter(java.io.StringWriter)

Aggregations

BoolTableByteArray (de.neemann.digital.analyse.quinemc.BoolTableByteArray)12 Variable (de.neemann.digital.analyse.expression.Variable)6 TruthTable (de.neemann.digital.analyse.TruthTable)4 ContextFiller (de.neemann.digital.analyse.expression.ContextFiller)4 BitSetter (de.neemann.digital.analyse.expression.BitSetter)2 BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)2 Signal (de.neemann.digital.core.Signal)2 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 Expression (de.neemann.digital.analyse.expression.Expression)1 QuineMcCluskey (de.neemann.digital.analyse.quinemc.QuineMcCluskey)1 TableReducer (de.neemann.digital.analyse.quinemc.TableReducer)1 TableRow (de.neemann.digital.analyse.quinemc.TableRow)1