mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 07:28:20 -04:00
RAM shape also used for EEPROM.
Allows opening of data dialog.
This commit is contained in:
parent
13a8f03410
commit
cfdd1b3c1e
@ -23,7 +23,6 @@ public class RAMSinglePortSel extends Node implements Element, RAMInterface {
|
|||||||
/**
|
/**
|
||||||
* The RAMs {@link ElementTypeDescription}
|
* The RAMs {@link ElementTypeDescription}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(RAMSinglePortSel.class,
|
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(RAMSinglePortSel.class,
|
||||||
input("A"),
|
input("A"),
|
||||||
input("CS"),
|
input("CS"),
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package de.neemann.digital.draw.shapes;
|
package de.neemann.digital.draw.shapes;
|
||||||
|
|
||||||
import de.neemann.digital.core.Model;
|
import de.neemann.digital.core.Model;
|
||||||
|
import de.neemann.digital.core.NodeException;
|
||||||
import de.neemann.digital.core.Observer;
|
import de.neemann.digital.core.Observer;
|
||||||
import de.neemann.digital.core.element.Element;
|
import de.neemann.digital.core.element.*;
|
||||||
import de.neemann.digital.core.element.ElementAttributes;
|
|
||||||
import de.neemann.digital.core.element.Keys;
|
|
||||||
import de.neemann.digital.core.element.PinDescriptions;
|
|
||||||
import de.neemann.digital.core.memory.DataField;
|
import de.neemann.digital.core.memory.DataField;
|
||||||
import de.neemann.digital.core.memory.RAMInterface;
|
import de.neemann.digital.core.memory.RAMInterface;
|
||||||
import de.neemann.digital.draw.elements.IOState;
|
import de.neemann.digital.draw.elements.IOState;
|
||||||
|
import de.neemann.digital.draw.elements.PinException;
|
||||||
import de.neemann.digital.draw.model.ModelCreator;
|
import de.neemann.digital.draw.model.ModelCreator;
|
||||||
import de.neemann.digital.draw.model.ModelEntry;
|
import de.neemann.digital.draw.model.ModelEntry;
|
||||||
import de.neemann.digital.gui.components.CircuitComponent;
|
import de.neemann.digital.gui.components.CircuitComponent;
|
||||||
@ -26,19 +25,26 @@ public class RAMShape extends GenericShape {
|
|||||||
private final int dataBits;
|
private final int dataBits;
|
||||||
private final int size;
|
private final int size;
|
||||||
private final int addrBits;
|
private final int addrBits;
|
||||||
private final String label;
|
private final String dialogTitle;
|
||||||
private Model model;
|
private Model model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance
|
* Creates a new instance
|
||||||
*
|
*
|
||||||
* @param attr the label to use
|
* @param attr the attributes of the element
|
||||||
* @param inputs the inputs
|
* @param description element type description
|
||||||
* @param outputs the outputs
|
* @throws NodeException NodeException
|
||||||
|
* @throws PinException PinException
|
||||||
*/
|
*/
|
||||||
public RAMShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
|
public RAMShape(ElementAttributes attr, ElementTypeDescription description) throws NodeException, PinException {
|
||||||
super("RAM", inputs, outputs, attr.getLabel(), true);
|
super(description.getShortName(),
|
||||||
label = attr.getLabel();
|
description.getInputDescription(attr),
|
||||||
|
description.getOutputDescriptions(attr),
|
||||||
|
attr.getLabel(), true);
|
||||||
|
if (attr.getLabel().length() > 0)
|
||||||
|
dialogTitle = attr.getLabel();
|
||||||
|
else
|
||||||
|
dialogTitle = description.getShortName();
|
||||||
dataBits = attr.get(Keys.BITS);
|
dataBits = attr.get(Keys.BITS);
|
||||||
addrBits = attr.get(Keys.ADDR_BITS);
|
addrBits = attr.get(Keys.ADDR_BITS);
|
||||||
size = 1 << addrBits;
|
size = 1 << addrBits;
|
||||||
@ -52,7 +58,7 @@ public class RAMShape extends GenericShape {
|
|||||||
if (element instanceof RAMInterface) {
|
if (element instanceof RAMInterface) {
|
||||||
DataField dataField = ((RAMInterface) element).getMemory();
|
DataField dataField = ((RAMInterface) element).getMemory();
|
||||||
DataEditor dataEditor = new DataEditor(cc, dataField, size, dataBits, addrBits, true, modelSync);
|
DataEditor dataEditor = new DataEditor(cc, dataField, size, dataBits, addrBits, true, modelSync);
|
||||||
dataEditor.showDialog(label, model);
|
dataEditor.showDialog(dialogTitle, model);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import de.neemann.digital.core.element.ElementTypeDescription;
|
|||||||
import de.neemann.digital.core.element.Keys;
|
import de.neemann.digital.core.element.Keys;
|
||||||
import de.neemann.digital.core.element.PinDescriptions;
|
import de.neemann.digital.core.element.PinDescriptions;
|
||||||
import de.neemann.digital.core.io.*;
|
import de.neemann.digital.core.io.*;
|
||||||
|
import de.neemann.digital.core.memory.EEPROM;
|
||||||
import de.neemann.digital.core.memory.RAMDualPort;
|
import de.neemann.digital.core.memory.RAMDualPort;
|
||||||
import de.neemann.digital.core.memory.RAMSinglePort;
|
import de.neemann.digital.core.memory.RAMSinglePort;
|
||||||
import de.neemann.digital.core.memory.RAMSinglePortSel;
|
import de.neemann.digital.core.memory.RAMSinglePortSel;
|
||||||
@ -73,9 +74,10 @@ public final class ShapeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
map.put(RAMDualPort.DESCRIPTION.getName(), (attr, inputs, outputs) -> new RAMShape(attr, RAMDualPort.DESCRIPTION.getInputDescription(attr), RAMDualPort.DESCRIPTION.getOutputDescriptions(attr)));
|
map.put(RAMDualPort.DESCRIPTION.getName(), (attr, inputs, outputs) -> new RAMShape(attr, RAMDualPort.DESCRIPTION));
|
||||||
map.put(RAMSinglePort.DESCRIPTION.getName(), (attr, inputs, outputs) -> new RAMShape(attr, RAMSinglePort.DESCRIPTION.getInputDescription(attr), RAMSinglePort.DESCRIPTION.getOutputDescriptions(attr)));
|
map.put(RAMSinglePort.DESCRIPTION.getName(), (attr, inputs, outputs) -> new RAMShape(attr, RAMSinglePort.DESCRIPTION));
|
||||||
map.put(RAMSinglePortSel.DESCRIPTION.getName(), (attr, inputs, outputs) -> new RAMShape(attr, RAMSinglePortSel.DESCRIPTION.getInputDescription(attr), RAMSinglePortSel.DESCRIPTION.getOutputDescriptions(attr)));
|
map.put(RAMSinglePortSel.DESCRIPTION.getName(), (attr, inputs, outputs) -> new RAMShape(attr, RAMSinglePortSel.DESCRIPTION));
|
||||||
|
map.put(EEPROM.DESCRIPTION.getName(), (attr, inputs, outputs) -> new RAMShape(attr, EEPROM.DESCRIPTION));
|
||||||
|
|
||||||
map.put(In.DESCRIPTION.getName(), InputShape::new);
|
map.put(In.DESCRIPTION.getName(), InputShape::new);
|
||||||
map.put(Reset.DESCRIPTION.getName(), ResetShape::new);
|
map.put(Reset.DESCRIPTION.getName(), ResetShape::new);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user