use of de.neemann.digital.TestExecuter in project Digital by hneemann.
the class BitSelectorTest method testBitSel.
public void testBitSel() throws Exception {
Model model = new Model();
ObservableValue d = new ObservableValue("d", 4);
ObservableValue sel = new ObservableValue("sel", 2);
BitSelector out = model.add(new BitSelector(new ElementAttributes().set(Keys.SELECTOR_BITS, 2)));
out.setInputs(ovs(d, sel));
TestExecuter te = new TestExecuter(model).setInputs(d, sel).setOutputs(out.getOutputs());
te.check(5, 0, 1);
te.check(5, 1, 0);
te.check(5, 2, 1);
te.check(5, 3, 0);
te.check(10, 0, 0);
te.check(10, 1, 1);
te.check(10, 2, 0);
te.check(10, 3, 1);
}
use of de.neemann.digital.TestExecuter in project Digital by hneemann.
the class CircuitBuilderTest method testBuilderCombinatorial.
public void testBuilderCombinatorial() throws Exception {
Variable a = new Variable("a");
Variable b = new Variable("b");
// xor
Expression y = and(or(a, b), not(and(a, b)));
ElementLibrary library = new ElementLibrary();
Circuit circuit = new CircuitBuilder(new ShapeFactory(library)).addCombinatorial("y", y).createCircuit();
ModelCreator m = new ModelCreator(circuit, library);
TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
te.check(0, 0, 0);
te.check(0, 1, 1);
te.check(1, 0, 1);
te.check(1, 1, 0);
}
use of de.neemann.digital.TestExecuter in project Digital by hneemann.
the class CircuitBuilderTest method testBuilderSequential.
public void testBuilderSequential() throws Exception {
Variable y0 = new Variable("Y_0");
Variable y1 = new Variable("Y_1");
// counter
Expression y0s = not(y0);
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
ElementLibrary library = new ElementLibrary();
Circuit circuit = new CircuitBuilder(new ShapeFactory(library)).addSequential("Y_0", y0s).addSequential("Y_1", y1s).createCircuit();
ModelCreator m = new ModelCreator(circuit, library);
TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
te.check(0, 0);
te.checkC(1, 0);
te.checkC(0, 1);
te.checkC(1, 1);
te.checkC(0, 0);
}
use of de.neemann.digital.TestExecuter in project Digital by hneemann.
the class AddTest method testAdd32.
public void testAdd32() throws Exception {
ObservableValue a = new ObservableValue("a", 32);
ObservableValue b = new ObservableValue("b", 32);
ObservableValue c = new ObservableValue("c", 1);
Model model = new Model();
Add node = new Add(new ElementAttributes().setBits(32));
node.setInputs(ovs(a, b, c));
model.add(node);
TestExecuter sc = new TestExecuter(model).setInputs(a, b, c).setOutputs(node.getOutputs());
sc.check(-1, 0, 1, 0, 1);
sc.check(-1, 1, 0, 0, 1);
}
use of de.neemann.digital.TestExecuter in project Digital by hneemann.
the class AddTest method testAdd64.
public void testAdd64() throws Exception {
ObservableValue a = new ObservableValue("a", 64);
ObservableValue b = new ObservableValue("b", 64);
ObservableValue c = new ObservableValue("c", 1);
Model model = new Model();
Add node = new Add(new ElementAttributes().setBits(64));
node.setInputs(ovs(a, b, c));
model.add(node);
TestExecuter sc = new TestExecuter(model).setInputs(a, b, c).setOutputs(node.getOutputs());
sc.check(-1, 0, 1, 0, 1);
sc.check(-1, 1, 0, 0, 1);
}
Aggregations