Skip to content
Snippets Groups Projects
Commit 4a5bdea1 authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Update on network

parent bc8c8aa5
No related branches found
No related tags found
No related merge requests found
...@@ -183,6 +183,8 @@ public class TMAP2Network<E> { ...@@ -183,6 +183,8 @@ public class TMAP2Network<E> {
- Channels must be mapped on at least one route to be taken into account - Channels must be mapped on at least one route to be taken into account
*/ */
public String removeAllRouterNodes() { public String removeAllRouterNodes() {
int i, j;
//TMLModeling<E> tmlm = new TMLModeling<>(); //TMLModeling<E> tmlm = new TMLModeling<>();
//TMLArchitecture tmla = new TMLArchitecture(); //TMLArchitecture tmla = new TMLArchitecture();
//tmlmapping = new TMLMapping<E>(tmlm, tmla, false); //tmlmapping = new TMLMapping<E>(tmlm, tmla, false);
...@@ -283,8 +285,8 @@ public class TMAP2Network<E> { ...@@ -283,8 +285,8 @@ public class TMAP2Network<E> {
} }
// *** Create routers // *** Create routers
for(int i=0; i<nocSize; i++) { for(i=0; i<nocSize; i++) {
for(int j=0; j<nocSize; j++) { for(j=0; j<nocSize; j++) {
// We must find the number of apps connected on this router // We must find the number of apps connected on this router
TranslatedRouter tr = new TranslatedRouter<>(this, tmlmapping, noc, channelsCommunicatingViaNoc, TranslatedRouter tr = new TranslatedRouter<>(this, tmlmapping, noc, channelsCommunicatingViaNoc,
nbOfVCs, i, j); nbOfVCs, i, j);
...@@ -292,25 +294,101 @@ public class TMAP2Network<E> { ...@@ -292,25 +294,101 @@ public class TMAP2Network<E> {
} }
} }
// *** Create links and update routers accordingly
// For each router, I consider all routers that are around the considered on
for(i=0; i<nocSize; i++) {
for(j=0; j<nocSize; j++) {
for(int k=0; k< DOMAIN; k++) {
// NORTH?
if (i>0) {
// There is a north router
// link to next
if (routers[i][j].toNextRouters[k] != null) {
Link to = new Link(tmlmodeling, routers[i][j], routers[i-1][j], nbOfVCs);
routers[i][j].toNextRouters[k] = to;
routers[i-1][j].fromPreviousRouters[getFrom(k)] = to;
}
// Link to previous
if (routers[i][j].fromPreviousRouters[k] != null) {
Link from = new Link(tmlmodeling, routers[i][j], routers[i-1][j], nbOfVCs);
routers[i][j].fromPreviousRouters[k] = from;
routers[i-1][j].toNextRouters[getFrom(k)] = from;
}
}
// SOUTH?
if (i<nocSize-1) {
// There is a south router
// link to next
if (routers[i][j].toNextRouters[k] != null) {
Link to = new Link(tmlmodeling, routers[i][j], routers[i+1][j], nbOfVCs);
routers[i][j].toNextRouters[k] = to;
routers[i+1][j].fromPreviousRouters[getFrom(k)] = to;
}
// Link to previous
if (routers[i][j].fromPreviousRouters[k] != null) {
Link from = new Link(tmlmodeling, routers[i][j], routers[i+1][j], nbOfVCs);
routers[i][j].fromPreviousRouters[k] = from;
routers[i+1][j].toNextRouters[getFrom(k)] = from;
}
}
// EAST?
if (j<nocSize-1) {
// There is an east router
// link to next
if (routers[i][j].toNextRouters[k] != null) {
Link to = new Link(tmlmodeling, routers[i][j+1], routers[i][j+1], nbOfVCs);
routers[i][j].toNextRouters[k] = to;
routers[i][j+1].fromPreviousRouters[getFrom(k)] = to;
}
// Link to previous
if (routers[i][j].fromPreviousRouters[k] != null) {
Link from = new Link(tmlmodeling, routers[i][j], routers[i][j+1], nbOfVCs);
routers[i][j].fromPreviousRouters[k] = from;
routers[i][j+1].toNextRouters[getFrom(k)] = from;
}
}
// WEST?
if (j>0) {
// There is an east router
// link to next
if (routers[i][j].toNextRouters[k] != null) {
Link to = new Link(tmlmodeling, routers[i][j+1], routers[i][j-1], nbOfVCs);
routers[i][j].toNextRouters[k] = to;
routers[i][j-1].fromPreviousRouters[getFrom(k)] = to;
}
// Link to previous
if (routers[i][j].fromPreviousRouters[k] != null) {
Link from = new Link(tmlmodeling, routers[i][j], routers[i][j-1], nbOfVCs);
routers[i][j].fromPreviousRouters[k] = from;
routers[i][j-1].toNextRouters[getFrom(k)] = from;
}
}
}
}
}
// Make the channels & events of routers // Make internal channels & events of routers
for(int i=0; i<nocSize; i++) { for(i=0; i<nocSize; i++) {
for(int j=0; j<nocSize; j++) { for(j=0; j<nocSize; j++) {
// We must find the number of apps connected on this router // We must find the number of apps connected on this router
routers[i][j].makeOutputEventsChannels(); routers[i][j].makeOutputEventsChannels();
} }
} }
// Make all routers // Make all routers
for(int i=0; i<nocSize; i++) { for(i=0; i<nocSize; i++) {
for(int j=0; j<nocSize; j++) { for(j=0; j<nocSize; j++) {
// We must find the number of apps connected on this router // We must find the number of apps connected on this router
routers[i][j].makeRouter(); routers[i][j].makeRouter();
} }
} }
// Connect their feedback
// Make their routing // Make their routing
// Integrate into the TMLMapping // Integrate into the TMLMapping
......
/* 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.tonetwork;
import tmltranslator.*;
import java.util.Vector;
/**
* Class TaskNetworkInterfaceOUT
* Creation: 07/05/2019
*
* @author Ludovic Apvrille
* @version 1.0 07/05/2019
*/
public class TaskNetworkInterfaceOUT extends TMLTask {
protected int nbOfVCs;
public TaskNetworkInterfaceOUT(String name, Object referenceToClass, Object referenceToActivityDiagram) {
super(name, referenceToClass, referenceToActivityDiagram);
}
// feedbackEvents: one per vc
// inputEvt, channels: one per task
// outputChannel, output event: only one, common: this is a network interface, only one exit!
public void generate(int nbOfVCs, Vector<TMLEvent> outputFeedbackEvents, TMLEvent packetOutFromOUT,
TMLEvent packetAvailable, TMLChannel outputChannelFromOUT) {
int i;
this.nbOfVCs = nbOfVCs;
// Attributes
TMLAttribute dst = new TMLAttribute("dst", "dst", new TMLType(TMLType.NATURAL), "0");
this.addAttribute(dst);
TMLAttribute pktlen = new TMLAttribute("pktlen", "pktlen", new TMLType(TMLType.NATURAL), "0");
this.addAttribute(pktlen);
TMLAttribute vc = new TMLAttribute("vc", "vc", new TMLType(TMLType.NATURAL), "0");
this.addAttribute(vc);
TMLAttribute eop = new TMLAttribute("eop", "eop", new TMLType(TMLType.NATURAL), "0");
this.addAttribute(eop);
TMLAttribute memSpace = new TMLAttribute("memSpace", "memSpace", new TMLType(TMLType.NATURAL), "4096");
this.addAttribute(memSpace);
// Events and channels
for(TMLEvent evt: outputFeedbackEvents) {
addTMLEvent(evt);
}
addTMLEvent(packetOutFromOUT);
addTMLEvent(packetAvailable);
addReadTMLChannel(outputChannelFromOUT);
// Activity Diagram
TMLStartState start = new TMLStartState("mainStart", referenceObject);
activity.setFirst(start);
//Main Sequence
TMLSequence mainSequence = new TMLSequence("mainSequence", referenceObject);
addElement(start, mainSequence);
// Left branch of left sequence
// For each VC, send a feedback
TMLActivityElement previous = mainSequence;
for(i=0; i<nbOfVCs; i++) {
TMLSendEvent sendEvtFeedback = new TMLSendEvent("sendEvtFeedback_VC" + i, referenceObject);
sendEvtFeedback.setEvent(outputFeedbackEvents.get(i));
addElement(previous, sendEvtFeedback);
previous = sendEvtFeedback;
}
TMLStopState stopOfLeftBranch = new TMLStopState("stopStateOfLeftBranchOfMainSequence", referenceObject);
addElement(previous, stopOfLeftBranch);
// Right branch of main sequence
//
TMLForLoop loop = new TMLForLoop("mainLoop", referenceObject);
loop.setInfinite(true);
addElement(mainSequence, loop);
// Waiting for a packet from OUT
TMLWaitEvent waitingForPacketFromOUT = new TMLWaitEvent("waitingForPacketFromOUT", referenceObject);
waitingForPacketFromOUT.setEvent(packetOutFromOUT);
waitingForPacketFromOUT.addParam("pktlen");
waitingForPacketFromOUT.addParam("dst");
waitingForPacketFromOUT.addParam("vc");
waitingForPacketFromOUT.addParam("eop");
addElement(loop, waitingForPacketFromOUT);
// Reading on channel
TMLReadChannel readFromOUT = new TMLReadChannel("readFromOUT", referenceObject);
readFromOUT.setNbOfSamples("1");
readFromOUT.addChannel(outputChannelFromOUT);
addElement(waitingForPacketFromOUT, readFromOUT);
// subsequence
TMLSequence internalSeq = new TMLSequence("internalSeq", referenceObject);
addElement(readFromOUT, internalSeq);
// Left branch: test on eop
TMLChoice testingEOP = new TMLChoice("testingEOP", referenceObject);
addElement(internalSeq, testingEOP);
// Left branch of choice: eop==1
TMLSendEvent sendEvtPktAvailable = new TMLSendEvent("sendEvtPktAvailable", referenceObject);
sendEvtPktAvailable.setEvent(packetAvailable);
sendEvtPktAvailable.addParam("pktlen");
sendEvtPktAvailable.addParam("dst");
sendEvtPktAvailable.addParam("vc");
sendEvtPktAvailable.addParam("eop");
addElement(testingEOP, sendEvtPktAvailable);
testingEOP.addGuard("eop == 1");
TMLStopState stopOfLeftBranchOfChoice = new TMLStopState("stopOfLeftBranchOfChoice", referenceObject);
addElement(sendEvtPktAvailable, stopOfLeftBranchOfChoice);
// Right branch of choice
TMLStopState stopOfRightBranchOfChoice = new TMLStopState("stopOfRightBranchOfChoice", referenceObject);
addElement(testingEOP, stopOfRightBranchOfChoice);
testingEOP.addGuard("not(eop == 1)");
// Right branch of internal seg
// Test on vc
TMLChoice testingVC = new TMLChoice("testingVC", referenceObject);
addElement(internalSeq, testingVC);
for(i=0; i<nbOfVCs; i++) {
TMLSendEvent sendEvtFeedback = new TMLSendEvent("sendEvtFeedback_VC" + i, referenceObject);
sendEvtFeedback.setEvent(outputFeedbackEvents.get(i));
addElement(testingVC, sendEvtFeedback);
testingEOP.addGuard("vc == " + i);
TMLStopState stopVC = new TMLStopState("stopVC" + i, referenceObject);
addElement(sendEvtFeedback, stopVC);
}
}
}
This diff is collapsed.
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