Skip to content
Snippets Groups Projects
Commit dcc553a4 authored by Andrea Enrici's avatar Andrea Enrici
Browse files

to be committed to branch diplodocus_gui

parent c49827fc
No related branches found
No related tags found
1 merge request!46Diplodocus channels data type
......@@ -50,10 +50,12 @@ package tmltranslator;
public class HwMemory extends HwCommunicationNode {
public static final int DEFAULT_BYTE_DATA_SIZE = 4;
public static final int DEFAULT_MEMORY_SIZE = 1024;
public static final int DEFAULT_BUFFER_TYPE = 0;
public int bufferType = DEFAULT_BUFFER_TYPE;
public int byteDataSize = DEFAULT_BYTE_DATA_SIZE; // In bytes. Should more than 0
public int memorySize = DEFAULT_MEMORY_SIZE; // In bytes. Should more than 0
public HwMemory(String _name) {
super(_name);
......@@ -61,7 +63,7 @@ public class HwMemory extends HwCommunicationNode {
public String toXML() {
String s = "<MEMORY name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" bufferType=\"" + bufferType + "\" />\n";
String s = "<MEMORY name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" memorySize=\"" + memorySize + "\" bufferType=\"" + bufferType + "\" />\n";
return s;
}
......
......@@ -70,6 +70,7 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa
private int bufferType = 0;
private int byteDataSize = HwMemory.DEFAULT_BYTE_DATA_SIZE;
private int memorySize = HwMemory.DEFAULT_MEMORY_SIZE;
public TMLArchiMemoryNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) {
super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
......@@ -226,6 +227,21 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa
}
}
if (dialog.getMemorySize().length() != 0) {
try {
tmp = memorySize;
memorySize = Integer.decode(dialog.getMemorySize()).intValue();
if (memorySize <= 0) {
memorySize = tmp;
error = true;
errors += "Data size ";
}
} catch (Exception e) {
error = true;
errors += "Memory size ";
}
}
if (dialog.getClockRatio().length() != 0) {
try {
tmp = clockRatio;
......@@ -291,6 +307,7 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa
sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name);
sb.append("\" />\n");
sb.append("<attributes byteDataSize=\"" + byteDataSize + "\" ");
sb.append(" memorySize=\"" + memorySize + "\" ");
sb.append(" clockRatio=\"" + clockRatio + "\" ");
sb.append(" bufferType=\"" + bufferType + "\" ");
sb.append("/>\n");
......@@ -332,6 +349,9 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa
if (elt.getTagName().equals("attributes")) {
byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue();
if ((elt.getAttribute("memorySize") != null) && (elt.getAttribute("memorySize").length() > 0)) {
memorySize = Integer.decode(elt.getAttribute("memorySize")).intValue();
}
if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){
clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue();
}
......@@ -354,9 +374,14 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa
return byteDataSize;
}
public int getMemorySize(){
return memorySize;
}
public String getAttributes() {
String attr = "";
attr += "Data size (in byte) = " + byteDataSize + "\n";
attr += "Memory size (in byte) = " + memorySize + "\n";
attr += "Clock divider = " + clockRatio + "\n";
return attr;
}
......
......@@ -74,7 +74,7 @@ public class JDialogMemoryNode extends JDialogBase implements ActionListener {
protected JTextField nodeName;
// Panel2
protected JTextField byteDataSize, monitored, clockRatio;
protected JTextField byteDataSize, memorySize, monitored, clockRatio;
//Panel3: code generation
protected int bufferType = 0; //it is the index in the ArrayList of String
......@@ -176,6 +176,12 @@ public class JDialogMemoryNode extends JDialogBase implements ActionListener {
bufferTypesCB.setSelectedIndex( bufferType );
panel3.add( bufferTypesCB, c3 );
c3.gridwidth = 1;
panel3.add( new JLabel( "Memory size (in byte):" ), c3 );
c3.gridwidth = GridBagConstraints.REMAINDER; //end row
memorySize = new JTextField( "" + node.getMemorySize(), 15 );
panel3.add( memorySize, c3 );
// main panel;
c0.gridheight = 10;
c0.weighty = 1.0;
......@@ -240,6 +246,10 @@ public class JDialogMemoryNode extends JDialogBase implements ActionListener {
return byteDataSize.getText();
}
public String getMemorySize() {
return memorySize.getText();
}
public int getMonitored() {
return tracemode.getSelectedIndex();
//return monitored.getText();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment