diff --git a/src/main/java/tmltranslator/TMLArchiTextSpecification.java b/src/main/java/tmltranslator/TMLArchiTextSpecification.java index 120926e0af0df4478239cf4e69c53be04850e9a3..ba656f5fded0f582db4f5bfe42cad2548bea1ae0 100755 --- a/src/main/java/tmltranslator/TMLArchiTextSpecification.java +++ b/src/main/java/tmltranslator/TMLArchiTextSpecification.java @@ -70,8 +70,8 @@ public class TMLArchiTextSpecification { private ArrayList<TMLTXTError> errors; private ArrayList<TMLTXTError> warnings; - private String keywords[] = {"NODE", "CPU", "FPGA", "SET", "BUS", "LINK", "BRIDGE", "ROUTER", "MEMORY", "MASTERCLOCKFREQUENCY", "DMA"}; - private String nodetypes[] = {"CPU", "FPGA", "BUS", "LINK", "BRIDGE", "ROUTER", "MEMORY", "HWA", "DMA"}; + private String keywords[] = {"NODE", "CPU", "FPGA", "SET", "BUS", "LINK", "BRIDGE", "NOC", "MEMORY", "MASTERCLOCKFREQUENCY", "DMA"}; + private String nodetypes[] = {"CPU", "FPGA", "BUS", "LINK", "BRIDGE", "NOC", "MEMORY", "HWA", "DMA"}; private String cpuparameters[] = {"nbOfCores", "byteDataSize", "pipelineSize", "goIdleTime", "maxConsecutiveIdleCycles", "taskSwitchingTime", "branchingPredictionPenalty", "cacheMiss", "schedulingPolicy", "sliceTime", "execiTime", "execcTime", "operation", "clockDivider"}; private String fpgaparameters[] = {"capacity", "byteDataSize", "mappingPenalty", "goIdleTime", @@ -81,6 +81,7 @@ public class TMLArchiTextSpecification { private String busparameters[] = {"byteDataSize", "pipelineSize", "arbitration", "clockDivider"}; private String bridgeparameters[] = {"bufferByteSize", "clockDivider"}; private String memoryparameters[] = {"byteDataSize", "clockDivider"}; + private String nocparameters[] = {"bufferbytesize", "nocSize", "clockdivider"}; // private String dmaparameters[] = {"byteDataSize", "nbOfChannels"}; @@ -148,7 +149,7 @@ public class TMLArchiTextSpecification { HwA hwa; HwBus bus; HwBridge bridge; - HwNoC router; + HwNoC noc; HwMemory memory; HwDMA dma; @@ -235,14 +236,14 @@ public class TMLArchiTextSpecification { code += set + "bufferByteSize " + bridge.bufferByteSize + CR; } - // Router + // NoC if (node instanceof HwNoC) { - router = (HwNoC) node; + noc = (HwNoC) node; name = prepareString(node.getName()); set = "SET " + name + " "; - code += "NODE ROUTER " + name + CR; - code += set + "bufferByteSize " + router.bufferByteSize + CR; - code += set + "NoCSize " + router.size + CR; + code += "NODE NOC " + name + CR; + code += set + "bufferByteSize " + noc.bufferByteSize + CR; + code += set + "NoCSize " + noc.size + CR; } // Memory @@ -476,9 +477,9 @@ public class TMLArchiTextSpecification { } else if (_split[1].equals("BRIDGE")) { HwBridge bridge = new HwBridge(_split[2]); tmla.addHwNode(bridge); - } else if (_split[1].equals("ROUTER")) { - HwNoC router = new HwNoC(_split[2]); - tmla.addHwNode(router); + } else if (_split[1].equals("NOC")) { + HwNoC noc = new HwNoC(_split[2]); + tmla.addHwNode(noc); } else if (_split[1].equals("HWA")) { HwA hwa = new HwA(_split[2]); tmla.addHwNode(hwa); @@ -796,9 +797,9 @@ public class TMLArchiTextSpecification { } if (node instanceof HwNoC) { - HwNoC router = (HwNoC) node; + HwNoC noc = (HwNoC) node; - if (!checkParameter("SET", _split, 2, 11, _lineNb)) { + if (!checkParameter("SET", _split, 2, 14, _lineNb)) { return -1; } @@ -807,15 +808,15 @@ public class TMLArchiTextSpecification { } if (_split[2].toUpperCase().equals("BUFFERBYTESIZE")) { - router.bufferByteSize = Integer.decode(_split[3]).intValue(); + noc.bufferByteSize = Integer.decode(_split[3]).intValue(); } if (_split[2].toUpperCase().equals("NOCSIZE")) { - router.size = Integer.decode(_split[3]).intValue(); + noc.size = Integer.decode(_split[3]).intValue(); } if (_split[2].toUpperCase().equals("CLOCKDIVIDER")) { - router.clockRatio = Integer.decode(_split[3]).intValue(); + noc.clockRatio = Integer.decode(_split[3]).intValue(); } } @@ -982,6 +983,11 @@ public class TMLArchiTextSpecification { err = true; } break; + case 14: + if (!isIncluded(_split[_parameter], nocparameters)) { + err = true; + } + break; } } else { diff --git a/src/main/java/ui/window/JDialogNoCManagement.java b/src/main/java/ui/window/JDialogNoCManagement.java index cd236a2ba45c002fa993170e1c574648e2bbd358..ca313a02abaee21608720f77f67ffcce4251147d 100644 --- a/src/main/java/ui/window/JDialogNoCManagement.java +++ b/src/main/java/ui/window/JDialogNoCManagement.java @@ -327,6 +327,7 @@ public class JDialogNoCManagement extends JDialog implements ActionListener, Lis outputText.append("\nPreparing model\n"); + int size = map.getTMLArchitecture().getSizeOfNoC(); if (size < 0) { @@ -415,6 +416,8 @@ public class JDialogNoCManagement extends JDialog implements ActionListener, Lis + + protected void checkMode() { mode = NOT_SELECTED; } diff --git a/ttool/src/test/java/tmltranslator/DiplodocusNoCTest.java b/ttool/src/test/java/tmltranslator/DiplodocusNoCTest.java new file mode 100644 index 0000000000000000000000000000000000000000..63131d97b710d1d77309b2179bc18a01dc3876db --- /dev/null +++ b/ttool/src/test/java/tmltranslator/DiplodocusNoCTest.java @@ -0,0 +1,197 @@ +package tmltranslator; + +import graph.AUTGraph; +import myutil.FileUtils; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import req.ebrdd.EBRDD; +import tepe.TEPE; +import tmltranslator.TMLSyntaxChecking; +import tmltranslator.TMLTextSpecification; +import tmltranslator.tomappingsystemc2.DiploSimulatorFactory; +import tmltranslator.tomappingsystemc2.IDiploSimulatorCodeGenerator; +import tmltranslator.tomappingsystemc2.Penalties; +import tmltranslator.tonetwork.TMAP2Network; +import ui.*; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; + +public class DiplodocusNoCTest extends AbstractUITest { + + + final String MODEL = "spec"; + final int NB_OF_NOCS = 1; + final int NB_Of_SIM_CYCLES = 300; + final String[] SIM_ACTION = {}; + + + private String SIM_DIR; + + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + RESOURCES_DIR = getBaseResourcesDir() + "/tmltranslator/noc/"; + + } + + public DiplodocusNoCTest() { + super(); + //mainGUI.openProjectFromFile(new File(RESOURCES_DIR)); + } + + @Before + public void setUp() throws Exception { + SIM_DIR = getBaseResourcesDir() + "../../../../simulators/c++2/"; + } + + + @Test + public void testSimulationGraph() throws Exception { + + String s = MODEL; + // Load the TML + System.out.println("executing: loading " + s); + TMLMappingTextSpecification tmts = new TMLMappingTextSpecification(s); + File f = new File(RESOURCES_DIR + s + ".tmap"); + System.out.println("executing: new file loaded " + s); + String spec = null; + try { + spec = FileUtils.loadFileData(f); + } catch (Exception e) { + System.out.println("Exception executing: loading " + s); + assertTrue(false); + } + System.out.println("executing: testing spec " + s); + assertTrue(spec != null); + + System.out.println("executing: testing parsed " + s); + boolean parsed = tmts.makeTMLMapping(spec, RESOURCES_DIR); + assertTrue(parsed); + + + System.out.println("executing: checking syntax " + s); + // Checking syntax + TMLMapping tmap = tmts.getTMLMapping(); + + TMLSyntaxChecking syntax = new TMLSyntaxChecking(tmap); + syntax.checkSyntax(); + + assertEquals(syntax.hasErrors(), 0); + + // Check if models contain the expected nb of NoCs + int size = tmap.getTMLArchitecture().getSizeOfNoC(); + + assertEquals(size, NB_OF_NOCS); + + // Remove Noc + TMAP2Network t2n = new TMAP2Network<>(tmap, size); + String error = t2n.removeAllRouterNodes(); + + assertNotNull(error); + + // Check syntax of the new mapping + syntax = new TMLSyntaxChecking(tmap); + syntax.checkSyntax(); + assertEquals(syntax.hasErrors(), 0); + + + // Generate SystemC code + System.out.println("executing: sim code gen for " + s); + final IDiploSimulatorCodeGenerator tml2systc; + List<EBRDD> al = new ArrayList<EBRDD>(); + List<TEPE> alTepe = new ArrayList<TEPE>(); + tml2systc = DiploSimulatorFactory.INSTANCE.createCodeGenerator(tmap, al, alTepe); + tml2systc.setModelName(s); + error = tml2systc.generateSystemC(false, true); + assertNull(error); + + tml2systc.saveFile(SIM_DIR, "appmodel"); + + // Compile it + System.out.println("executing: compile"); + Process proc; + BufferedReader proc_in; + String str; + boolean mustRecompileAll; + Penalties penalty = new Penalties(SIM_DIR + File.separator + "src_simulator"); + int changed = penalty.handlePenalties(false); + + if (changed == 1) { + mustRecompileAll = true; + } else { + mustRecompileAll = false; + } + + if (mustRecompileAll) { + System.out.println("executing: " + "make -C " + SIM_DIR + " clean"); + try { + proc = Runtime.getRuntime().exec("make -C " + SIM_DIR + " clean"); + proc_in = new BufferedReader(new InputStreamReader(proc.getInputStream())); + while ((str = proc_in.readLine()) != null) { + // TraceManager.addDev( "Sending " + str + " from " + port + " to client..." ); + System.out.println("executing: " + str); + } + } catch (Exception e) { + // probably make is not installed + System.out.println("FAILED: executing: " + "make -C " + SIM_DIR + " clean"); + return; + } + } + + System.out.println("executing: " + "make -C " + SIM_DIR); + try { + + proc = Runtime.getRuntime().exec("make -C " + SIM_DIR + ""); + proc_in = new BufferedReader(new InputStreamReader(proc.getInputStream())); + + while ((str = proc_in.readLine()) != null) { + // TraceManager.addDev( "Sending " + str + " from " + port + " to client..." ); + System.out.println("executing: " + str); + } + } catch (Exception e) { + // Probably make is not installed + System.out.println("FAILED: executing: " + "make -C " + SIM_DIR); + return; + } + System.out.println("SUCCESS: executing: " + "make -C " + SIM_DIR); + + // Run the simulator + try { + proc = Runtime.getRuntime().exec("./" + SIM_DIR + "run.x -cmd '1 6 " + NB_Of_SIM_CYCLES + "; 7 2 " + s + ".txt'"); + proc_in = new BufferedReader(new InputStreamReader(proc.getInputStream())); + + while ((str = proc_in.readLine()) != null) { + // TraceManager.addDev( "Sending " + str + " from " + port + " to client..." ); + System.out.println("executing: " + str); + } + } catch (Exception e) { + // Probably make is not installed + System.out.println("FAILED: executing simulation"); + return; + } + + // Compare results with expected ones + // Must load the file data + File simFile = new File(s + ".txt"); + String simData = ""; + try { + simData = FileUtils.loadFileData(simFile); + } catch (Exception e) { + assertTrue(false); + } + + for(String act: SIM_ACTION) { + assertTrue(simData.indexOf(act) > -1); + } + + } + + +} \ No newline at end of file diff --git a/ttool/src/test/resources/tmltranslator/noc/spec.tarchi b/ttool/src/test/resources/tmltranslator/noc/spec.tarchi new file mode 100644 index 0000000000000000000000000000000000000000..bd2e6324c6fef5a13ce19e6e8f3d54afc63a01f7 --- /dev/null +++ b/ttool/src/test/resources/tmltranslator/noc/spec.tarchi @@ -0,0 +1,153 @@ +// Master clock frequency - in MHz +MASTERCLOCKFREQUENCY 200 + +NODE BUS Bus00 +SET Bus00 byteDataSize 4 +SET Bus00 pipelineSize 1 +SET Bus00 arbitration 0 +SET Bus00 clockDivider 1 + +NODE CPU CPU00 +SET CPU00 nbOfCores 1 +SET CPU00 byteDataSize 4 +SET CPU00 pipelineSize 5 +SET CPU00 goIdleTime 10 +SET CPU00 maxConsecutiveIdleCycles 10 +SET CPU00 taskSwitchingTime 20 +SET CPU00 branchingPredictionPenalty 2 +SET CPU00 cacheMiss 5 +SET CPU00 schedulingPolicy 0 +SET CPU00 sliceTime 10000 +SET CPU00 execiTime 1 +SET CPU00 execcTime 1 +SET CPU00 clockDivider 1 + +NODE CPU CPU12 +SET CPU12 nbOfCores 1 +SET CPU12 byteDataSize 4 +SET CPU12 pipelineSize 5 +SET CPU12 goIdleTime 10 +SET CPU12 maxConsecutiveIdleCycles 10 +SET CPU12 taskSwitchingTime 20 +SET CPU12 branchingPredictionPenalty 2 +SET CPU12 cacheMiss 5 +SET CPU12 schedulingPolicy 0 +SET CPU12 sliceTime 10000 +SET CPU12 execiTime 1 +SET CPU12 execcTime 1 +SET CPU12 clockDivider 1 + +NODE NOC NoC0 +SET NoC0 bufferByteSize 2 +SET NoC0 NoCSize 3 +SET NoC0 clockDivider 1 + +NODE BUS Bus12 +SET Bus12 byteDataSize 4 +SET Bus12 pipelineSize 1 +SET Bus12 arbitration 0 +SET Bus12 clockDivider 1 + +NODE CPU CPU20 +SET CPU20 nbOfCores 1 +SET CPU20 byteDataSize 4 +SET CPU20 pipelineSize 5 +SET CPU20 goIdleTime 10 +SET CPU20 maxConsecutiveIdleCycles 10 +SET CPU20 taskSwitchingTime 20 +SET CPU20 branchingPredictionPenalty 2 +SET CPU20 cacheMiss 5 +SET CPU20 schedulingPolicy 0 +SET CPU20 sliceTime 10000 +SET CPU20 execiTime 1 +SET CPU20 execcTime 1 +SET CPU20 clockDivider 1 + +NODE BUS Bus20 +SET Bus20 byteDataSize 4 +SET Bus20 pipelineSize 1 +SET Bus20 arbitration 0 +SET Bus20 clockDivider 1 + +NODE CPU CPU11 +SET CPU11 nbOfCores 1 +SET CPU11 byteDataSize 4 +SET CPU11 pipelineSize 5 +SET CPU11 goIdleTime 10 +SET CPU11 maxConsecutiveIdleCycles 10 +SET CPU11 taskSwitchingTime 20 +SET CPU11 branchingPredictionPenalty 2 +SET CPU11 cacheMiss 5 +SET CPU11 schedulingPolicy 0 +SET CPU11 sliceTime 10000 +SET CPU11 execiTime 1 +SET CPU11 execcTime 1 +SET CPU11 clockDivider 1 + +NODE BUS Bus11 +SET Bus11 byteDataSize 4 +SET Bus11 pipelineSize 1 +SET Bus11 arbitration 0 +SET Bus11 clockDivider 1 + +NODE CPU CPU22 +SET CPU22 nbOfCores 1 +SET CPU22 byteDataSize 4 +SET CPU22 pipelineSize 5 +SET CPU22 goIdleTime 10 +SET CPU22 maxConsecutiveIdleCycles 10 +SET CPU22 taskSwitchingTime 20 +SET CPU22 branchingPredictionPenalty 2 +SET CPU22 cacheMiss 5 +SET CPU22 schedulingPolicy 0 +SET CPU22 sliceTime 10000 +SET CPU22 execiTime 1 +SET CPU22 execcTime 1 +SET CPU22 clockDivider 1 + +NODE BUS Bus22 +SET Bus22 byteDataSize 4 +SET Bus22 pipelineSize 1 +SET Bus22 arbitration 0 +SET Bus22 clockDivider 1 + +NODE LINK link_CPU22_to_Bus22 +SET link_CPU22_to_Bus22 node CPU22 +SET link_CPU22_to_Bus22 bus Bus22 +SET link_CPU22_to_Bus22 priority 0 +NODE LINK link_NoC0_to_Bus22 +SET link_NoC0_to_Bus22 node NoC0 +SET link_NoC0_to_Bus22 bus Bus22 +SET link_NoC0_to_Bus22 priority 0 +NODE LINK link_NoC0_to_Bus11 +SET link_NoC0_to_Bus11 node NoC0 +SET link_NoC0_to_Bus11 bus Bus11 +SET link_NoC0_to_Bus11 priority 0 +NODE LINK link_NoC0_to_Bus20 +SET link_NoC0_to_Bus20 node NoC0 +SET link_NoC0_to_Bus20 bus Bus20 +SET link_NoC0_to_Bus20 priority 0 +NODE LINK link_CPU12_to_Bus12 +SET link_CPU12_to_Bus12 node CPU12 +SET link_CPU12_to_Bus12 bus Bus12 +SET link_CPU12_to_Bus12 priority 0 +NODE LINK link_NoC0_to_Bus12 +SET link_NoC0_to_Bus12 node NoC0 +SET link_NoC0_to_Bus12 bus Bus12 +SET link_NoC0_to_Bus12 priority 0 +NODE LINK link_NoC0_to_Bus00 +SET link_NoC0_to_Bus00 node NoC0 +SET link_NoC0_to_Bus00 bus Bus00 +SET link_NoC0_to_Bus00 priority 0 +NODE LINK link_CPU00_to_Bus00 +SET link_CPU00_to_Bus00 node CPU00 +SET link_CPU00_to_Bus00 bus Bus00 +SET link_CPU00_to_Bus00 priority 0 +NODE LINK link_CPU20_to_Bus20 +SET link_CPU20_to_Bus20 node CPU20 +SET link_CPU20_to_Bus20 bus Bus20 +SET link_CPU20_to_Bus20 priority 0 +NODE LINK link_CPU11_to_Bus11 +SET link_CPU11_to_Bus11 node CPU11 +SET link_CPU11_to_Bus11 bus Bus11 +SET link_CPU11_to_Bus11 priority 0 diff --git a/ttool/src/test/resources/tmltranslator/noc/spec.tmap b/ttool/src/test/resources/tmltranslator/noc/spec.tmap new file mode 100644 index 0000000000000000000000000000000000000000..65b61c70cd13483de1ffc0bdc247c46b486f72b8 --- /dev/null +++ b/ttool/src/test/resources/tmltranslator/noc/spec.tmap @@ -0,0 +1,20 @@ +TMLSPEC + #include "spec.tml" +ENDTMLSPEC + +TMLARCHI + #include "spec.tarchi" +ENDTMLARCHI + +TMLMAPPING + MAP CPU00 noc_3x3_periodic_flows__FunctionPeriodicSend0 + SET noc_3x3_periodic_flows__FunctionPeriodicSend0 priority 0 + MAP CPU12 noc_3x3_periodic_flows__FunctionPeriodicReceive0 + SET noc_3x3_periodic_flows__FunctionPeriodicReceive0 priority 0 + MAP CPU20 noc_3x3_periodic_flows__FunctionPeriodicSend1 + SET noc_3x3_periodic_flows__FunctionPeriodicSend1 priority 0 + MAP CPU11 noc_3x3_periodic_flows__FunctionPeriodicReceive1 + SET noc_3x3_periodic_flows__FunctionPeriodicReceive1 priority 0 + MAP CPU22 noc_3x3_periodic_flows__FunctionPeriodicReceive2 + SET noc_3x3_periodic_flows__FunctionPeriodicReceive2 priority 0 +ENDTMLMAPPING diff --git a/ttool/src/test/resources/tmltranslator/noc/spec.tml b/ttool/src/test/resources/tmltranslator/noc/spec.tml new file mode 100644 index 0000000000000000000000000000000000000000..ec79edc1460a7182f83184b03a5cc7d2aa57848a --- /dev/null +++ b/ttool/src/test/resources/tmltranslator/noc/spec.tml @@ -0,0 +1,76 @@ +// TML Application - FORMAT 0.1 +// Application: /Users/ludovicapvrille/TTool/modeling/ISAE/noc_test_vcs_periodic.xml +// Generated: Tue Jul 23 21:17:52 CEST 2019 + +// Channels +CHANNEL noc_3x3_periodic_flows__tx_00__noc_3x3_periodic_flows__rx_0 BRBW 4 8 OUT noc_3x3_periodic_flows__FunctionPeriodicSend0 IN noc_3x3_periodic_flows__FunctionPeriodicReceive0 +VCCHANNEL noc_3x3_periodic_flows__tx_00__noc_3x3_periodic_flows__rx_0 0 +CHANNEL noc_3x3_periodic_flows__tx_01__noc_3x3_periodic_flows__rx2 BRBW 4 8 OUT noc_3x3_periodic_flows__FunctionPeriodicSend0 IN noc_3x3_periodic_flows__FunctionPeriodicReceive2 +VCCHANNEL noc_3x3_periodic_flows__tx_01__noc_3x3_periodic_flows__rx2 1 +CHANNEL noc_3x3_periodic_flows__tx_1__noc_3x3_periodic_flows__rx_1 BRBW 4 8 OUT noc_3x3_periodic_flows__FunctionPeriodicSend1 IN noc_3x3_periodic_flows__FunctionPeriodicReceive1 +VCCHANNEL noc_3x3_periodic_flows__tx_1__noc_3x3_periodic_flows__rx_1 0 + +// Events + +// Requests + +TASK noc_3x3_periodic_flows__FunctionPeriodicReceive0 + TASKOP + //Local variables + int payload = 3 + + //Behavior + FOR( ; ; ) + READ noc_3x3_periodic_flows__tx_00__noc_3x3_periodic_flows__rx_0 payload + ENDFOR +ENDTASK + +TASK noc_3x3_periodic_flows__FunctionPeriodicReceive1 + TASKOP + //Local variables + int payload = 3 + + //Behavior + FOR( ; ; ) + READ noc_3x3_periodic_flows__tx_1__noc_3x3_periodic_flows__rx_1 payload + ENDFOR +ENDTASK + +TASK noc_3x3_periodic_flows__FunctionPeriodicReceive2 + TASKOP + //Local variables + int payload = 3 + + //Behavior + FOR( ; ; ) + READ noc_3x3_periodic_flows__tx_01__noc_3x3_periodic_flows__rx2 payload + ENDFOR +ENDTASK + +TASK noc_3x3_periodic_flows__FunctionPeriodicSend0 + TASKOP + //Local variables + int period = 500 + int payload = 3 + + //Behavior + FOR( ; ; ) + WRITE noc_3x3_periodic_flows__tx_00__noc_3x3_periodic_flows__rx_0 payload + WRITE noc_3x3_periodic_flows__tx_01__noc_3x3_periodic_flows__rx2 payload + DELAY period ns + ENDFOR +ENDTASK + +TASK noc_3x3_periodic_flows__FunctionPeriodicSend1 + TASKOP + //Local variables + int period = 500 + int payload = 3 + + //Behavior + FOR( ; ; ) + WRITE noc_3x3_periodic_flows__tx_1__noc_3x3_periodic_flows__rx_1 payload + DELAY period ns + ENDFOR +ENDTASK +