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));
}
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));
}
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());
}
}
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());
}
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));
}
Aggregations