Search in sources :

Example 1 with DataField

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

the class CircuitTest method createCircuit.

private static Circuit createCircuit() {
    Circuit c = new Circuit();
    // add a ROM
    final DataField data = new DataField(4);
    data.setData(0, 0xffff0000ffff0000L);
    data.setData(1, 0x8fff0000ffff0000L);
    final VisualElement rom = new VisualElement(ROM.DESCRIPTION.getName()).setAttribute(Keys.DATA, data);
    c.add(rom);
    // add an input
    final VisualElement in = new VisualElement(In.DESCRIPTION.getName()).setAttribute(Keys.INPUT_DEFAULT, new InValue(0x8fff0000ffff0000L));
    c.add(in);
    return c;
}
Also used : DataField(de.neemann.digital.core.memory.DataField) InValue(de.neemann.digital.core.io.InValue)

Example 2 with DataField

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

the class ElementAttributesTest method testDataField.

/**
 * Ensures that the DataField is accessible from within the template engine
 */
public void testDataField() throws IOException, ParserException, HGSEvalException {
    DataField d = new DataField(5).setData(0, 1).setData(1, 7).setData(2, 4).setData(3, 8).setData(4, 2);
    Context c = new Context().declareVar("d", d);
    new Parser("(<? for(i:=0;i<sizeOf(d);i++) { if (i>0) print(\"-\"); print(d[i]);} ?>)").parse().execute(c);
    assertEquals("(1-7-4-8-2)", c.toString());
}
Also used : Context(de.neemann.digital.hdl.hgs.Context) DataField(de.neemann.digital.core.memory.DataField) Parser(de.neemann.digital.hdl.hgs.Parser)

Example 3 with DataField

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

the class RAMShape method applyStateMonitor.

@Override
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
    return new Interactor() {

        @Override
        public boolean clicked(CircuitComponent cc, Point pos, IOState ioState, Element element, Sync modelSync) {
            if (element instanceof RAMInterface) {
                DataField dataField = ((RAMInterface) element).getMemory();
                DataEditor dataEditor = new DataEditor(cc, dataField, size, dataBits, addrBits, true, modelSync);
                dataEditor.showDialog(dialogTitle, model);
            }
            return false;
        }
    };
}
Also used : DataEditor(de.neemann.digital.gui.components.DataEditor) DataField(de.neemann.digital.core.memory.DataField) CircuitComponent(de.neemann.digital.gui.components.CircuitComponent) IOState(de.neemann.digital.draw.elements.IOState) Sync(de.neemann.digital.gui.sync.Sync) RAMInterface(de.neemann.digital.core.memory.RAMInterface)

Example 4 with DataField

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

the class TestProcessor method createProcessor.

private ToBreakRunner createProcessor(String program, String processor) throws IOException, PinException, NodeException, ElementNotFoundException {
    ToBreakRunner runner = new ToBreakRunner(processor, false);
    Model model = runner.getModel();
    ROM rom = null;
    for (ROM r : model.findNode(ROM.class)) {
        if (r.isProgramMemory())
            rom = r;
    }
    assertNotNull(rom);
    rom.setData(new DataField(new File(Resources.getRoot(), program)));
    runner.getModel().init(true);
    return runner;
}
Also used : ROM(de.neemann.digital.core.memory.ROM) DataField(de.neemann.digital.core.memory.DataField) Model(de.neemann.digital.core.Model) File(java.io.File)

Example 5 with DataField

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

the class RomLoader method preInit.

@Override
public void preInit(Model model) throws NodeException {
    List<ROM> roms = model.findNode(ROM.class, ROM::isProgramMemory);
    if (roms.isEmpty())
        throw new NodeException(Lang.get("msg_noRomFound"));
    if (roms.size() > 1)
        throw new NodeException(Lang.get("msg_moreThenOneRomFound"));
    try {
        roms.get(0).setData(new DataField(romHex));
        roms.get(0).provideRomAdress(model);
    } catch (IOException e) {
        throw new NodeException(e.getMessage());
    }
}
Also used : ROM(de.neemann.digital.core.memory.ROM) DataField(de.neemann.digital.core.memory.DataField) NodeException(de.neemann.digital.core.NodeException) IOException(java.io.IOException)

Aggregations

DataField (de.neemann.digital.core.memory.DataField)7 ROM (de.neemann.digital.core.memory.ROM)2 Model (de.neemann.digital.core.Model)1 Node (de.neemann.digital.core.Node)1 NodeException (de.neemann.digital.core.NodeException)1 InValue (de.neemann.digital.core.io.InValue)1 RAMInterface (de.neemann.digital.core.memory.RAMInterface)1 IOState (de.neemann.digital.draw.elements.IOState)1 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)1 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)1 CircuitComponent (de.neemann.digital.gui.components.CircuitComponent)1 DataEditor (de.neemann.digital.gui.components.DataEditor)1 Sync (de.neemann.digital.gui.sync.Sync)1 Context (de.neemann.digital.hdl.hgs.Context)1 Parser (de.neemann.digital.hdl.hgs.Parser)1 File (java.io.File)1 IOException (java.io.IOException)1