use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class NotTest method testNot.
public void testNot() throws Exception {
ObservableValue a = new ObservableValue("a", 2);
Model model = new Model();
Not out = model.add(new Not(new ElementAttributes().setBits(2)));
out.setInputs(a.asList());
TestExecuter sc = new TestExecuter(model).setInputs(a).setOutputs(out.getOutputs());
sc.check(0, 3);
sc.check(1, 2);
sc.check(2, 1);
sc.check(3, 0);
}
use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class OrTest method testOr.
public void testOr() throws Exception {
ObservableValue a = new ObservableValue("a", 1);
ObservableValue b = new ObservableValue("b", 1);
Model model = new Model();
FanIn and = model.add(new Or(new ElementAttributes().setBits(1)));
and.setInputs(ovs(a, b));
TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputs(and.getOutput());
sc.check(0, 0, 0);
sc.check(1, 0, 1);
sc.check(0, 1, 1);
sc.check(1, 1, 1);
sc.check(1, 0, 1);
sc.check(0, 1, 1);
sc.check(0, 0, 0);
}
use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class XNOrTest method testXor.
public void testXor() throws Exception {
ObservableValue a = new ObservableValue("a", 1);
ObservableValue b = new ObservableValue("b", 1);
Model model = new Model();
XNOr out = model.add(new XNOr(new ElementAttributes().setBits(1)));
out.setInputs(ovs(a, b));
TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputs(out.getOutputs());
sc.check(0, 0, 1);
sc.check(1, 0, 0);
sc.check(0, 1, 0);
sc.check(1, 1, 1);
}
use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class LUTTest method testLut.
public void testLut() throws Exception {
ObservableValue a = new ObservableValue("a", 1);
ObservableValue b = new ObservableValue("b", 1);
ObservableValue c = new ObservableValue("c", 1);
Model model = new Model();
DataField data = new DataField(8);
data.setData(3, 1);
data.setData(7, 1);
LookUpTable out = model.add(new LookUpTable(new ElementAttributes().setBits(1).set(Keys.DATA, data)));
out.setInputs(ovs(a, b));
TestExecuter sc = new TestExecuter(model).setInputs(a, b, c).setOutputs(out.getOutputs());
sc.check(0, 0, 0, 0);
sc.check(1, 0, 0, 0);
sc.check(0, 1, 0, 0);
sc.check(1, 1, 0, 1);
sc.check(0, 0, 1, 0);
sc.check(1, 0, 1, 0);
sc.check(0, 1, 1, 0);
sc.check(1, 1, 1, 1);
}
use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class ROMTest method testROM.
public void testROM() throws Exception {
ObservableValue addr = new ObservableValue("addr", 3);
ObservableValue sel = new ObservableValue("sel", 1);
Model model = new Model();
DataField data = new DataField(8);
data.setData(3, 17);
data.setData(7, 200);
ROM out = model.add(new ROM(new ElementAttributes().setBits(8).set(Keys.ADDR_BITS, 3).set(Keys.DATA, data)));
out.setInputs(ovs(addr, sel));
TestExecuter sc = new TestExecuter(model).setInputs(addr, sel).setOutputs(out.getOutputs());
sc.check(0, 1, 0);
sc.check(1, 1, 0);
sc.check(2, 1, 0);
sc.check(3, 1, 17);
sc.check(4, 1, 0);
sc.check(5, 1, 0);
sc.check(6, 1, 0);
// try { ToDo HighZ
// sc.check(6, 0, 0);
// assertTrue(false);
// } catch (HighZException e) {
// assertTrue(true);
// }
}
Aggregations