Search in sources :

Example 1 with TableReducer

use of de.neemann.digital.analyse.quinemc.TableReducer in project Digital by hneemann.

the class ExpressionCreator method simplify.

private void simplify(ExpressionListener listener, List<Variable> vars, String resultName, BoolTable boolTable) throws AnalyseException, ExpressionException, FormatterException {
    List<Variable> localVars = vars;
    if (vars.size() > 4) {
        TableReducer tr = new TableReducer(vars, boolTable);
        if (tr.canReduce()) {
            LOGGER.debug(resultName + " reduced from " + vars.size() + " to " + tr.getVars().size() + " variables (" + tr.getVars() + ")");
            boolTable = tr.getTable();
            localVars = tr.getVars();
        }
    }
    if (!Main.isExperimentalMode() && localVars.size() > MAX_INPUTS_ALLOWED)
        throw new AnalyseException(Lang.get("err_toManyInputsIn_N0_max_N1_is_N2", resultName, MAX_INPUTS_ALLOWED, localVars.size()));
    listener = new CheckResultListener(listener, localVars, boolTable);
    getMinimizer(localVars.size()).minimize(localVars, boolTable, resultName, listener);
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) TableReducer(de.neemann.digital.analyse.quinemc.TableReducer)

Example 2 with TableReducer

use of de.neemann.digital.analyse.quinemc.TableReducer in project Digital by hneemann.

the class BoolTableExpandedTest method testCombined.

public void testCombined() {
    ArrayList<Signal> in1 = new Signals("b", "c").list();
    ArrayList<Signal> in2 = new Signals("a", "b", "c", "d").list();
    List<Variable> vars = new Vars("a", "b", "c", "d").list();
    BoolTableExpanded bt = new BoolTableExpanded(new BoolTableByteArray(new byte[] { 1, 1, 0, 0 }), in1, in2);
    TableReducer tr = new TableReducer(vars, bt);
    assertTrue(tr.canReduce());
    List<Variable> v = tr.getVars();
    assertEquals(1, v.size());
    assertEquals("b", v.get(0).getIdentifier());
    BoolTable t1 = tr.getTable();
    assertEquals(ThreeStateValue.one, t1.get(0));
    assertEquals(ThreeStateValue.zero, t1.get(1));
}
Also used : Signal(de.neemann.digital.core.Signal) Variable(de.neemann.digital.analyse.expression.Variable) BoolTableByteArray(de.neemann.digital.analyse.quinemc.BoolTableByteArray) BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) TableReducer(de.neemann.digital.analyse.quinemc.TableReducer)

Example 3 with TableReducer

use of de.neemann.digital.analyse.quinemc.TableReducer in project Digital by hneemann.

the class BoolTableExpandedTest method check.

private void check(BoolTableByteArray e, ArrayList<Signal> in1, ArrayList<Signal> in2, List<Variable> vars) {
    BoolTableExpanded bt = new BoolTableExpanded(e, in1, in2);
    TableReducer tr = new TableReducer(vars, bt);
    assertTrue(tr.canReduceOnlyCheckTable());
    List<Variable> v = tr.getVars();
    assertEquals(in1.size(), v.size());
    for (int i = 0; i < v.size(); i++) assertEquals(in1.get(i).getName(), v.get(i).getIdentifier());
    BoolTable t1 = tr.getTable();
    assertEquals(e.size(), t1.size());
    for (int r = 0; r < e.size(); r++) assertEquals(e.get(r), t1.get(r));
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) TableReducer(de.neemann.digital.analyse.quinemc.TableReducer)

Aggregations

Variable (de.neemann.digital.analyse.expression.Variable)3 TableReducer (de.neemann.digital.analyse.quinemc.TableReducer)3 BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)2 BoolTableByteArray (de.neemann.digital.analyse.quinemc.BoolTableByteArray)1 Signal (de.neemann.digital.core.Signal)1