use of de.neemann.digital.core.Signal 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.core.Signal 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);
}
use of de.neemann.digital.core.Signal in project Digital by hneemann.
the class TestTrans method testTrans.
public void testTrans() throws Exception {
Model model = new ToBreakRunner("dig/test/transp/transtest3.dig").getModel();
assertEquals(2, model.getInputs().size());
assertEquals(1, model.getOutputs().size());
assertEquals(1, model.getNodes().size());
Node node = model.getNodes().get(0);
assertTrue(node instanceof XOr);
XOr xor = (XOr) node;
// The models inputs are the xor input values!
// All the intermediate transparent stuff is removed!
ArrayList<ObservableValue> ins = new ArrayList<>();
for (Signal s : model.getInputs()) ins.add(s.getValue());
assertTrue(ins.contains(xor.getInputs().get(0)));
assertTrue(ins.contains(xor.getInputs().get(1)));
}
use of de.neemann.digital.core.Signal in project Digital by hneemann.
the class SplitPinStringTest method testEmpty.
public void testEmpty() {
SplitPinString p = SplitPinString.create(new Signal("a", null));
assertEquals(null, p.getPin(0));
assertEquals(null, p.getPin(1));
assertEquals(null, p.getPin(2));
}
use of de.neemann.digital.core.Signal in project Digital by hneemann.
the class TestExecutor method create.
/**
* Creates the result by comparing the testing vector with the given model-
*
* @param model the model to check
* @return this for chained calls
* @throws TestingDataException DataException
* @throws NodeException NodeException
*/
public TestExecutor create(Model model) throws TestingDataException, NodeException {
allPassed = true;
HashSet<String> usedSignals = new HashSet<>();
inputs = new ArrayList<>();
outputs = new ArrayList<>();
for (Signal s : model.getInputs()) {
final int index = getIndexOf(s.getName());
if (index >= 0) {
inputs.add(new TestSignal(index, s.getValue()));
addTo(usedSignals, s.getName());
}
ObservableValue outValue = s.getBidirectionalReader();
if (outValue != null) {
final String outName = s.getName() + "_out";
final int inIndex = getIndexOf(outName);
if (inIndex >= 0) {
outputs.add(new TestSignal(inIndex, outValue));
addTo(usedSignals, outName);
}
}
}
for (Clock c : model.getClocks()) {
final int index = getIndexOf(c.getLabel());
if (index >= 0) {
inputs.add(new TestSignal(index, c.getClockOutput()));
addTo(usedSignals, c.getLabel());
}
}
for (Signal s : model.getOutputs()) {
final int index = getIndexOf(s.getName());
if (index >= 0) {
outputs.add(new TestSignal(index, s.getValue()));
addTo(usedSignals, s.getName());
}
}
for (String name : names) if (!usedSignals.contains(name))
throw new TestingDataException(Lang.get("err_testSignal_N_notFound", name));
if (inputs.size() == 0)
throw new TestingDataException(Lang.get("err_noTestInputSignalsDefined"));
if (outputs.size() == 0)
throw new TestingDataException(Lang.get("err_noTestOutputSignalsDefined"));
model.init();
try {
lines.emitLines(new LineListenerResolveDontCare(values -> checkRow(model, values), inputs), new Context());
} catch (ParserException e) {
throw new TestingDataException(Lang.get("err_errorParsingTestdata"), e);
} catch (RuntimeException e) {
if (allPassed) {
allPassed = false;
exception = e;
}
}
return this;
}
Aggregations