Search in sources :

Example 1 with ElementAttributes

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

the class VHDLTestBenchCreator method write.

/**
 * Writes the test benches
 *
 * @param file the original vhdl file
 * @return this for chained calls
 * @throws IOException  IOException
 * @throws HDLException HDLException
 */
public VHDLTestBenchCreator write(File file) throws IOException, HDLException {
    String filename = file.getName();
    int p = filename.indexOf('.');
    if (p > 0)
        filename = filename.substring(0, p);
    for (ElementAttributes tc : testCases) {
        String testName = tc.getCleanLabel();
        if (testName.length() > 0)
            testName = filename + "_" + testName + "_tb";
        else
            testName = filename + "_tb";
        File f = new File(file.getParentFile(), testName + ".vhdl");
        testFileWritten.add(f);
        try (CodePrinter out = new CodePrinter(f)) {
            try {
                writeTestBench(out, testName, tc);
            } catch (TestingDataException | ParserException | RuntimeException e) {
                throw new HDLException(Lang.get("err_vhdlErrorWritingTestBench"), e);
            }
        }
    }
    return this;
}
Also used : ParserException(de.neemann.digital.testing.parser.ParserException) TestingDataException(de.neemann.digital.testing.TestingDataException) CodePrinter(de.neemann.digital.hdl.printer.CodePrinter) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) HDLException(de.neemann.digital.hdl.model2.HDLException) File(java.io.File)

Example 2 with ElementAttributes

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

the class ClockIntegratorARTIX7 method insertMMCMClock.

private void insertMMCMClock(HDLCircuit model, Params p, HDLPort clock) throws HDLException {
    ElementAttributes attr = new ElementAttributes().set(new Key<>("cascading", 0), p.isCascading()).set(new Key<>("D_PARAM", 0), p.d).set(new Key<>("M_PARAM", 0), p.m).set(new Key<>("DIV_PARAM", 0), p.divider).set(new Key<>("DIV4_PARAM", 0), p.divider4).set(new Key<>("PERIOD_PARAM", 0.0), clkInPeriod);
    model.integrateClockNode(clock, new HDLNodeBuildIn("MMCME2_BASE", attr, name -> 1));
}
Also used : de.neemann.digital.hdl.model2(de.neemann.digital.hdl.model2) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) ClockIntegratorGeneric(de.neemann.digital.hdl.model2.clock.ClockIntegratorGeneric) ClockInfo(de.neemann.digital.hdl.model2.clock.ClockInfo) HDLClockIntegrator(de.neemann.digital.hdl.model2.clock.HDLClockIntegrator) Key(de.neemann.digital.core.element.Key) ArrayList(java.util.ArrayList) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) Key(de.neemann.digital.core.element.Key)

Example 3 with ElementAttributes

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

the class HDLCircuit method createNot.

private HDLNode createNot(HDLPort p, HDLNode node) throws HDLException, NodeException, PinException {
    final ElementAttributes attr = new ElementAttributes().setBits(p.getBits());
    HDLNodeAssignment n = new HDLNodeAssignment(Not.DESCRIPTION.getName(), attr, name -> p.getBits());
    HDLNet outNet = new HDLNet(null);
    listOfNets.add(outNet);
    HDLNet inNet = p.getNet();
    inNet.remove(p);
    n.addPort(new HDLPort(Not.DESCRIPTION.getInputDescription(attr).get(0).getName(), inNet, HDLPort.Direction.IN, p.getBits()));
    n.addPort(new HDLPort(Not.DESCRIPTION.getOutputDescriptions(attr).get(0).getName(), outNet, HDLPort.Direction.OUT, p.getBits()));
    p.setNet(outNet);
    node.replaceNet(inNet, outNet);
    n.setExpression(new ExprNot(new ExprVar(n.getInputs().get(0).getNet())));
    return n;
}
Also used : ExprVar(de.neemann.digital.hdl.model2.expression.ExprVar) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) ExprNot(de.neemann.digital.hdl.model2.expression.ExprNot)

Example 4 with ElementAttributes

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

the class DecoderTest method testDecoder.

public void testDecoder() throws Exception {
    Model model = new Model();
    ObservableValue sel = new ObservableValue("sel", 2);
    Decoder decoder = model.add(new Decoder(new ElementAttributes().set(Keys.SELECTOR_BITS, 2)));
    decoder.setInputs(sel.asList());
    TestExecuter te = new TestExecuter(model).setInputs(sel).setOutputs(decoder.getOutputs());
    te.check(0, 1, 0, 0, 0);
    te.check(1, 0, 1, 0, 0);
    te.check(2, 0, 0, 1, 0);
    te.check(3, 0, 0, 0, 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 5 with ElementAttributes

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

the class MultiplexerTest method testMux2.

public void testMux2() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue b = new ObservableValue("b", 4);
    ObservableValue c = new ObservableValue("c", 4);
    ObservableValue d = new ObservableValue("d", 4);
    ObservableValue sel = new ObservableValue("sel", 1);
    FanIn out = new Multiplexer(new ElementAttributes().set(Keys.BITS, 4).set(Keys.SELECTOR_BITS, 2));
    try {
        out.setInputs(ovs(a, b, c, d, sel));
        assertTrue(false);
    } catch (BitsException e) {
        assertTrue(true);
    }
}
Also used : FanIn(de.neemann.digital.core.basic.FanIn) ObservableValue(de.neemann.digital.core.ObservableValue) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) BitsException(de.neemann.digital.core.BitsException)

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