Search in sources :

Example 51 with ElementAttributes

use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.

the class ComparatorTest method testCompUnsigned64Bit.

public void testCompUnsigned64Bit() throws Exception {
    ObservableValue a = new ObservableValue("a", 64);
    ObservableValue b = new ObservableValue("b", 64);
    Model model = new Model();
    Comparator node = new Comparator(new ElementAttributes().setBits(64).set(Keys.SIGNED, false));
    node.setInputs(ovs(a, b));
    model.add(node);
    TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputs(node.getOutputs());
    // gr eq kl
    sc.check(0, 0, 0, 1, 0);
    sc.check(0, -2, 0, 0, 1);
    sc.check(-2, 0, 1, 0, 0);
    sc.check(-1, -2, 1, 0, 0);
    sc.check(-2, -1, 0, 0, 1);
    sc.check(2, 1, 1, 0, 0);
    sc.check(0xC000000000000000L, 0x8000000000000000L, 1, 0, 0);
    sc.check(0x8000000000000000L, 0, 1, 0, 0);
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Example 52 with ElementAttributes

use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.

the class MulTest method testMul.

public void testMul() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue b = new ObservableValue("b", 4);
    Model model = new Model();
    Mul node = model.add(new Mul(new ElementAttributes().setBits(4)));
    node.setInputs(ovs(a, b));
    TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputsOf(node);
    sc.check(0, 0, 0);
    sc.check(6, 6, 36);
    sc.check(15, 15, 225);
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Example 53 with ElementAttributes

use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.

the class NegTest method testNeg.

public void testNeg() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    Model model = new Model();
    Neg out = model.add(new Neg(new ElementAttributes().setBits(4)));
    out.setInputs(a.asList());
    TestExecuter sc = new TestExecuter(model).setInputs(a).setOutputs(out.getOutputs());
    sc.check(0, 0);
    sc.check(1, 15);
    sc.check(15, 1);
    sc.check(3, 13);
    sc.check(7, 9);
    sc.check(8, 8);
    sc.check(9, 7);
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Example 54 with ElementAttributes

use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.

the class NegTest method testNeg64.

public void testNeg64() throws Exception {
    ObservableValue a = new ObservableValue("a", 64);
    Model model = new Model();
    Neg out = model.add(new Neg(new ElementAttributes().setBits(64)));
    out.setInputs(a.asList());
    TestExecuter sc = new TestExecuter(model).setInputs(a).setOutputs(out.getOutputs());
    sc.check(0, 0);
    sc.check(-1, 1);
    sc.check(1, -1);
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Example 55 with ElementAttributes

use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.

the class SubTest method testSub64.

public void testSub64() throws Exception {
    ObservableValue a = new ObservableValue("a", 64);
    ObservableValue b = new ObservableValue("b", 64);
    ObservableValue c = new ObservableValue("c", 1);
    Model model = new Model();
    Sub node = new Sub(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(0, 0, 1, -1, 1);
    sc.check(0, 1, 0, -1, 1);
    sc.check(2, 2, 1, -1, 1);
    sc.check(2, 3, 0, -1, 1);
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Aggregations

ElementAttributes (de.neemann.digital.core.element.ElementAttributes)87 ObservableValue (de.neemann.digital.core.ObservableValue)73 TestExecuter (de.neemann.digital.TestExecuter)61 Model (de.neemann.digital.core.Model)52 ObservableValues (de.neemann.digital.core.ObservableValues)16 BitsException (de.neemann.digital.core.BitsException)3 FanIn (de.neemann.digital.core.basic.FanIn)3 NodeException (de.neemann.digital.core.NodeException)2 Delay (de.neemann.digital.core.wiring.Delay)2 Circuit (de.neemann.digital.draw.elements.Circuit)2 And (de.neemann.digital.core.basic.And)1 Not (de.neemann.digital.core.basic.Not)1 Or (de.neemann.digital.core.basic.Or)1 Element (de.neemann.digital.core.element.Element)1 Key (de.neemann.digital.core.element.Key)1 FlipflopD (de.neemann.digital.core.flipflops.FlipflopD)1 FlipflopJK (de.neemann.digital.core.flipflops.FlipflopJK)1 Clock (de.neemann.digital.core.wiring.Clock)1 VisualElement (de.neemann.digital.draw.elements.VisualElement)1 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)1