Commit 9043a11d authored by apvrille's avatar apvrille
Browse files

Update on NoC management: routing table, creating basic mapping and architecture

parent 6febac09
......@@ -449,4 +449,18 @@ public class TMLArchitecture {
}
hwnodes = newList;
}
public HwNoC getHwNoC() {
for(HwNode node: hwnodes) {
if (node instanceof HwNoC) {
return ((HwNoC)node);
}
}
return null;
}
public int getSizeOfNoC() {
HwNoC noc = getHwNoC();
return (noc == null ? -1 : noc.size);
}
}
......@@ -45,7 +45,9 @@ import myutil.FileUtils;
import myutil.TraceManager;
import tmltranslator.*;
import java.awt.*;
import java.util.*;
import java.util.List;
/**
......@@ -77,7 +79,7 @@ public class TMAP2Network<E> {
- Only one router set (i.e. no router, then bus, then router) between two tasks
- Channels must be mapped on at least one route to be taken into account
*/
public void removeAllRouterNodes() {
public String removeAllRouterNodes() {
//TMLModeling<E> tmlm = new TMLModeling<>();
//TMLArchitecture tmla = new TMLArchitecture();
//tmlmapping = new TMLMapping<E>(tmlm, tmla, false);
......@@ -91,15 +93,23 @@ public class TMAP2Network<E> {
// all local channels are mapped on this memory, otherwise they
// use the bus
// So, from the initial archi, we keep only the HwExecutionNodes
// So, from the initial archi, we keep only the HwExecutionNodes and the NoC
HwNoC noc = tmla.getHwNoC();
if (noc == null) {
return "No NoC in the architecture";
}
tmla.removeAllNonHwExecutionNodes();
// Then, for each HwExecNode, we add one bus and one memory
// and we create the corresponding link
tmla.getHwLinks().clear();
List<HwNode> newList = new ArrayList<HwNode>();
int nbOfHwExecutionNode = 0;
for(HwNode node: tmla.getHwNodes()) {
if (node instanceof HwExecutionNode) {
nbOfHwExecutionNode ++;
newList.add(node);
HwBus bus = new HwBus(node.getName() + "__bus");
HwMemory mem = new HwMemory(node.getName() + "__mem");
newList.add(bus);
......@@ -119,6 +129,34 @@ public class TMAP2Network<E> {
}
newList = null;
// Check for no more CPU than gridsize
// Put a random place to non placed CPU
// All CPU must be placed
if (nbOfHwExecutionNode > (nocSize * nocSize)) {
return "Too many processors for the NoC size";
}
// Check for placementMap
if (noc.placementMap == null) {
noc.makePlacement("", noc.size);
}
for(HwNode node: tmla.getHwNodes()) {
if (node instanceof HwExecutionNode) {
Point p = noc.placementMap.get(node.getName());
if (p == null) {
// Processor not mapped on grid
// Find an available place
if (!(noc.map(node.getName()))) {
return "Could not map " + node.getName() + " on the NoC";
}
}
}
}
// the NoC is fully mapped. Let's print it!
TraceManager.addDev("\nNoc:\n" + noc.toString() + "\n\n");
// We need to update mapping information
// First, wee keep only the task mapping
// then, we map to the local memory only channels between tasks on the same CPU
......@@ -148,7 +186,7 @@ public class TMAP2Network<E> {
// We must find the number of apps connected on this router
int nbOfApps = 2;
TranslatedRouter tr = new TranslatedRouter<>(tmlmapping, channelsCommunicatingViaNoc, nbOfVCs, i, j);
TranslatedRouter tr = new TranslatedRouter<>(tmlmapping, noc, channelsCommunicatingViaNoc, nbOfVCs, i, j);
routers[i][j] = tr;
tr.makeRouter();
}
......@@ -165,8 +203,9 @@ public class TMAP2Network<E> {
// A bridge is put with the same position as the router as to allow classical paths not to use the router
// We consider all channels mapped on at least one router.
return null; // all ok
}
}
......@@ -60,6 +60,7 @@ public class TranslatedRouter<E> {
private int nbOfVCs, xPos, yPos, nbOfApps;
private HwNoC noc;
private List<TMLChannel> channelsViaNoc;
private Vector<TMLEvent> pktins;
......@@ -69,8 +70,9 @@ public class TranslatedRouter<E> {
public TranslatedRouter(TMLMapping<E> tmlmap, List<TMLChannel> channelsViaNoc, int nbOfVCs, int xPos, int yPos) {
public TranslatedRouter(TMLMapping<E> tmlmap, HwNoC noc, List<TMLChannel> channelsViaNoc, int nbOfVCs, int xPos, int yPos) {
this.nbOfVCs = nbOfVCs;
this.noc = noc;
this.channelsViaNoc = channelsViaNoc;
this.xPos = xPos;
this.yPos = yPos;
......
......@@ -2991,6 +2991,13 @@ public class GTMLModeling {
router.bufferByteSize = routerNode.getBufferByteDataSize();
router.clockRatio = routerNode.getClockRatio();
router.size = routerNode.getNoCSize();
boolean b = router.makePlacement(routerNode.getPlacement(), router.size);
if (!b) {
UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "NoC " + routerNode.getName() + "has an invalid placement map: ");
ce.setTDiagramPanel(tmlap.tmlap);
ce.setTGComponent(routerNode);
checkingErrors.add(ce);
}
listE.addCor(router, routerNode);
archi.addHwNode(router);
//TraceManager.addDev("Router node added:" + router.getName());
......
......@@ -46,12 +46,15 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import tmltranslator.HwBridge;
import tmltranslator.HwExecutionNode;
import tmltranslator.HwNoC;
import ui.*;
import ui.util.IconManager;
import ui.window.JDialogRouterNode;
import javax.swing.*;
import java.awt.*;
import java.util.HashMap;
/**
* Class TMLArchiRouterNode
......@@ -69,6 +72,7 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa
private int size = 2; // 2x2 NoC by default
private int bufferByteDataSize = HwBridge.DEFAULT_BUFFER_BYTE_DATA_SIZE;
private String placement = "";
public TMLArchiRouterNode(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);
......@@ -180,7 +184,7 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa
JDialogRouterNode dialog = new JDialogRouterNode(frame, "Setting NoC attributes", this);
// dialog.setSize(350, 350);
GraphicLib.centerOnParent(dialog, 350, 350);
GraphicLib.centerOnParent(dialog, 650, 350);
dialog.setVisible( true ); // blocked until dialog has been closed
if (!dialog.isRegularClose()) {
......@@ -243,6 +247,17 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa
}
}
if (dialog.getPlacement().length() != 0) {
String tmpS = dialog.getPlacement();
HashMap<String, Point> hashMap = HwNoC.makePlacementMap(tmpS, size);
if (hashMap == null) {
error = true;
errors += "Placement is invalid ";
} else {
placement = tmpS;
}
}
if (error) {
JOptionPane.showMessageDialog(frame,
......@@ -266,6 +281,7 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa
sb.append("\" />\n");
sb.append("<attributes bufferByteDataSize=\"" + bufferByteDataSize + "\" ");
sb.append(" size=\"" + size + "\" ");
sb.append(" placement=\"" + placement + "\" ");
sb.append(" clockRatio=\"" + clockRatio + "\" ");
sb.append("/>\n");
sb.append("</extraparam>\n");
......@@ -312,6 +328,10 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa
if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){
clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue();
}
if ((elt.getAttribute("placement") != null) && (elt.getAttribute("placement").length() > 0)){
placement = elt.getAttribute("placement");
}
}
}
}
......@@ -344,5 +364,9 @@ public class TMLArchiRouterNode extends TMLArchiCommunicationNode implements Swa
return TRANSFER;
}
public String getPlacement() {
return placement;
}
}
......@@ -308,8 +308,25 @@ public class JDialogNoCManagement extends JDialog implements ActionListener, Lis
TraceManager.addDev("Thread started");
outputText.append("\nPreparing model\n");
TMAP2Network t2n = new TMAP2Network<>(map, 2);
t2n.removeAllRouterNodes();
int size = map.getTMLArchitecture().getSizeOfNoC();
if (size < 0) {
outputText.append("\nNo NoC found. Aborting.\n");
return;
}
if (size < 2) {
outputText.append("\nNoC must be at least of size 2x2. Currently: " + size + ". Aborting.\n");
return;
}
TMAP2Network t2n = new TMAP2Network<>(map, size);
String error = t2n.removeAllRouterNodes();
if (error != null) {
outputText.append("\nERROR: " + error + ". Aborting.\n");
stopProcess();
return;
}
outputText.append("\nAll done\n");
......
......@@ -73,7 +73,7 @@ public class JDialogRouterNode extends JDialogBase implements ActionListener {
protected JTextField nodeName;
// Panel2
protected JTextField bufferByteDataSize, size, clockRatio;
protected JTextField bufferByteDataSize, size, clockRatio, placement;
/* Creates new form */
public JDialogRouterNode(Frame _frame, String _title, TMLArchiRouterNode _node) {
......@@ -137,6 +137,12 @@ public class JDialogRouterNode extends JDialogBase implements ActionListener {
size = new JTextField(""+node.getNoCSize(), 15);
panel2.add(size, c2);
c2.gridwidth = 1;
panel2.add(new JLabel("Placement: \"CPU gridx gridy ;\""), c2);
c2.gridwidth = GridBagConstraints.REMAINDER; //end row
placement = new JTextField(""+node.getPlacement(), 15);
panel2.add(placement, c2);
c2.gridwidth = 1;
panel2.add(new JLabel("Clock divider:"), c2);
c2.gridwidth = GridBagConstraints.REMAINDER; //end row
......@@ -148,11 +154,11 @@ public class JDialogRouterNode extends JDialogBase implements ActionListener {
c0.weighty = 1.0;
c0.weightx = 1.0;
c0.gridwidth = GridBagConstraints.REMAINDER; //end row
c0.fill = GridBagConstraints.HORIZONTAL;
c.add(panel2, c0);
c0.gridwidth = 1;
c0.gridheight = 1;
c0.fill = GridBagConstraints.HORIZONTAL;
initButtons(c0, c, this);
}
......@@ -200,6 +206,10 @@ public class JDialogRouterNode extends JDialogBase implements ActionListener {
return size.getText();
}
public String getPlacement() {
return placement.getText();
}
public String getClockRatio() {
return clockRatio.getText();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment