Search in sources :

Example 1 with BoolTable

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

the class BuilderExpressionCreatorTest method check.

private void check(Model m) throws AnalyseException, NodeException, BacktrackException, PinException {
    TruthTable tt = new ModelAnalyser(m).analyse();
    m.close();
    assertEquals(1, tt.getResultCount());
    BoolTable r = tt.getResult(0);
    assertEquals(4, r.size());
    assertEquals(ThreeStateValue.zero, r.get(0));
    assertEquals(ThreeStateValue.one, r.get(1));
    assertEquals(ThreeStateValue.one, r.get(2));
    assertEquals(ThreeStateValue.zero, r.get(3));
}
Also used : ModelAnalyser(de.neemann.digital.analyse.ModelAnalyser) TruthTable(de.neemann.digital.analyse.TruthTable) BoolTable(de.neemann.digital.analyse.quinemc.BoolTable)

Example 2 with BoolTable

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

the class BoolTableExpandedTest method testCombined.

public void testCombined() {
    ArrayList<Signal> in1 = new Signals("b", "c").list();
    ArrayList<Signal> in2 = new Signals("a", "b", "c", "d").list();
    List<Variable> vars = new Vars("a", "b", "c", "d").list();
    BoolTableExpanded bt = new BoolTableExpanded(new BoolTableByteArray(new byte[] { 1, 1, 0, 0 }), in1, in2);
    TableReducer tr = new TableReducer(vars, bt);
    assertTrue(tr.canReduce());
    List<Variable> v = tr.getVars();
    assertEquals(1, v.size());
    assertEquals("b", v.get(0).getIdentifier());
    BoolTable t1 = tr.getTable();
    assertEquals(ThreeStateValue.one, t1.get(0));
    assertEquals(ThreeStateValue.zero, t1.get(1));
}
Also used : Signal(de.neemann.digital.core.Signal) Variable(de.neemann.digital.analyse.expression.Variable) BoolTableByteArray(de.neemann.digital.analyse.quinemc.BoolTableByteArray) BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) TableReducer(de.neemann.digital.analyse.quinemc.TableReducer)

Example 3 with BoolTable

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

the class ModelAnalyserTest method testAnalyzerMultiBit.

public void testAnalyzerMultiBit() throws Exception {
    Model model = new ToBreakRunner("dig/analyze/multiBitCounter.dig", false).getModel();
    TruthTable tt = new ModelAnalyser(model).analyse();
    checkTable(tt.getResult("Q0n+1"), one, zero, one, zero);
    checkTable(tt.getResult("Q1n+1"), zero, one, one, zero);
    assertEquals("Y1", tt.getResultName(2));
    assertEquals("Y0", tt.getResultName(3));
    final BoolTable y1 = tt.getResult(2);
    final BoolTable y0 = tt.getResult(3);
    for (int i = 0; i < 4; i++) {
        assertEquals((i & 1) > 0, y0.get(i).invert().bool());
        assertEquals((i & 2) > 0, y1.get(i).invert().bool());
    }
}
Also used : BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 4 with BoolTable

use of de.neemann.digital.analyse.quinemc.BoolTable 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 5 with BoolTable

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

the class BoolTableExpandedTest method check.

private void check(BoolTableByteArray e, ArrayList<Signal> in1, ArrayList<Signal> in2, List<Variable> vars) {
    BoolTableExpanded bt = new BoolTableExpanded(e, in1, in2);
    TableReducer tr = new TableReducer(vars, bt);
    assertTrue(tr.canReduceOnlyCheckTable());
    List<Variable> v = tr.getVars();
    assertEquals(in1.size(), v.size());
    for (int i = 0; i < v.size(); i++) assertEquals(in1.get(i).getName(), v.get(i).getIdentifier());
    BoolTable t1 = tr.getTable();
    assertEquals(e.size(), t1.size());
    for (int r = 0; r < e.size(); r++) assertEquals(e.get(r), t1.get(r));
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) TableReducer(de.neemann.digital.analyse.quinemc.TableReducer)

Aggregations

BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)7 TruthTable (de.neemann.digital.analyse.TruthTable)3 Variable (de.neemann.digital.analyse.expression.Variable)3 BoolTableByteArray (de.neemann.digital.analyse.quinemc.BoolTableByteArray)2 TableReducer (de.neemann.digital.analyse.quinemc.TableReducer)2 Model (de.neemann.digital.core.Model)2 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)2 ModelAnalyser (de.neemann.digital.analyse.ModelAnalyser)1 TruthTableTableModel (de.neemann.digital.analyse.TruthTableTableModel)1 ExpressionException (de.neemann.digital.analyse.expression.ExpressionException)1 Signal (de.neemann.digital.core.Signal)1 ArrayList (java.util.ArrayList)1