Search in sources :

Example 11 with ObservableValues

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

the class BarrelShifterTest method getTestExecuter.

private TestExecuter getTestExecuter(BarrelShifterMode mode, boolean signed, LeftRightFormat direction, int valueWidth, int shiftWidth) throws Exception {
    ObservableValue value = new ObservableValue("value", valueWidth);
    ObservableValue shift = new ObservableValue("shift", shiftWidth);
    ElementAttributes attributes = new ElementAttributes().set(Keys.BARREL_SHIFTER_MODE, mode).set(Keys.BARREL_SIGNED, signed).set(Keys.DIRECTION, direction).set(Keys.BITS, valueWidth);
    Model model = new Model();
    BarrelShifter bs = new BarrelShifter(attributes);
    bs.setInputs(ovs(value, shift));
    model.add(bs);
    ObservableValues outputs = bs.getOutputs();
    assertEquals(1, outputs.size());
    assertEquals(value.getBits(), outputs.get(0).getBits());
    return new TestExecuter(model).setInputs(value, shift).setOutputs(outputs);
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues) 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 12 with ObservableValues

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

the class BitCountTest method testBitCount.

public void testBitCount() throws Exception {
    ObservableValue a = new ObservableValue("a", 6);
    Model model = new Model();
    BitCount node = new BitCount(new ElementAttributes().setBits(6));
    node.setInputs(a.asList());
    model.add(node);
    ObservableValues outputs = node.getOutputs();
    assertEquals(1, outputs.size());
    assertEquals(3, outputs.get(0).getBits());
    TestExecuter sc = new TestExecuter(model).setInputs(a).setOutputs(outputs);
    sc.check(0, 0);
    sc.check(1, 1);
    sc.check(2, 1);
    sc.check(4, 1);
    sc.check(8, 1);
    sc.check(16, 1);
    sc.check(32, 1);
    sc.check(3, 2);
    sc.check(6, 2);
    sc.check(12, 2);
    sc.check(24, 2);
    sc.check(48, 2);
    sc.check(63, 6);
    sc.check(255, 6);
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues) 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 13 with ObservableValues

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

the class PortsTest method testPortsMult.

public void testPortsMult() throws Exception {
    Splitter.Ports p = new Splitter.Ports("1*4,4*2");
    ObservableValues outs = p.getOutputs();
    assertEquals(6, outs.size());
    assertEquals(1, outs.get(0).getBits());
    assertEquals(1, outs.get(1).getBits());
    assertEquals(1, outs.get(2).getBits());
    assertEquals(1, outs.get(3).getBits());
    assertEquals(4, outs.get(4).getBits());
    assertEquals(4, outs.get(5).getBits());
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues)

Example 14 with ObservableValues

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

the class PortsTest method testPortsRange.

public void testPortsRange() throws Exception {
    Splitter.Ports p = new Splitter.Ports("4-6,0-3");
    ObservableValues outs = p.getOutputs();
    assertEquals(2, outs.size());
    assertEquals(3, outs.get(0).getBits());
    assertEquals(4, outs.get(1).getBits());
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues)

Example 15 with ObservableValues

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

the class PortsTest method testPortsRangeOneBit.

public void testPortsRangeOneBit() throws Exception {
    Splitter.Ports p = new Splitter.Ports("4-4,3-3,2-2,1-1");
    ObservableValues outs = p.getOutputs();
    assertEquals(4, outs.size());
    assertEquals(1, outs.get(0).getBits());
    assertEquals(1, outs.get(1).getBits());
    assertEquals(1, outs.get(2).getBits());
    assertEquals(1, outs.get(3).getBits());
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues)

Aggregations

ObservableValues (de.neemann.digital.core.ObservableValues)22 ObservableValue (de.neemann.digital.core.ObservableValue)17 TestExecuter (de.neemann.digital.TestExecuter)16 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)16 Model (de.neemann.digital.core.Model)3 BitsException (de.neemann.digital.core.BitsException)1 NodeException (de.neemann.digital.core.NodeException)1 PinDescription (de.neemann.digital.core.element.PinDescription)1 ArrayList (java.util.ArrayList)1