Search in sources :

Example 1 with Or

use of de.neemann.digital.core.basic.Or 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)

Aggregations

And (de.neemann.digital.core.basic.And)1 Not (de.neemann.digital.core.basic.Not)1 Or (de.neemann.digital.core.basic.Or)1 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)1 FlipflopD (de.neemann.digital.core.flipflops.FlipflopD)1 FlipflopJK (de.neemann.digital.core.flipflops.FlipflopJK)1