Search in sources :

Example 1 with FlipflopJK

use of de.neemann.digital.core.flipflops.FlipflopJK 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 2 with FlipflopJK

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

the class ModelAnalyser method replaceTFF.

private void replaceTFF() throws NodeException, AnalyseException {
    List<FlipflopT> tList = model.findNode(FlipflopT.class);
    for (FlipflopT tff : tList) {
        checkClock(tff);
        tff.getClockVal().removeObserver(tff);
        ObservableValue q = tff.getOutputs().get(0);
        ObservableValue qn = tff.getOutputs().get(1);
        ObservableValue enable = tff.getEnableVal();
        if (enable == null) {
            // create d ff
            FlipflopD d = new FlipflopD(tff.getLabel(), q, qn);
            d.setInputs(new ObservableValues(qn, getClock()));
            model.replace(tff, d);
        } else {
            // create jk ff
            enable.removeObserver(tff);
            FlipflopJK jk = new FlipflopJK(tff.getLabel(), q, qn);
            jk.setInputs(new ObservableValues(enable, getClock(), enable));
            model.replace(tff, jk);
        }
    }
}
Also used : FlipflopT(de.neemann.digital.core.flipflops.FlipflopT) FlipflopD(de.neemann.digital.core.flipflops.FlipflopD) FlipflopJK(de.neemann.digital.core.flipflops.FlipflopJK)

Aggregations

FlipflopD (de.neemann.digital.core.flipflops.FlipflopD)2 FlipflopJK (de.neemann.digital.core.flipflops.FlipflopJK)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 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)1 FlipflopT (de.neemann.digital.core.flipflops.FlipflopT)1