Search in sources :

Example 21 with ElementAttributes

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

the class RegisterFileTest method testRegisterFile.

public void testRegisterFile() throws Exception {
    ObservableValue ra = new ObservableValue("ra", 2);
    ObservableValue rb = new ObservableValue("rb", 2);
    ObservableValue rw = new ObservableValue("rw", 2);
    ObservableValue in = new ObservableValue("in", 4);
    ObservableValue we = new ObservableValue("we", 1);
    ObservableValue clk = new ObservableValue("clk", 1);
    Model model = new Model();
    RegisterFile out = model.add(new RegisterFile(new ElementAttributes().set(Keys.ADDR_BITS, 2).setBits(4)));
    out.setInputs(ovs(in, we, rw, clk, ra, rb));
    TestExecuter sc = new TestExecuter(model).setInputs(clk, in, we, rw, ra, rb).setOutputs(out.getOutputs());
    // c  in we rw ra rb da db
    sc.check(0, 0, 0, 0, 0, 0, 0, 0);
    sc.check(1, 7, 1, 1, 0, 0, 0, 0);
    sc.check(0, 0, 0, 0, 1, 1, 7, 7);
    sc.check(1, 5, 1, 2, 1, 1, 7, 7);
    sc.check(0, 0, 0, 0, 1, 2, 7, 5);
}
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 22 with ElementAttributes

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

the class BitSelectorTest method testBitSel.

public void testBitSel() throws Exception {
    Model model = new Model();
    ObservableValue d = new ObservableValue("d", 4);
    ObservableValue sel = new ObservableValue("sel", 2);
    BitSelector out = model.add(new BitSelector(new ElementAttributes().set(Keys.SELECTOR_BITS, 2)));
    out.setInputs(ovs(d, sel));
    TestExecuter te = new TestExecuter(model).setInputs(d, sel).setOutputs(out.getOutputs());
    te.check(5, 0, 1);
    te.check(5, 1, 0);
    te.check(5, 2, 1);
    te.check(5, 3, 0);
    te.check(10, 0, 0);
    te.check(10, 1, 1);
    te.check(10, 2, 0);
    te.check(10, 3, 1);
}
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)

Example 23 with ElementAttributes

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

the class EditorFactoryTest method testKeyConstrains.

public void testKeyConstrains() {
    ElementAttributes attr = new ElementAttributes();
    assertEquals(attr.get(Keys.INPUT_COUNT), attr.get(Keys.ADDR_BITS));
// see comments in EditorFactory$DataFieldEditor
}
Also used : ElementAttributes(de.neemann.digital.core.element.ElementAttributes)

Example 24 with ElementAttributes

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

the class ModelAnalyser method replaceJKFF.

private void replaceJKFF() throws NodeException, AnalyseException {
    List<FlipflopJK> jkList = model.findNode(FlipflopJK.class);
    for (FlipflopJK jk : jkList) {
        checkClock(jk);
        jk.getClockVal().removeObserver(jk);
        jk.getjVal().removeObserver(jk);
        jk.getkVal().removeObserver(jk);
        // create d ff
        ObservableValue q = jk.getOutputs().get(0);
        ObservableValue qn = jk.getOutputs().get(1);
        FlipflopD d = new FlipflopD(jk.getLabel(), q, qn);
        And a1 = new And(new ElementAttributes());
        a1.setInputs(new ObservableValues(jk.getjVal(), qn));
        And a2 = new And(new ElementAttributes());
        Not nk = new Not(new ElementAttributes());
        nk.setInputs(jk.getkVal().asList());
        a2.setInputs(new ObservableValues(nk.getOutput(), q));
        Or or = new Or(new ElementAttributes());
        or.setInputs(new ObservableValues(a1.getOutput(), a2.getOutput()));
        d.setInputs(new ObservableValues(or.getOutputs().get(0), jk.getClockVal()));
        model.add(a1);
        model.add(a2);
        model.add(nk);
        model.add(or);
        model.replace(jk, d);
    }
}
Also used : FlipflopD(de.neemann.digital.core.flipflops.FlipflopD) Not(de.neemann.digital.core.basic.Not) Or(de.neemann.digital.core.basic.Or) And(de.neemann.digital.core.basic.And) FlipflopJK(de.neemann.digital.core.flipflops.FlipflopJK) ElementAttributes(de.neemann.digital.core.element.ElementAttributes)

Example 25 with ElementAttributes

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

the class LibraryNode method getToolTipText.

/**
 * @return the tool tip text
 */
public String getToolTipText() {
    if (isCustom()) {
        if (isUnique()) {
            if (description == null) {
                if (toolTipText == null) {
                    try {
                        LOGGER.debug("load tooltip from " + file);
                        Circuit c = Circuit.loadCircuit(file, null);
                        toolTipText = new LineBreaker().toHTML().breakLines(c.getAttributes().get(Keys.DESCRIPTION));
                    } catch (Exception e) {
                        toolTipText = Lang.get("msg_fileNotImportedYet");
                    }
                }
                return toolTipText;
            } else
                return new LineBreaker().toHTML().breakLines(description.getDescription(new ElementAttributes()));
        } else
            return Lang.get("msg_fileIsNotUnique");
    } else
        return new LineBreaker().toHTML().breakLines(Lang.getNull("elem_" + getName() + "_tt"));
}
Also used : Circuit(de.neemann.digital.draw.elements.Circuit) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) LineBreaker(de.neemann.gui.LineBreaker) IOException(java.io.IOException)

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