use of de.neemann.digital.analyse.expression.BitSetter in project Digital by hneemann.
the class ModelAnalyser method simpleFiller.
private void simpleFiller(TruthTable tt) throws NodeException, AnalyseException {
if (inputs.size() > MAX_INPUTS_ALLOWED)
throw new AnalyseException(Lang.get("err_toManyInputs_max_N0_is_N1", MAX_INPUTS_ALLOWED, inputs.size()));
BitSetter bitsetter = new BitSetter(inputs.size()) {
@Override
public void setBit(int row, int bit, boolean value) {
inputs.get(bit).getValue().setBool(value);
}
};
int rows = 1 << inputs.size();
ArrayList<BoolTableByteArray> data = new ArrayList<>();
for (Signal s : outputs) {
BoolTableByteArray e = new BoolTableByteArray(rows);
data.add(e);
tt.addResult(s.getName(), e);
}
model.init();
for (int row = 0; row < rows; row++) {
bitsetter.fill(row);
model.doStep();
for (int i = 0; i < outputs.size(); i++) {
data.get(i).set(row, outputs.get(i).getValue().getBool());
}
}
}
use of de.neemann.digital.analyse.expression.BitSetter 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