Search in sources :

Example 31 with TestExecuter

use of de.neemann.digital.TestExecuter in project Digital by hneemann.

the class ComparatorTest method testCompSigned64Bit.

public void testCompSigned64Bit() 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, true));
    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, 1, 0, 0);
    sc.check(-2, 0, 0, 0, 1);
    sc.check(-1, -2, 1, 0, 0);
    sc.check(-2, -1, 0, 0, 1);
    sc.check(0x8000000000000000L, 0, 0, 0, 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 32 with TestExecuter

use of de.neemann.digital.TestExecuter in project Digital by hneemann.

the class ComparatorTest method testCompUnsigned.

public void testCompUnsigned() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue b = new ObservableValue("b", 4);
    Model model = new Model();
    Comparator node = new Comparator(new ElementAttributes().setBits(4).set(Keys.SIGNED, false));
    node.setInputs(ovs(a, b));
    model.add(node);
    TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputs(node.getOutputs());
    sc.check(0, 0, 0, 1, 0);
    sc.check(1, 0, 1, 0, 0);
    sc.check(1, 2, 0, 0, 1);
    sc.check(14, 2, 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 33 with TestExecuter

use of de.neemann.digital.TestExecuter in project Digital by hneemann.

the class AndTest method testAnd.

public void testAnd() throws Exception {
    ObservableValue a = new ObservableValue("a", 1);
    ObservableValue b = new ObservableValue("b", 1);
    Model model = new Model();
    FanIn out = model.add(new And(new ElementAttributes().setBits(1)));
    out.setInputs(ovs(a, b));
    TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputs(out.getOutputs());
    sc.check(0, 0, 0);
    sc.check(1, 0, 0);
    sc.check(0, 1, 0);
    sc.check(1, 1, 1);
    sc.check(1, 0, 0);
    sc.check(0, 1, 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 34 with TestExecuter

use of de.neemann.digital.TestExecuter in project Digital by hneemann.

the class CircuitBuilderTest method testBuilderSequentialJK_JequalsK.

public void testBuilderSequentialJK_JequalsK() 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), true).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);
}
Also used : ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Circuit(de.neemann.digital.draw.elements.Circuit) TestExecuter(de.neemann.digital.TestExecuter) ModelCreator(de.neemann.digital.draw.model.ModelCreator)

Example 35 with TestExecuter

use of de.neemann.digital.TestExecuter in project Digital by hneemann.

the class TestNesting method testMultipleNesting.

/**
 * Imports the same model two times.
 * A simple traffic light build with two nested MS-JK flip flops.
 */
public void testMultipleNesting() throws NodeException, PinException, IOException, ElementNotFoundException {
    TestExecuter te = createTestExecuterForNesting("dig/trafficLight.dig");
    // runs the sequential logic up to the given state, its necessary because initial state is undefined
    te.clockUntil(1, 0, 0);
    // C  R  Y  G
    // Red
    te.check(0, 1, 0, 0);
    te.check(1, 1, 0, 0);
    // Red / Yellow
    te.check(0, 1, 1, 0);
    te.check(1, 1, 1, 0);
    // Green
    te.check(0, 0, 0, 1);
    te.check(1, 0, 0, 1);
    // Yellow
    te.check(0, 0, 1, 0);
    te.check(1, 0, 1, 0);
    // Red
    te.check(0, 1, 0, 0);
    te.check(1, 1, 0, 0);
    // Red / Yellow
    te.check(0, 1, 1, 0);
    te.check(1, 1, 1, 0);
    // Green
    te.check(0, 0, 0, 1);
    te.check(1, 0, 0, 1);
    // Yellow
    te.check(0, 0, 1, 0);
    te.check(1, 0, 1, 0);
    // Red
    te.check(0, 1, 0, 0);
    te.check(1, 1, 0, 0);
}
Also used : TestExecuter(de.neemann.digital.TestExecuter)

Aggregations

TestExecuter (de.neemann.digital.TestExecuter)80 ObservableValue (de.neemann.digital.core.ObservableValue)61 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)61 Model (de.neemann.digital.core.Model)49 ObservableValues (de.neemann.digital.core.ObservableValues)16 Circuit (de.neemann.digital.draw.elements.Circuit)5 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)5 ModelCreator (de.neemann.digital.draw.model.ModelCreator)5 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)5 Expression (de.neemann.digital.analyse.expression.Expression)4 Variable (de.neemann.digital.analyse.expression.Variable)4 Node (de.neemann.digital.core.Node)1 FanIn (de.neemann.digital.core.basic.FanIn)1 Delay (de.neemann.digital.core.wiring.Delay)1 ModelEntry (de.neemann.digital.draw.model.ModelEntry)1 File (java.io.File)1