Commit f1831250 authored by apvrille's avatar apvrille
Browse files

Update on router translation

parent 7c466c21
......@@ -69,16 +69,99 @@ public class TMAP2Network<E> {
private int nocSize = 2;
private TranslatedRouter[][] routers;
public final static int NORTH = 0;
public final static int SOUTH = 1;
public final static int WEST = 2;
public final static int EAST = 3;
public final static int DOMAIN = 4;
public TMAP2Network(TMLMapping<?> _tmlmapping, int nocSize) {
tmlmapping = _tmlmapping;
routers = new TranslatedRouter[nbOfVCs][nbOfVCs];
this.nocSize = nocSize;
}
public static boolean hasRouterAt(int myX, int myY, int routerPosition, int nocSize) {
if (routerPosition == DOMAIN) {
return true;
}
int decX = 0;
int decY = 0;
switch(routerPosition) {
case NORTH:
decY = -1;
break;
case SOUTH:
decY = 1;
break;
case WEST:
decX = -1;
break;
case EAST:
decX = 1;
}
myX = myX + decX;
myY = myY + decY;
if ((myX < 0) || (myY < 0)) {
return false;
}
if ((myX >= nocSize) || (myY >= nocSize)) {
return false;
}
return true;
}
public TranslatedRouter getRouterAt(int xPos, int yPos) {
if (routers == null) {
return null;
}
if ((xPos < 0) || (xPos >= nocSize) || (yPos < 0) || (yPos >= nocSize)) {
return null;
}
return routers[xPos][yPos];
}
public TranslatedRouter getRouterFrom(int xPos, int yPos, int routerPosition) {
int decX = 0;
int decY = 0;
switch(routerPosition) {
case NORTH:
decY = -1;
break;
case SOUTH:
decY = 1;
break;
case WEST:
decX = -1;
break;
case EAST:
decX = 1;
}
xPos = xPos + decX;
yPos = yPos + decY;
return getRouterAt(xPos, yPos);
}
/* List of assumptions:
- 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
*/
- 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 String removeAllRouterNodes() {
//TMLModeling<E> tmlm = new TMLModeling<>();
//TMLArchitecture tmla = new TMLArchitecture();
......@@ -179,16 +262,21 @@ public class TMAP2Network<E> {
}
}
//Create 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
TranslatedRouter tr = new TranslatedRouter<>(this, tmlmapping, noc, channelsCommunicatingViaNoc,
nbOfVCs, i, j);
routers[i][j] = tr;
}
}
// 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<>(tmlmapping, noc, channelsCommunicatingViaNoc, nbOfVCs, i, j);
routers[i][j] = tr;
tr.makeRouter();
routers[i][j].makeRouter();
}
}
......
......@@ -41,7 +41,6 @@ package tmltranslator.tonetwork;
import myutil.TraceManager;
import tmltranslator.*;
import ui.TGComponent;
import java.util.HashMap;
import java.util.List;
......@@ -55,13 +54,17 @@ import java.util.Vector;
* @author Ludovic Apvrille
* @version 1.0 17/01/2019
*/
public class TranslatedRouter<E> {
public class TranslatedRouter<E> {
private final int NB_OF_PORTS = 5;
private final int CHANNEL_SIZE = 4;
private final int CHANNEL_MAX = 8;
private int nbOfVCs, xPos, yPos, nbOfApps;
private TMAP2Network<?> main;
private HwNoC noc;
private List<TMLChannel> channelsViaNoc;
......@@ -71,14 +74,17 @@ public class TranslatedRouter<E> {
private TMLMapping<?> tmlmap;
public TranslatedRouter(TMLMapping<E> tmlmap, HwNoC noc, List<TMLChannel> channelsViaNoc, int nbOfVCs, int xPos, int yPos) {
public TranslatedRouter(TMAP2Network<?> main, TMLMapping<?> tmlmap, HwNoC noc, List<TMLChannel> channelsViaNoc, int nbOfVCs, int xPos, int yPos) {
this.main = main;
this.nbOfVCs = nbOfVCs;
this.noc = noc;
this.channelsViaNoc = channelsViaNoc;
this.xPos = xPos;
this.yPos = yPos;
this.tmlmap = tmlmap;
//A router creates all its output events and channels, depending on its position in the NoC
}
......@@ -113,7 +119,7 @@ public class TranslatedRouter<E> {
Vector<TMLChannel> inputChannels = new Vector<>();
Vector<TMLChannel> outputChannels = new Vector<>();
if (execNode != null) {
for(TMLChannel ch: channelsViaNoc) {
for (TMLChannel ch : channelsViaNoc) {
TMLTask origin = ch.getOriginTask();
TMLTask destination = ch.getDestinationTask();
......@@ -140,12 +146,12 @@ public class TranslatedRouter<E> {
// We can create the MUX task: one mux task for each VC
Vector<TaskMUXAppDispatch> muxTasks = new Vector<>();
for(i=0; i<nbOfVCs; i++) {
for (i = 0; i < nbOfVCs; i++) {
// Now that we know all channels, we can generate the MUX tasks
// We need one event par outputChannel
HashMap<TMLChannel, TMLEvent> mapOfOutputChannels = new HashMap<>();
Vector<TMLEvent> inputEventsOfMUX = new Vector<>();
for(TMLChannel chan: outputChannels) {
for (TMLChannel chan : outputChannels) {
if (chan.getVC() == i) {
TMLEvent outputEventOfMux = new TMLEvent("EventMUXof" + chan.getName(), null, 8,
true);
......@@ -160,7 +166,7 @@ public class TranslatedRouter<E> {
null, 8, true);
tmlm.addEvent(eventForMUX_and_NI_IN);
TaskMUXAppDispatch muxTask = new TaskMUXAppDispatch("MUXof" + nameOfExecNode +"_VC" + i, null, null);
TaskMUXAppDispatch muxTask = new TaskMUXAppDispatch("MUXof" + nameOfExecNode + "_VC" + i, null, null);
tmlm.addTask(muxTask);
muxTask.generate(inputEventsOfMUX, eventForMUX_and_NI_IN);
muxTasks.add(muxTask);
......@@ -174,7 +180,7 @@ public class TranslatedRouter<E> {
// NETWORK INTERFACE IN
// We must first gathers events from must task
Vector<TMLEvent> inputEventsFromMUX = new Vector<>();
for(TaskMUXAppDispatch tmux: muxTasks) {
for (TaskMUXAppDispatch tmux : muxTasks) {
inputEventsFromMUX.add(tmux.getOutputEvent());
}
......@@ -185,7 +191,7 @@ public class TranslatedRouter<E> {
// One TMLEvent for feedback for each VC
Vector<TMLEvent> feedbackEventsNIINs = new Vector<>();
for(i=0; i<nbOfVCs; i++) {
for (i = 0; i < nbOfVCs; i++) {
TMLEvent eventFeedback = new TMLEvent("EventBetweenNI_IN_ANd_IN_for_" + nameOfExecNode,
null, 8, true);
feedbackEventsNIINs.add(eventFeedback);
......@@ -204,36 +210,52 @@ public class TranslatedRouter<E> {
tniIn.generate(nbOfVCs, feedbackEventsNIINs, inputEventsFromMUX, outputFromNIINtoIN, outputChannelFromNIINtoIN);
// IN NOC
// We need one ouput channel per VC and one output event per VC
Vector<TMLEvent> evtFromINtoINVCs = new Vector<>();
Vector<TMLChannel> chFromINtoINVCs = new Vector<>();
for(i=0; i<nbOfVCs; i++) {
TMLEvent evtFromINtoINVC = new TMLEvent("EventBetweenIN_IN_forVC_" + i + "_" + nameOfExecNode,
null, 8, true);
tmlm.addEvent(evtFromINtoINVC);
evtFromINtoINVCs.add(evtFromINtoINVC);
TMLChannel chFromINtoINVC = new TMLChannel("channelBetweenIN_IN_for_VC" + i + "_" + nameOfExecNode,
null);
chFromINtoINVC.setSize(4);
chFromINtoINVC.setMax(8);
tmlm.addChannel(chFromINtoINVC);
chFromINtoINVCs.add(chFromINtoINVC);
}
// IN NOC - One for each input
// We need one output channel per VC and one output event per VC
// A task only create the output, never the input
HashMap<Integer, TaskINForDispatch> dispatchIns = new HashMap<>();
for (int portNb = 0; portNb < NB_OF_PORTS; portNb++) {
TranslatedRouter routerToconnectWith = main.getRouterFrom(xPos, yPos, portNb);
if (routerToconnectWith != null) {
if (TMAP2Network.hasRouterAt(xPos, yPos, portNb, noc.size)) {
Vector<TMLEvent> evtFromINtoINVCs = new Vector<>();
Vector<TMLChannel> chFromINtoINVCs = new Vector<>();
for (i = 0; i < nbOfVCs; i++) {
TMLEvent evtFromINtoINVC = new TMLEvent("EventBetweenIN_IN_forVC_" + i + "_" + nameOfExecNode,
null, 8, true);
tmlm.addEvent(evtFromINtoINVC);
evtFromINtoINVCs.add(evtFromINtoINVC);
TMLChannel chFromINtoINVC = new TMLChannel("channelBetweenIN_IN_for_VC" + i + "_" + nameOfExecNode,
null);
chFromINtoINVC.setSize(4);
chFromINtoINVC.setMax(8);
tmlm.addChannel(chFromINtoINVC);
chFromINtoINVCs.add(chFromINtoINVC);
}
TaskINForDispatch inDispatch = new TaskINForDispatch("IN_" + execNode, null, null);
tmlm.addTask(inDispatch);
if (portNb == NB_OF_PORTS) {
inDispatch.generate(nbOfVCs, outputFromNIINtoIN, outputChannelFromNIINtoIN, evtFromINtoINVCs, chFromINtoINVCs);
} else {
TaskINForDispatch inDispatch = new TaskINForDispatch("IN_" + execNode, null, null);
tmlm.addTask(inDispatch);
inDispatch.generate(nbOfVCs, outputFromNIINtoIN, outputChannelFromNIINtoIN, evtFromINtoINVCs, chFromINtoINVCs);
}
dispatchIns.put(new Integer(portNb), inDispatch);
}
}
}
// IN specific to an input of the NoC apart from internal CPU
// inputs 0 to 3
// We create all connection events
}
}
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