Search in sources :

Example 76 with TestExecuter

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

the class FlipflopDAsyncTest method testFlipFlop.

public void testFlipFlop() throws Exception {
    ObservableValue set = new ObservableValue("set", 1);
    ObservableValue d = new ObservableValue("d", 8);
    ObservableValue c = new ObservableValue("c", 1);
    ObservableValue clr = new ObservableValue("clr", 1);
    Model model = new Model();
    FlipflopDAsync out = model.add(new FlipflopDAsync(new ElementAttributes().setBits(8)));
    out.setInputs(ovs(set, d, c, clr));
    TestExecuter sc = new TestExecuter(model).setInputs(set, d, c, clr).setOutputs(out.getOutputs());
    // set D  C  clr Q  ~Q
    sc.check(0, 0, 0, 0, 0, 255);
    // set
    sc.check(1, 0, 0, 0, 255, 0);
    sc.check(0, 0, 0, 0, 255, 0);
    // clr
    sc.check(0, 0, 0, 1, 0, 255);
    sc.check(0, 0, 0, 0, 0, 255);
    sc.check(0, 1, 0, 0, 0, 255);
    sc.check(0, 1, 1, 0, 1, 254);
    sc.check(0, 0, 0, 0, 1, 254);
}
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 77 with TestExecuter

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

the class RAMDualPortTest method testRAM.

public void testRAM() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue d = new ObservableValue("d", 4);
    ObservableValue str = new ObservableValue("str", 1);
    ObservableValue clk = new ObservableValue("clk", 1);
    ObservableValue ld = new ObservableValue("ld", 1);
    Model model = new Model();
    RAMDualPort out = model.add(new RAMDualPort(new ElementAttributes().set(Keys.ADDR_BITS, 4).setBits(4)));
    out.setInputs(ovs(a, d, str, clk, ld));
    TestExecuter sc = new TestExecuter(model).setInputs(a, d, str, clk, ld).setOutputs(out.getOutputs());
    // A  D  ST C  LD
    // def
    sc.checkZ(0, 0, 0, 0, 0, HIGHZ);
    // st  0->5
    sc.checkZ(0, 5, 1, 1, 0, HIGHZ);
    // def
    sc.checkZ(0, 0, 0, 0, 0, HIGHZ);
    // st  1->9
    sc.checkZ(1, 9, 1, 1, 0, HIGHZ);
    // rd  5
    sc.check(0, 0, 0, 0, 1, 5);
    // rd  5
    sc.check(1, 0, 0, 0, 1, 9);
}
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 78 with TestExecuter

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

the class RAMSinglePortTest method testRAM.

public void testRAM() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue d = new ObservableValue("d", 4);
    ObservableValue str = new ObservableValue("str", 1);
    ObservableValue clk = new ObservableValue("clk", 1);
    ObservableValue ld = new ObservableValue("ld", 1);
    Model model = new Model();
    RAMSinglePort out = model.add(new RAMSinglePort(new ElementAttributes().set(Keys.ADDR_BITS, 4).setBits(4)));
    out.setInputs(ovs(a, str, clk, ld, d));
    TestExecuter sc = new TestExecuter(model).setInputs(a, d, str, clk, ld).setOutputs(out.getOutputs());
    // A  D  ST C  LD
    // def
    sc.checkZ(0, 0, 0, 0, 0, HIGHZ);
    // st  0->5
    sc.checkZ(0, 5, 1, 1, 0, HIGHZ);
    // def
    sc.checkZ(0, 0, 0, 0, 0, HIGHZ);
    // st  1->9
    sc.checkZ(1, 9, 1, 1, 0, HIGHZ);
    // rd  5
    sc.check(0, 0, 0, 0, 1, 5);
    // rd  5
    sc.check(1, 0, 0, 0, 1, 9);
}
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 79 with TestExecuter

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

the class RegisterTest method testRegister.

public void testRegister() throws Exception {
    ObservableValue d = new ObservableValue("s", 8);
    ObservableValue c = new ObservableValue("c", 1);
    ObservableValue en = new ObservableValue("en", 1);
    Model model = new Model();
    Register out = model.add(new Register(new ElementAttributes().setBits(8)));
    out.setInputs(ovs(d, c, en));
    TestExecuter sc = new TestExecuter(model).setInputs(d, c, en).setOutputs(out.getOutputs());
    // D  C  en  Q
    sc.check(0, 0, 0, 0);
    sc.check(7, 1, 1, 7);
    sc.check(9, 1, 1, 7);
    sc.check(9, 1, 0, 7);
    sc.check(9, 0, 0, 7);
    sc.check(9, 0, 1, 7);
    sc.check(9, 1, 1, 9);
    sc.check(0, 0, 0, 9);
    sc.check(0, 1, 0, 9);
    sc.check(0, 1, 1, 9);
    sc.check(0, 0, 0, 9);
    sc.check(0, 1, 0, 9);
    sc.check(0, 0, 1, 9);
}
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 80 with TestExecuter

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

the class BusSplitterTest method testBusSplitter.

public void testBusSplitter() throws Exception {
    Model model = new Model();
    ObservableValue oe = new ObservableValue("oe", 1);
    ObservableValue d = new ObservableValue("d", 4);
    ObservableValue d0 = new ObservableValue("d0", 1);
    ObservableValue d1 = new ObservableValue("d1", 1);
    ObservableValue d2 = new ObservableValue("d2", 1);
    ObservableValue d3 = new ObservableValue("d3", 1);
    BusSplitter out = model.add(new BusSplitter(new ElementAttributes().setBits(4)));
    out.setInputs(ovs(oe, d, d0, d1, d2, d3));
    TestExecuter te = new TestExecuter(model).setInputs(oe, d, d0, d1, d2, d3).setOutputs(out.getOutputs());
    te.check(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    te.check(1, 5, 0, 0, 0, 0, 0, 1, 0, 1, 0);
    te.check(1, 15, 0, 0, 0, 0, 0, 1, 1, 1, 1);
    te.check(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    te.check(0, 0, 1, 0, 1, 0, 5, 0, 0, 0, 0);
    te.check(0, 0, 1, 1, 1, 1, 15, 0, 0, 0, 0);
}
Also used : Model(de.neemann.digital.core.Model) ObservableValue(de.neemann.digital.core.ObservableValue) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) 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