use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.
the class BruteForceGetAllTest method performTestCalculation.
/*
public void testFull() throws ExpressionException, FormatterException {
new FullVariantDontCareCreator(4) {
@Override
public void handleTable(int n, int[] tab) throws ExpressionException {
performTestCalculation(n, tab);
}
}.create();
} /**/
private static void performTestCalculation(int n, byte[] tab) throws ExpressionException {
BruteForceGetAll ps = new BruteForceGetAll();
ArrayList<Variable> v = vars(n);
new QuineMcCluskey(v).fillTableWith(new BoolTableByteArray(tab)).simplify(ps);
ArrayList<ArrayList<TableRow>> solutions = ps.getAllSolutions();
if (solutions != null) {
for (ArrayList<TableRow> sol : solutions) {
Expression e = QuineMcCluskey.addAnd(null, sol, v);
ContextFiller context = new ContextFiller(v);
for (int i = 0; i < tab.length; i++) {
if (tab[i] <= 1) {
assertEquals(tab[i] == 1, e.calculate(context.setContextTo(i)));
}
}
}
}
}
use of de.neemann.digital.analyse.quinemc.BoolTableByteArray in project Digital by hneemann.
the class ModelAnalyser method dependantFiller.
private void dependantFiller(TruthTable tt, DependencyAnalyser da) throws NodeException, AnalyseException {
model.init();
for (Signal out : outputs) {
ArrayList<Signal> ins = reorder(da.getInputs(out), inputs);
if (ins.size() > MAX_INPUTS_ALLOWED)
throw new AnalyseException(Lang.get("err_toManyInputs_max_N0_is_N1", MAX_INPUTS_ALLOWED, ins.size()));
int rows = 1 << ins.size();
BoolTableByteArray e = new BoolTableByteArray(rows);
BitSetter bitsetter = new BitSetter(ins.size()) {
@Override
public void setBit(int row, int bit, boolean value) {
ins.get(bit).getValue().setBool(value);
}
};
for (int row = 0; row < rows; row++) {
bitsetter.fill(row);
model.doStep();
e.set(row, out.getValue().getBool());
}
tt.addResult(out.getName(), new BoolTableExpanded(e, ins, inputs));
}
}
Aggregations