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;
}
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());
}
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;
}
};
}
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;
}
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());
}
}
Aggregations