diff --git a/src/main/java/tmltranslator/TMLSyntaxChecking.java b/src/main/java/tmltranslator/TMLSyntaxChecking.java index 03e8ffca276ed0db5ff8e62151a1c3d3842abba2..23236b9df5f47e58457e5da8828a3ea5c38e2ee4 100755 --- a/src/main/java/tmltranslator/TMLSyntaxChecking.java +++ b/src/main/java/tmltranslator/TMLSyntaxChecking.java @@ -341,12 +341,16 @@ public class TMLSyntaxChecking { } if (elt instanceof TMLSendEvent) { - evt = ((TMLSendEvent) elt).getEvent(); - if (evt.isBasicEvent()) { - //TraceManager.addDev("send evt= " + evt.getName() + " task=" + t.getName() + " origin=" + evt.getOriginTask().getName()); - if (evt.getOriginTask() != t) { - addError(t, elt, evt.getName() + ": " + WRONG_ORIGIN_EVENT, TMLError.ERROR_BEHAVIOR); + //TraceManager.addDev("In Task " + t.getName() + " = " + evt); + if (evt == null) { + addError(t, elt, "Null event in SendEvt of Task " + t.getName(), TMLError.ERROR_BEHAVIOR); + } else { + if (evt.isBasicEvent()) { + //TraceManager.addDev("send evt= " + evt.getName() + " task=" + t.getName() + " origin=" + evt.getOriginTask().getName()); + if (evt.getOriginTask() != t) { + addError(t, elt, evt.getName() + ": " + WRONG_ORIGIN_EVENT, TMLError.ERROR_BEHAVIOR); + } } } } @@ -454,7 +458,9 @@ public class TMLSyntaxChecking { tmlase = (TMLSendEvent) elt; evt = tmlase.getEvent(); - if (tmlase.getNbOfParams() != evt.getNbOfParams()) { + if (evt == null) { + addError(t, elt, "Empty event in Sendevent of task " + t.getTaskName(), TMLError.ERROR_BEHAVIOR); + } else if (tmlase.getNbOfParams() != evt.getNbOfParams()) { addError(t, elt, WRONG_PARAMS + " between event " + evt.getName() + " (nb:" + evt.getNbOfParams() + ") and send event (nb:" + tmlase.getNbOfParams() + ") in task " + t.getTaskName(), TMLError.ERROR_BEHAVIOR); @@ -758,12 +764,13 @@ public class TMLSyntaxChecking { // Then we find the corresponding CPUs for (TMLTask task : tasks) { //We collect all the CPUs - //TraceManager.addDev("Collecting all CPUs of task: " + task.getTaskName()); + TraceManager.addDev("Collecting all CPUs of task: " + task.getTaskName()); for (HwExecutionNode origin : mapping.getAllHwExecutionNodesOfTask(task)) { // And then we check the paths between node and all the nodes of ch for (HwCommunicationNode destination : mapping.getAllCommunicationNodesOfChannel(ch)) { - //TraceManager.addDev("Computing path between " + origin + " and " + destination); + TraceManager.addDev("Computing path between " + origin.getName() + " and " + destination.getName()); if (!mapping.checkPath(origin, destination)) { + TraceManager.addDev("Checking checkPathToMemoryFromCPU: Adding error"); addError(null, null, INVALID_CHANNEL_PATH + ": " + ch.getName(), TMLError.ERROR_STRUCTURE); return; } @@ -774,11 +781,13 @@ public class TMLSyntaxChecking { } private void checkPathToMemoryFromAllHwCommNode(TMLChannel ch) { + TraceManager.addDev("Checking checkPathToMemoryFromAllHwCommNode"); HwMemory mem = mapping.getMemoryOfChannel(ch); if (mem != null) { for (HwCommunicationNode origin : mapping.getAllCommunicationNodesOfChannel(ch)) { if (origin != mem) { if (!mapping.checkPath(origin, mem)) { + TraceManager.addDev("Checking checkPathToMemoryFromAllHwCommNode: Adding error"); addError(null, null, INVALID_CHANNEL_PATH + ": " + ch.getName(), TMLError.ERROR_STRUCTURE); return; } diff --git a/src/main/java/tmltranslator/tonetwork/TMAP2Network.java b/src/main/java/tmltranslator/tonetwork/TMAP2Network.java index 633aa3dd7a3bbd4fdb6932dd2f567b3d29281ac9..51573d8786b9730bfad92f2fbff70d6e68319eb9 100644 --- a/src/main/java/tmltranslator/tonetwork/TMAP2Network.java +++ b/src/main/java/tmltranslator/tonetwork/TMAP2Network.java @@ -78,7 +78,6 @@ public class TMAP2Network<E> { private HashMap<TMLChannel, String> IDsOfChannels; - public TMAP2Network(TMLMapping<?> _tmlmapping, int nocSize) { tmlmapping = _tmlmapping; routers = new TranslatedRouter[nbOfVCs][nbOfVCs]; @@ -455,6 +454,12 @@ public class TMAP2Network<E> { } } + // Removing useless channels i.e. channels routed by the router + // The ones in channelID + // We indeed assume all channels go to the NoC + for(TMLChannel ch: IDsOfChannels.keySet()) { + tmlm.removeChannel(ch); + } // Printing routers diff --git a/src/main/java/tmltranslator/tonetwork/TaskOUTForDispatch.java b/src/main/java/tmltranslator/tonetwork/TaskOUTForDispatch.java index dfbd8602d5b45fc514e9ec24f6e3b7caf40e9897..ca7a0f5889af63bed0233992b1edd2c024b760fd 100644 --- a/src/main/java/tmltranslator/tonetwork/TaskOUTForDispatch.java +++ b/src/main/java/tmltranslator/tonetwork/TaskOUTForDispatch.java @@ -147,7 +147,7 @@ public class TaskOUTForDispatch extends TMLTask { internalChoice.addGuard("feedback > 0"); waitEvt = new TMLWaitEvent("PacketEventInLoop", referenceObject); - TraceManager.addDev("Nb Of params of " + inPacketEvents.get(i).getName() + " = " + inPacketEvents.get(i).getNbOfParams()); + //TraceManager.addDev("Nb Of params of " + inPacketEvents.get(i).getName() + " = " + inPacketEvents.get(i).getNbOfParams()); waitEvt.setEvent(inPacketEvents.get(i)); waitEvt.addParam("pktlen"); waitEvt.addParam("dst"); diff --git a/src/main/java/tmltranslator/tonetwork/TranslatedRouter.java b/src/main/java/tmltranslator/tonetwork/TranslatedRouter.java index 4187a53c567aabfdc4a4643ae3b67bb19846d4a8..7634d62656c1e86699dae73bfcb9363da1169036 100644 --- a/src/main/java/tmltranslator/tonetwork/TranslatedRouter.java +++ b/src/main/java/tmltranslator/tonetwork/TranslatedRouter.java @@ -110,8 +110,6 @@ public class TranslatedRouter<E> { private Vector<TMLChannel> handledChannels; - private Vector<TMLChannel> destChannels; - public TranslatedRouter(TMAP2Network<?> main, TMLMapping<?> tmlmap, HwNoC noc, List<TMLChannel> channelsViaNoc, int nbOfVCs, int xPos, int yPos, HwExecutionNode myHwExecutionNode) { this.main = main; @@ -775,6 +773,7 @@ public class TranslatedRouter<E> { } public void makeOriginChannels() { + Vector<TMLChannel> newChannels = new Vector<>(); // We now need to modify the corresponding input tasks // The channel is modified to NBRNBW @@ -783,132 +782,144 @@ public class TranslatedRouter<E> { // For all channels whose origin task is mapped on the CPU of the router - destChannels = new Vector<>(); for(TMLChannel ch: tmlmap.getTMLModeling().getChannels()) { - TMLTask t = ch.getOriginTask(); - HwExecutionNode mappedOn = tmlmap.getHwNodeOf(t); - if (mappedOn == myHwExecutionNode) { - TraceManager.addDev("Found HwNode of origin task " + t.getTaskName() + " for channel " + ch.getName()); - // We must rework the channel of the task. - // The channel is modified to a NBRNBW with the same task has sender / receiver - // The channel is mapped to the local mem - // Once the sample has been sent, an event is sent to the input task of the router - // For a receiver, the event is first waited for, and then the read in the new channel is performed - - handledChannels.add(ch); - - ch.setType(TMLChannel.NBRNBW); - TMLTask dest = ch.getDestinationTask(); - - TMLChannel channelForDestination = new TMLChannel(ch.getName() + "_dest", ch.getReferenceObject()); - channelForDestination.setType(TMLChannel.NBRNBW); - channelForDestination.setDestinationTask(dest); - channelForDestination.setOriginTask(dest); - destChannels.add(channelForDestination); - main.putTMLChannelID(channelForDestination, main.getChannelID(ch)); - - ch.setDestinationTask(t); - - // Map modify channel to the right memory - HwMemory mem = tmlmap.getTMLArchitecture().getHwMemoryByName(myHwExecutionNode.getName() + "__mem"); - if (mem != null) { - TraceManager.addDev("Mapping channel " + ch.getName() + " on mem " + mem.getName()); - tmlmap.addCommToHwCommNode(ch, mem); - } + if (main.getChannelID(ch) != null) { + TMLTask t = ch.getOriginTask(); + HwExecutionNode mappedOn = tmlmap.getHwNodeOf(t); + if (mappedOn == myHwExecutionNode) { + TraceManager.addDev("Found HwNode of origin task " + t.getTaskName() + " for channel " + ch.getName()); + // We must rework the channel of the task. + // The channel is modified to a NBRNBW with the same task has sender / receiver + // The channel is mapped to the local mem + // Once the sample has been sent, an event is sent to the input task of the router + // For a receiver, the event is first waited for, and then the read in the new channel is performed + + TMLChannel newChannel = new TMLChannel(ch.getName() + "__origin", ch.getReferenceObject()); + newChannel.setType(TMLChannel.NBRNBW); + newChannel.setOriginTask(t); + newChannel.setDestinationTask(t); + newChannel.setSize(ch.getSize()); + newChannel.setVC(ch.getVC()); + newChannels.add(newChannel); + + + // Map modify channel to the right memory + HwMemory mem = tmlmap.getTMLArchitecture().getHwMemoryByName(myHwExecutionNode.getName() + "__mem"); + if (mem != null) { + TraceManager.addDev("Mapping channel " + ch.getName() + " on mem " + mem.getName()); + tmlmap.addCommToHwCommNode(newChannel, mem); + } - // Must now modify the source app - TMLAttribute pktlen = new TMLAttribute("pktlen", "pktlen", new TMLType(TMLType.NATURAL), "0"); - t.addAttributeIfApplicable(pktlen); - TMLAttribute dst = new TMLAttribute("dst", "dst", new TMLType(TMLType.NATURAL), "0"); - t.addAttributeIfApplicable(dst); - TMLAttribute vc = new TMLAttribute("vc", "vc", new TMLType(TMLType.NATURAL), "0"); - t.addAttributeIfApplicable(vc); - TMLAttribute eop = new TMLAttribute("eop", "eop", new TMLType(TMLType.NATURAL), "1"); - t.addAttributeIfApplicable(eop); - TMLAttribute chid = new TMLAttribute("chid", "chid", new TMLType(TMLType.NATURAL), - ""+main.getChannelID(ch)); - t.addAttributeIfApplicable(chid); - - TMLActivity activity = t.getActivityDiagram(); - Vector<TMLActivityElement> newElements = new Vector<>(); - TMLWriteChannel twc; - for(TMLElement elt: activity.getElements()) { - if (elt instanceof TMLWriteChannel) { - twc = (TMLWriteChannel) elt; - if (twc.getChannel(0) == ch) { - TraceManager.addDev("Modifying write ch of task " + t.getTaskName()); - TMLSendEvent tse = new TMLSendEvent("EvtForSending__" + ch.getName(), ch.getReferenceObject()); - newElements.add(tse); - tse.setEvent(mapOfAllOutputChannels.get(ch)); - tse.addParam("" + ch.getSize()); - tse.addParam("dst"); - tse.addParam("vc"); - tse.addParam("eop"); - tse.addParam("chid"); - tse.addNext(twc.getNextElement(0)); - twc.setNewNext(twc.getNextElement(0), tse); + // Must now modify the source app + TMLAttribute pktlen = new TMLAttribute("pktlen", "pktlen", new TMLType(TMLType.NATURAL), "0"); + t.addAttributeIfApplicable(pktlen); + TMLAttribute dst = new TMLAttribute("dst", "dst", new TMLType(TMLType.NATURAL), "0"); + t.addAttributeIfApplicable(dst); + TMLAttribute vc = new TMLAttribute("vc", "vc", new TMLType(TMLType.NATURAL), "0"); + t.addAttributeIfApplicable(vc); + TMLAttribute eop = new TMLAttribute("eop", "eop", new TMLType(TMLType.NATURAL), "1"); + t.addAttributeIfApplicable(eop); + TMLAttribute chid = new TMLAttribute("chid", "chid", new TMLType(TMLType.NATURAL), + "" + main.getChannelID(ch)); + t.addAttributeIfApplicable(chid); + TMLActivity activity = t.getActivityDiagram(); + Vector<TMLActivityElement> newElements = new Vector<>(); + TMLWriteChannel twc; + for (TMLElement elt : activity.getElements()) { + if (elt instanceof TMLWriteChannel) { + twc = (TMLWriteChannel) elt; + if (twc.getChannel(0) == ch) { + TraceManager.addDev("Modifying write ch of task " + t.getTaskName()); + TMLSendEvent tse = new TMLSendEvent("EvtForSending__" + ch.getName(), ch.getReferenceObject()); + twc.replaceChannelWith(ch, newChannel); + newElements.add(tse); + tse.setEvent(mapOfAllOutputChannels.get(ch)); + tse.addParam("" + newChannel.getSize()); + tse.addParam("dst"); + tse.addParam("" + newChannel.getVC()); + tse.addParam("eop"); + tse.addParam(""+main.getChannelID(ch)); + tse.addNext(twc.getNextElement(0)); + twc.setNewNext(twc.getNextElement(0), tse); + } } } - } - for(TMLActivityElement newElt: newElements) { - activity.addElement(newElt); + for (TMLActivityElement newElt : newElements) { + activity.addElement(newElt); + } } } } - // Handling of destination part of channels - for(TMLChannel chd: destChannels) { - tmlmap.getTMLModeling().addChannel(chd); + for(TMLChannel ch: newChannels) { + tmlmap.getTMLModeling().addChannel(ch); } + } public void makeDestinationChannels() { + Vector<TMLChannel> newChannels = new Vector<>(); + mapOfAllInputChannels = new HashMap<>(); + TMLModeling tmlm = tmlmap.getTMLModeling(); Vector<TMLEvent> events = new Vector<>(); Vector<String> ids = new Vector<>(); - for(TMLChannel ch: destChannels) { - TMLTask t = ch.getDestinationTask(); - HwExecutionNode mappedOn = tmlmap.getHwNodeOf(t); - if (mappedOn == myHwExecutionNode) { - TMLEvent packetOut = new TMLEvent("evtPktOutToAppFromOut__" + xPos + "_" + yPos, - null, 8, true); - packetOut.addParam(new TMLType(TMLType.NATURAL)); - packetOut.addParam(new TMLType(TMLType.NATURAL)); - packetOut.addParam(new TMLType(TMLType.NATURAL)); - packetOut.addParam(new TMLType(TMLType.NATURAL)); - packetOut.addParam(new TMLType(TMLType.NATURAL)); - tmlm.addEvent(packetOut); - packetOut.setOriginTask(tniOut); - packetOut.setDestinationTask(ch.getDestinationTask()); - events.add(packetOut); - ids.add(main.getChannelID(ch)); + for(TMLChannel ch: tmlmap.getTMLModeling().getChannels()) { + if (main.getChannelID(ch) != null) { + TMLTask t = ch.getDestinationTask(); + HwExecutionNode mappedOn = tmlmap.getHwNodeOf(t); + if (mappedOn == myHwExecutionNode) { + TMLEvent packetOut = new TMLEvent("evtPktOutToAppFromOut__" + xPos + "_" + yPos, + null, 8, true); + packetOut.addParam(new TMLType(TMLType.NATURAL)); + packetOut.addParam(new TMLType(TMLType.NATURAL)); + packetOut.addParam(new TMLType(TMLType.NATURAL)); + packetOut.addParam(new TMLType(TMLType.NATURAL)); + packetOut.addParam(new TMLType(TMLType.NATURAL)); + tmlm.addEvent(packetOut); + packetOut.setOriginTask(tniOut); + packetOut.setDestinationTask(ch.getDestinationTask()); + events.add(packetOut); + ids.add(main.getChannelID(ch)); + mapOfAllInputChannels.put(ch, packetOut); + } } } tniOut.postProcessing(events, ids); - - for(TMLChannel ch: tmlmap.getTMLModeling().getChannels()) { - if (!handledChannels.contains(ch)) { - + if (main.getChannelID(ch) != null) { TMLTask t = ch.getDestinationTask(); HwExecutionNode mappedOn = tmlmap.getHwNodeOf(t); if (mappedOn == myHwExecutionNode) { - TraceManager.addDev("Found HwNode of destination task " + t.getTaskName() + " for channel " + ch.getName()); + TraceManager.addDev("Found HwNode of origin task " + t.getTaskName() + " for channel " + ch.getName()); + // We must rework the channel of the task. + // The channel is modified to a NBRNBW with the same task has sender / receiver + // The channel is mapped to the local mem + // Once the sample has been sent, an event is sent to the input task of the router + // For a receiver, the event is first waited for, and then the read in the new channel is performed + + TMLChannel newChannel = new TMLChannel(ch.getName() + "__origin", ch.getReferenceObject()); + newChannel.setType(TMLChannel.NBRNBW); + newChannel.setOriginTask(t); + newChannel.setDestinationTask(t); + newChannel.setSize(ch.getSize()); + newChannel.setVC(ch.getVC()); + newChannels.add(newChannel); // Map modify channel to the right memory HwMemory mem = tmlmap.getTMLArchitecture().getHwMemoryByName(myHwExecutionNode.getName() + "__mem"); if (mem != null) { TraceManager.addDev("Mapping channel " + ch.getName() + " on mem " + mem.getName()); - tmlmap.addCommToHwCommNode(ch, mem); + tmlmap.addCommToHwCommNode(newChannel, mem); } - // Must now modify the dest app + // Must now modify the source app TMLAttribute pktlen = new TMLAttribute("pktlen", "pktlen", new TMLType(TMLType.NATURAL), "0"); t.addAttributeIfApplicable(pktlen); TMLAttribute dst = new TMLAttribute("dst", "dst", new TMLType(TMLType.NATURAL), "0"); @@ -917,7 +928,8 @@ public class TranslatedRouter<E> { t.addAttributeIfApplicable(vc); TMLAttribute eop = new TMLAttribute("eop", "eop", new TMLType(TMLType.NATURAL), "1"); t.addAttributeIfApplicable(eop); - TMLAttribute chid = new TMLAttribute("chid", "chid", new TMLType(TMLType.NATURAL), "0"); + TMLAttribute chid = new TMLAttribute("chid", "chid", new TMLType(TMLType.NATURAL), + "" + main.getChannelID(ch)); t.addAttributeIfApplicable(chid); TMLActivity activity = t.getActivityDiagram(); @@ -929,15 +941,15 @@ public class TranslatedRouter<E> { if (trc.getChannel(0) == ch) { TraceManager.addDev("Modifying read ch of task " + t.getTaskName() + " for channel " + ch.getName()); // TODO TODO - //trc.replaceChannelWith(ch, ); + trc.replaceChannelWith(ch, newChannel); TMLWaitEvent twe = new TMLWaitEvent("EvtForReceiving__" + ch.getName(), ch.getReferenceObject()); newElements.add(twe); twe.setEvent(mapOfAllInputChannels.get(ch)); - twe.addParam("" + ch.getSize()); + twe.addParam("pktlen"); twe.addParam("dst"); twe.addParam("vc"); twe.addParam("eop"); - twe.addParam("" + main.getChannelID(ch)); + twe.addParam("chid"); activity.replaceAllNext(trc, twe); twe.addNext(trc); } @@ -950,6 +962,12 @@ public class TranslatedRouter<E> { } } + for(TMLChannel ch: newChannels) { + tmlmap.getTMLModeling().addChannel(ch); + } + + + } diff --git a/src/main/java/ui/window/JDialogNoCManagement.java b/src/main/java/ui/window/JDialogNoCManagement.java index a8431922201e6cdabee6b89d5694c6ca13f89222..e63014d131e9883c863bfc8cb7d00c37b832deee 100644 --- a/src/main/java/ui/window/JDialogNoCManagement.java +++ b/src/main/java/ui/window/JDialogNoCManagement.java @@ -330,17 +330,36 @@ public class JDialogNoCManagement extends JDialog implements ActionListener, Lis } outputText.append("\nNoC removed\n"); - outputText.append("\nGenerating TML\n"); + outputText.append("\nChecking syntax of the specification\n"); TMLMapping<?> mapping = t2n.getTMLMapping(); mgui.gtm.setTMLMapping(mapping); + TMLSyntaxChecking tmlsc = new TMLSyntaxChecking(mapping); + mapping.forceMakeAutomata(); + tmlsc.checkSyntax(); + + outputText.append("\n" + tmlsc.hasErrors() + " errors, " + tmlsc.hasWarnings() + " warnings:\n"); + if (tmlsc.hasErrors() > 0) { + for (TMLError err :tmlsc.getErrors()) { + outputText.append("Error:" + err.toString() + "\n"); + } + } + if (tmlsc.hasWarnings() > 0) { + for (TMLError err :tmlsc.getWarnings()) { + outputText.append("Warning:" + err.toString() + "\n"); + } + } + + + outputText.append("\nGenerating TML\n"); + + TMLMappingTextSpecification ts = new TMLMappingTextSpecification<>("noNoc"); ts.toTextFormat(mapping); - String dir = SpecConfigTTool.TMLCodeDirectory; try { ts.saveFile(SpecConfigTTool.TMLCodeDirectory, "NoNoC"); @@ -352,22 +371,9 @@ public class JDialogNoCManagement extends JDialog implements ActionListener, Lis outputText.append("\nSpecification generated in " + dir + "\n"); - outputText.append("\nChecking syntax of the specification\n"); - TMLSyntaxChecking tmlsc = new TMLSyntaxChecking(mapping); - tmlsc.checkSyntax(); - outputText.append("\n" + tmlsc.hasErrors() + " errrors, " + tmlsc.hasWarnings() + " warnings:\n"); - if (tmlsc.hasErrors() > 0) { - for (TMLError err :tmlsc.getErrors()) { - outputText.append("Error:" + err.toString() + "\n"); - } - } - if (tmlsc.hasWarnings() > 0) { - for (TMLError err :tmlsc.getWarnings()) { - outputText.append("Warning:" + err.toString() + "\n"); - } - } + outputText.append("\nAll done\n");