Commit 6febac09 authored by apvrille's avatar apvrille
Browse files

Enhancing NoC Translation. Improvement over the dialog for connector between diplo buses and others

parent 2c986114
......@@ -83,6 +83,11 @@ public class HwLink implements Comparable<HwLink> {
return s;
}
public void setNodes(HwBus bus, HwNode node) {
this.bus = bus;
this.hwnode = node;
}
public boolean areConnected(HwNode node1, HwNode node2) {
if (connectedBusHwNode(node1, node2)) {
return true;
......
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
*
* ludovic.apvrille AT enst.fr
*
* This software is a computer program whose purpose is to allow the
* edition of TURTLE analysis, design and deployment diagrams, to
* allow the generation of RT-LOTOS or Java code from this diagram,
* and at last to allow the analysis of formal validation traces
* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
* from INRIA Rhone-Alpes.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package tmltranslator;
import java.util.ArrayList;
/**
* Class HwRouter
* Creation: 07/01/2019
* @version 1.0 07/01/2019
* @author Ludovic APVRILLE
*/
public class HwRouter extends HwCommunicationNode {
public static final int DEFAULT_BUFFER_BYTE_DATA_SIZE = 4;
public int latency = 0;
public int bufferByteSize = DEFAULT_BUFFER_BYTE_DATA_SIZE; // In bytes. Should more than 0
public int size = 2; //2x2 by default
public HwRouter(String _name) {
super(_name);
}
public String toXML() {
String s = "<ROUTER name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" bufferByteSize=\"" + bufferByteSize + "\" />\n";
return s;
}
}
......@@ -146,7 +146,7 @@ public class TMLArchiTextSpecification {
HwA hwa;
HwBus bus;
HwBridge bridge;
HwRouter router;
HwNoC router;
HwMemory memory;
HwDMA dma;
......@@ -225,8 +225,8 @@ public class TMLArchiTextSpecification {
}
// Router
if (node instanceof HwRouter) {
router = (HwRouter) node;
if (node instanceof HwNoC) {
router = (HwNoC) node;
name = prepareString(node.getName());
set = "SET " + name + " ";
code += "NODE ROUTER " + name + CR;
......@@ -461,7 +461,7 @@ public class TMLArchiTextSpecification {
HwBridge bridge = new HwBridge(_split[2]);
tmla.addHwNode(bridge);
} else if (_split[1].equals("ROUTER")) {
HwRouter router = new HwRouter(_split[2]);
HwNoC router = new HwNoC(_split[2]);
tmla.addHwNode(router);
} else if (_split[1].equals("HWA")) {
HwA hwa = new HwA(_split[2]);
......@@ -727,8 +727,8 @@ public class TMLArchiTextSpecification {
}
}
if (node instanceof HwRouter) {
HwRouter router = (HwRouter) node;
if (node instanceof HwNoC) {
HwNoC router = (HwNoC) node;
if (!checkParameter("SET", _split, 2, 11, _lineNb)) {
return -1;
......
......@@ -437,4 +437,16 @@ public class TMLArchitecture {
}
return false;
}
// For NoC manipulation
public void removeAllNonHwExecutionNodes() {
List<HwNode> newList = new ArrayList<HwNode>();
for(HwNode node: hwnodes) {
if (node instanceof HwExecutionNode) {
newList.add(node);
}
}
hwnodes = newList;
}
}
......@@ -158,6 +158,11 @@ public class TMLMapping<E> {
return null;
}
public void emptyCommunicationMapping() {
oncommnodes.clear();
mappedcommelts.clear();
}
public CorrespondanceTGElement getCorrespondanceList() {
return listE;
}
......@@ -602,6 +607,7 @@ public class TMLMapping<E> {
return onnodes.get(index);
}
public void removeTask(TMLTask _task) {
int index = mappedtasks.indexOf(_task);
if (index > -1) {
......@@ -1799,7 +1805,21 @@ public class TMLMapping<E> {
// Routers / NoC / Network
public void removeAllRouters() {
TMAP2Network translator = new TMAP2Network(this, 2);
TMAP2Network translator = new TMAP2Network<>(this, 2);
translator.removeAllRouterNodes();
}
public int getNbOfNoCs() {
if (tmla == null) {
return 0;
}
int cpt = 0;
for(HwNode node: tmla.getHwNodes()) {
if (node instanceof HwNoC) {
cpt ++;
}
}
return cpt;
}
}
......@@ -82,6 +82,7 @@ public class TMLSyntaxChecking {
private final String INVALID_BUS_PATH = "Bus path is invalid for channel"; // Should be a warning only
private final String DUPLICATE_PATH_TO_BUS = "Path to bus is duplicated"; // Should be a warning only
private final String ONLY_ONE_NOC = "Only one NoC can be used"; // Should be a warning only
private ArrayList<TMLError> errors;
......@@ -134,6 +135,7 @@ public class TMLSyntaxChecking {
checkPathToMemory();
checkPathValidity();
checkNonDuplicatePathToBuses();
checkOneNOC();
// Check that if their is a memory for a channel, the memory is connected to the path
}
......@@ -807,4 +809,17 @@ public class TMLSyntaxChecking {
}
private void checkOneNOC() {
TraceManager.addDev("Checking NOC Nodes");
int nb = mapping.getNbOfNoCs();
if (nb > 1) {
addError(null, null, ONLY_ONE_NOC, TMLError.ERROR_STRUCTURE);
return;
}
}
}
......@@ -55,7 +55,7 @@ import java.util.*;
* @author Ludovic Apvrille
* @version 1.0 07/01/2019
*/
public class TMAP2Network {
public class TMAP2Network<E> {
private TMLModeling<?> tmlmodeling;
private TMLMapping<?> tmlmapping;
......@@ -78,13 +78,77 @@ public class TMAP2Network {
- Channels must be mapped on at least one route to be taken into account
*/
public void removeAllRouterNodes() {
//TMLModeling<E> tmlm = new TMLModeling<>();
//TMLArchitecture tmla = new TMLArchitecture();
//tmlmapping = new TMLMapping<E>(tmlm, tmla, false);
TMLArchitecture tmla = tmlmapping.getTMLArchitecture();
TMLModeling<?> tmlm = tmlmapping.getTMLModeling();
// we have to redo the architecture:
// we assume that each processor is connected directly to the NoC via a first bus
// so, each CPU gets one memory, on bus connecting the mem and the NoC.
// all local channels are mapped on this memory, otherwise they
// use the bus
// So, from the initial archi, we keep only the HwExecutionNodes
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>();
for(HwNode node: tmla.getHwNodes()) {
if (node instanceof HwExecutionNode) {
HwBus bus = new HwBus(node.getName() + "__bus");
HwMemory mem = new HwMemory(node.getName() + "__mem");
newList.add(bus);
newList.add(mem);
HwLink cpuToBus = new HwLink(node.getName() + "__tocpu");
cpuToBus.setNodes(bus, node);
tmla.addHwLink(cpuToBus);
HwLink memToBus = new HwLink(node.getName() + "__tomem");
memToBus.setNodes(bus, mem);
tmla.addHwLink(memToBus);
}
}
for(HwNode node: newList) {
tmla.addHwNode(node);
}
newList = null;
// 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
// Other tasks, i.e. communicating thu the NoC, are put in a special list
tmlmapping.emptyCommunicationMapping();
List<TMLChannel> channelsCommunicatingViaNoc = new ArrayList<>();
List<tmltranslator.TMLChannel> allChannels = tmlm.getChannels();
for(TMLChannel chan: allChannels) {
HwNode originNode = tmlmapping.getHwNodeOf(chan.getOriginTask());
HwNode destinationNode = tmlmapping.getHwNodeOf(chan.getDestinationTask());
if (originNode == destinationNode) {
// Channel mapped on the same node
// We map it to the corresponding mem and bus
HwNode bus = tmla.getHwNodeByName(originNode.getName() + "__bus");
HwNode mem = tmla.getHwNodeByName(originNode.getName() + "__mem");
if (bus != null ) tmlmapping.addCommToHwCommNode(chan, (HwCommunicationNode)bus);
if (bus != null ) tmlmapping.addCommToHwCommNode(chan, (HwCommunicationNode)mem);
} else {
channelsCommunicatingViaNoc.add(chan);
}
}
// Make all routers
for(int i=0; i<nocSize; i++) {
for(int j=0; j<nocSize; j++) {
// We must find the number of apps connected on this router
int nbOfApps = 2;
TranslatedRouter tr = new TranslatedRouter(nbOfApps, nbOfVCs, i, j);
TranslatedRouter tr = new TranslatedRouter<>(tmlmapping, channelsCommunicatingViaNoc, nbOfVCs, i, j);
routers[i][j] = tr;
tr.makeRouter();
}
......
......@@ -59,7 +59,8 @@ public class TaskINForDispatch extends TMLTask {
}
// Output Channels are given in the order of VCs
public void generate(int nbOfVCs, TMLEvent inputEvent, TMLChannel inputChannel, Vector<TMLEvent> outputEvents, Vector<TMLChannel> outputChannels) {
public void generate(int nbOfVCs, TMLEvent inputEvent, TMLChannel inputChannel,
Vector<TMLEvent> outputEvents, Vector<TMLChannel> outputChannels) {
this.nbOfVCs = nbOfVCs;
......
......@@ -42,6 +42,7 @@ package tmltranslator.tonetwork;
import tmltranslator.*;
import ui.TGComponent;
import java.util.List;
import java.util.Vector;
......@@ -58,18 +59,22 @@ public class TranslatedRouter<E> {
private final int CHANNEL_MAX = 8;
private int nbOfVCs, xPos, yPos, nbOfApps;
private TMLMapping<E> map;
private Vector<TMLEvent> pktins;
private List<TMLChannel> channelsViaNoc;
private Vector<TMLEvent> pktins;
private Vector<TMLTask> dispatchers;
private TMLMapping<?> tmlmap;
public TranslatedRouter(int nbOfApps, int nbOfVCs, int xPos, int yPos) {
public TranslatedRouter(TMLMapping<E> tmlmap, List<TMLChannel> channelsViaNoc, int nbOfVCs, int xPos, int yPos) {
this.nbOfVCs = nbOfVCs;
this.nbOfApps = nbOfApps;
this.channelsViaNoc = channelsViaNoc;
this.xPos = xPos;
this.yPos = yPos;
this.tmlmap = tmlmap;
}
......@@ -80,11 +85,8 @@ public class TranslatedRouter<E> {
public void makeRouter() {
int i, j;
TMLTask t;
TMLModeling tmlm = tmlmap.getTMLModeling();
// A router is made upon tasks, hardware components and a mapping i.e. a TMLMapping
TMLModeling<E> tmlm = new TMLModeling<>();
TMLArchitecture tmla = new TMLArchitecture();
map = new TMLMapping<E>(tmlm, tmla, false);
// MUX for the different writing tasks
......@@ -95,7 +97,7 @@ public class TranslatedRouter<E> {
// VC DISPATCHERS
// One dispatcher per port
// A dispatcher outputs to VCs tasks
dispatchers = new Vector<>();
dispatchers = new Vector<TMLTask>();
for(i=0; i<NB_OF_PORTS; i++) {
//TaskINForDispatch dt = new TaskINForDispatch(nbOfVCs);
//dispatchers.add(dt);
......
......@@ -52,44 +52,8 @@ import java.util.Vector;
import avatartranslator.AvatarSpecification;
import myutil.TraceManager;
import tmltranslator.HwA;
import tmltranslator.HwBridge;
import tmltranslator.HwRouter;
import tmltranslator.HwBus;
import tmltranslator.HwCPU;
import tmltranslator.HwCommunicationNode;
import tmltranslator.HwCrossbar;
import tmltranslator.HwDMA;
import tmltranslator.HwExecutionNode;
import tmltranslator.HwFPGA;
import tmltranslator.HwLink;
import tmltranslator.HwMemory;
import tmltranslator.HwNode;
import tmltranslator.HwVGMN;
import tmltranslator.SecurityPattern;
import tmltranslator.TMLActivity;
import tmltranslator.TMLActivityElement;
import tmltranslator.TMLActivityElementChannel;
import tmltranslator.TMLArchitecture;
import tmltranslator.TMLAttribute;
import tmltranslator.TMLCP;
import tmltranslator.TMLCPError;
import tmltranslator.TMLCPLib;
import tmltranslator.TMLCPLibArtifact;
import tmltranslator.TMLCPSyntaxChecking;
import tmltranslator.TMLChannel;
import tmltranslator.TMLCheckingError;
import tmltranslator.TMLElement;
import tmltranslator.TMLError;
import tmltranslator.TMLEvent;
import tmltranslator.TMLExecI;
import tmltranslator.TMLMapping;
import tmltranslator.TMLModeling;
import tmltranslator.TMLPort;
import tmltranslator.TMLRequest;
import tmltranslator.TMLSyntaxChecking;
import tmltranslator.TMLTask;
import tmltranslator.TMLType;
import tmltranslator.*;
import tmltranslator.HwNoC;
import tmltranslator.modelcompiler.ArchUnitMEC;
import tmltranslator.tmlcp.TMLCPElement;
import tmltranslator.tmlcp.TMLSDAction;
......@@ -2831,7 +2795,7 @@ public class GTMLModeling {
HwVGMN vgmn;
HwCrossbar crossbar;
HwBridge bridge;
HwRouter router;
HwNoC router;
HwMemory memory;
HwDMA dma;
......@@ -3023,7 +2987,7 @@ public class GTMLModeling {
checkingErrors.add(ce);
} else {
names.add(routerNode.getName());
router = new HwRouter(routerNode.getName());
router = new HwNoC(routerNode.getName());
router.bufferByteSize = routerNode.getBufferByteDataSize();
router.clockRatio = routerNode.getClockRatio();
router.size = routerNode.getNoCSize();
......
......@@ -81,7 +81,7 @@ public class TMLArchiConnectorNode extends TGConnector implements WithAttribute
public boolean editOndoubleClick(JFrame frame) {
JDialogTMLConnectorNode dialog = new JDialogTMLConnectorNode(frame, "Setting connector attributes", this);
//dialog.setSize(350, 300);
GraphicLib.centerOnParent(dialog, 350, 300 );
GraphicLib.centerOnParent(dialog, 450, 300 );
dialog.setVisible( true ); // blocked until dialog has been closed
if (!dialog.isRegularClose()) {
......
......@@ -156,7 +156,7 @@ public class JDialogNoCManagement extends JDialog implements ActionListener, Lis
GridBagLayout gridbag03 = new GridBagLayout();
GridBagConstraints c03 = new GridBagConstraints();
jp03.setLayout(gridbag03);
jp03.setBorder(new javax.swing.border.TitledBorder("DSE Options"));
jp03.setBorder(new javax.swing.border.TitledBorder("NoC Management Options"));
c03.weighty = 1.0;
c03.weightx = 1.0;
c03.gridwidth = GridBagConstraints.REMAINDER; //end row
......@@ -308,7 +308,7 @@ public class JDialogNoCManagement extends JDialog implements ActionListener, Lis
TraceManager.addDev("Thread started");
outputText.append("\nPreparing model\n");
TMAP2Network t2n = new TMAP2Network(map, 2);
TMAP2Network t2n = new TMAP2Network<>(map, 2);
t2n.removeAllRouterNodes();
outputText.append("\nAll done\n");
......
......@@ -55,7 +55,7 @@ import java.util.Vector;
/**
* Class JDialogTMLConnectorNode
* Dialog for managing atributes of connectors between nodes
* Dialog for managing attributes of connectors between nodes
* Creation: 22/11/2007
* @version 1.0 22/11/2007
* @author Ludovic APVRILLE
......@@ -132,6 +132,7 @@ public class JDialogTMLConnectorNode extends JDialogBase implements ActionListen
panel2.add(taskName, c1);*/
// main panel;
c0.fill = GridBagConstraints.BOTH;
c0.gridheight = 10;
c0.weighty = 1.0;
c0.weightx = 1.0;
......@@ -140,9 +141,10 @@ public class JDialogTMLConnectorNode extends JDialogBase implements ActionListen
c0.gridwidth = 1;
c0.gridheight = 1;
c0.fill = GridBagConstraints.HORIZONTAL;
initButtons(c0, c, this);
pack();
}
public void actionPerformed(ActionEvent evt) {
......
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