Search in sources :

Example 1 with Signal

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

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

the class BoolTableExpandedTest method checkTable.

private void checkTable(ArrayList<Signal> in1) {
    ArrayList<Signal> in2 = new Signals("a", "b", "c", "d").list();
    List<Variable> vars = new Vars("a", "b", "c", "d").list();
    check(new BoolTableByteArray(new byte[] { 1, 1, 0, 1 }), in1, in2, vars);
    check(new BoolTableByteArray(new byte[] { 0, 1, 1, 0 }), in1, in2, vars);
    check(new BoolTableByteArray(new byte[] { 1, 0, 0, 1 }), in1, in2, vars);
    check(new BoolTableByteArray(new byte[] { 0, 0, 0, 1 }), in1, in2, vars);
    check(new BoolTableByteArray(new byte[] { 0, 1, 1, 1 }), in1, in2, vars);
}
Also used : Signal(de.neemann.digital.core.Signal) Variable(de.neemann.digital.analyse.expression.Variable) BoolTableByteArray(de.neemann.digital.analyse.quinemc.BoolTableByteArray)

Example 3 with Signal

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

the class TestTrans method testTrans.

public void testTrans() throws Exception {
    Model model = new ToBreakRunner("dig/test/transp/transtest3.dig").getModel();
    assertEquals(2, model.getInputs().size());
    assertEquals(1, model.getOutputs().size());
    assertEquals(1, model.getNodes().size());
    Node node = model.getNodes().get(0);
    assertTrue(node instanceof XOr);
    XOr xor = (XOr) node;
    // The models inputs are the xor input values!
    // All the intermediate transparent stuff is removed!
    ArrayList<ObservableValue> ins = new ArrayList<>();
    for (Signal s : model.getInputs()) ins.add(s.getValue());
    assertTrue(ins.contains(xor.getInputs().get(0)));
    assertTrue(ins.contains(xor.getInputs().get(1)));
}
Also used : Signal(de.neemann.digital.core.Signal) Node(de.neemann.digital.core.Node) Model(de.neemann.digital.core.Model) ObservableValue(de.neemann.digital.core.ObservableValue) ArrayList(java.util.ArrayList) XOr(de.neemann.digital.core.basic.XOr)

Example 4 with Signal

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

the class SplitPinStringTest method testEmpty.

public void testEmpty() {
    SplitPinString p = SplitPinString.create(new Signal("a", null));
    assertEquals(null, p.getPin(0));
    assertEquals(null, p.getPin(1));
    assertEquals(null, p.getPin(2));
}
Also used : Signal(de.neemann.digital.core.Signal)

Example 5 with Signal

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

the class TestExecutor method create.

/**
 * Creates the result by comparing the testing vector with the given model-
 *
 * @param model the model to check
 * @return this for chained calls
 * @throws TestingDataException DataException
 * @throws NodeException        NodeException
 */
public TestExecutor create(Model model) throws TestingDataException, NodeException {
    allPassed = true;
    HashSet<String> usedSignals = new HashSet<>();
    inputs = new ArrayList<>();
    outputs = new ArrayList<>();
    for (Signal s : model.getInputs()) {
        final int index = getIndexOf(s.getName());
        if (index >= 0) {
            inputs.add(new TestSignal(index, s.getValue()));
            addTo(usedSignals, s.getName());
        }
        ObservableValue outValue = s.getBidirectionalReader();
        if (outValue != null) {
            final String outName = s.getName() + "_out";
            final int inIndex = getIndexOf(outName);
            if (inIndex >= 0) {
                outputs.add(new TestSignal(inIndex, outValue));
                addTo(usedSignals, outName);
            }
        }
    }
    for (Clock c : model.getClocks()) {
        final int index = getIndexOf(c.getLabel());
        if (index >= 0) {
            inputs.add(new TestSignal(index, c.getClockOutput()));
            addTo(usedSignals, c.getLabel());
        }
    }
    for (Signal s : model.getOutputs()) {
        final int index = getIndexOf(s.getName());
        if (index >= 0) {
            outputs.add(new TestSignal(index, s.getValue()));
            addTo(usedSignals, s.getName());
        }
    }
    for (String name : names) if (!usedSignals.contains(name))
        throw new TestingDataException(Lang.get("err_testSignal_N_notFound", name));
    if (inputs.size() == 0)
        throw new TestingDataException(Lang.get("err_noTestInputSignalsDefined"));
    if (outputs.size() == 0)
        throw new TestingDataException(Lang.get("err_noTestOutputSignalsDefined"));
    model.init();
    try {
        lines.emitLines(new LineListenerResolveDontCare(values -> checkRow(model, values), inputs), new Context());
    } catch (ParserException e) {
        throw new TestingDataException(Lang.get("err_errorParsingTestdata"), e);
    } catch (RuntimeException e) {
        if (allPassed) {
            allPassed = false;
            exception = e;
        }
    }
    return this;
}
Also used : Clock(de.neemann.digital.core.wiring.Clock) LineEmitter(de.neemann.digital.testing.parser.LineEmitter) Signal(de.neemann.digital.core.Signal) ParserException(de.neemann.digital.testing.parser.ParserException) ObservableValue(de.neemann.digital.core.ObservableValue) Lang(de.neemann.digital.lang.Lang) ValueTable(de.neemann.digital.data.ValueTable) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Model(de.neemann.digital.core.Model) Value(de.neemann.digital.data.Value) Context(de.neemann.digital.testing.parser.Context) NodeException(de.neemann.digital.core.NodeException) Context(de.neemann.digital.testing.parser.Context) ParserException(de.neemann.digital.testing.parser.ParserException) ObservableValue(de.neemann.digital.core.ObservableValue) Clock(de.neemann.digital.core.wiring.Clock) Signal(de.neemann.digital.core.Signal) HashSet(java.util.HashSet)

Aggregations

Signal (de.neemann.digital.core.Signal)8 Model (de.neemann.digital.core.Model)4 Variable (de.neemann.digital.analyse.expression.Variable)2 BoolTableByteArray (de.neemann.digital.analyse.quinemc.BoolTableByteArray)2 ObservableValue (de.neemann.digital.core.ObservableValue)2 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)2 ArrayList (java.util.ArrayList)2 BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)1 TableReducer (de.neemann.digital.analyse.quinemc.TableReducer)1 Node (de.neemann.digital.core.Node)1 NodeException (de.neemann.digital.core.NodeException)1 XOr (de.neemann.digital.core.basic.XOr)1 Clock (de.neemann.digital.core.wiring.Clock)1 Value (de.neemann.digital.data.Value)1 ValueTable (de.neemann.digital.data.ValueTable)1 ValueTableObserver (de.neemann.digital.gui.components.data.ValueTableObserver)1 Lang (de.neemann.digital.lang.Lang)1 Context (de.neemann.digital.testing.parser.Context)1 LineEmitter (de.neemann.digital.testing.parser.LineEmitter)1 ParserException (de.neemann.digital.testing.parser.ParserException)1