diff --git a/MPSoC/Makefile.forsoclib b/MPSoC/Makefile.forsoclib
index 3f2a0a832d057372f77e5ae838b7fdaa50d03622..e8efda1010873b9572f53212b426fecafeab8d39 100755
--- a/MPSoC/Makefile.forsoclib
+++ b/MPSoC/Makefile.forsoclib
@@ -16,6 +16,9 @@ export PATH
 updateruntime:
 	cp mutekh/libmwmr/*.c mutekh/examples/avatar
 	cp mutekh/libmwmr/include/mwmr/mwmr.h mutekh/examples/avatar
+	cp src/*.c ~/Prog/mutekh/libavatar/
+	cp src/*.h ~/Prog/mutekh/libavatar/include/  
+
 	
 updategeneratedcode:
 	cp src/defs.h mutekh/examples/avatar
diff --git a/MPSoC/src/asyncchannel.c b/MPSoC/src/asyncchannel.c
index 802eb9f9ebab96324427ba69f40b07ddcda9542a..ed6edd635864470f6253d9f2f5ed39e0c512b748 100755
--- a/MPSoC/src/asyncchannel.c
+++ b/MPSoC/src/asyncchannel.c
@@ -22,7 +22,7 @@ int async_write_nonblocking( struct mwmr_s *fifo, void *_ptr, int lensw ){
   i = mwmr_try_write(fifo,_ptr,lensw);
   if (i<lensw){
     /* the data item is thrown away */
-    //debugInt("data thrown away");
+    debugInt("data discarded");
     return i;
   }
   else{
@@ -94,8 +94,9 @@ void destroyAsyncchannel(asyncchannel *asyncch) {
     debugInt("asyncchannel read: address \n",channel->mwmr_fifo);
     debugInt("asyncchannel \n",channel->mwmr_fifo->depth);
     debugInt("asyncchannel \n",channel->mwmr_fifo->width);
+    debugInt("asyncchannel msg size \n",sizeof(msg));
     // async_read(channel->mwmr_fifo, &msg, 1);
-    async_read(channel->mwmr_fifo, &msg, sizeof(msg));//DG 7.2.
+    async_read(channel->mwmr_fifo, &msg, sizeof(*msg));
     return msg;
   }
 
@@ -112,7 +113,8 @@ void destroyAsyncchannel(asyncchannel *asyncch) {
   debugInt("asyncchannel address \n",channel->mwmr_fifo);
   debugInt("asyncchannel \n",channel->mwmr_fifo->depth);
   debugInt("asyncchannel \n",channel->mwmr_fifo->width);
-  async_read(channel->mwmr_fifo, &msg, sizeof(msg));//DG 7.2.
+  debugInt("asyncchannel msg size \n",sizeof(*msg));
+  async_read(channel->mwmr_fifo, &msg, sizeof(*msg));//DG 13.6. *msg au lieu de msg
   
   return msg;
 }
@@ -132,5 +134,6 @@ void addMessageToAsyncChannel(asyncchannel *channel, message *msg) {
   debugInt("asyncchannel->fifo rptr \n", channel->mwmr_fifo->status->rptr);
   debugInt("asyncchannel->fifo wptr \n", channel->mwmr_fifo->status->wptr);
   //async_write(channel->mwmr_fifo, &msg, 1 );
-  async_write(channel->mwmr_fifo, &msg, sizeof(msg));//DG 7.2.
+  debugInt("asyncchannel msg size \n",sizeof(*msg));
+  async_write(channel->mwmr_fifo, &msg, sizeof(*msg));//DG 13.6. *msg au lieu de msg
 }
diff --git a/MPSoC/src/syncchannel.c b/MPSoC/src/syncchannel.c
index abc70b0ad0b7355e071aacd1b3708ad1cba75c84..e231dde8ec843ec596daa4139d40518e7028b16a 100755
--- a/MPSoC/src/syncchannel.c
+++ b/MPSoC/src/syncchannel.c
@@ -26,7 +26,7 @@ int sync_read( struct mwmr_s *fifo, void *_ptr, int lensw ){
   debugInt("read debug  fifo wptr address\n", &(fifo->status->rptr));
   debugInt("read debug  fifo lock \n", fifo->status->lock);
   i=mwmr_try_read(fifo,_ptr,lensw);
-  debugInt("debug i \n", i);
+  //debugInt("debug i \n", i);
   //mwmr_read(fifo,_ptr,lensw);
   return i;
   //return lensw;
@@ -45,7 +45,7 @@ int sync_write( struct mwmr_s *fifo, void *_ptr, int lensw ){
   debugInt("debug  fifo lock \n", fifo->status->lock);
   i=mwmr_try_write(fifo,_ptr,lensw);
   //mwmr_write(fifo,_ptr,lensw);
-  debugInt("debug i \n", i);
+  //debugInt("debug i \n", i);
   return i;
   //return lensw;
 }
diff --git a/src/main/java/avatartranslator/AvatarSignal.java b/src/main/java/avatartranslator/AvatarSignal.java
index 8effe45f0c0da4c5cee51691afc1c919a8e34ba2..c3315849466e5c7e5f086bc83912fcaab8a2315d 100644
--- a/src/main/java/avatartranslator/AvatarSignal.java
+++ b/src/main/java/avatartranslator/AvatarSignal.java
@@ -122,7 +122,17 @@ public class AvatarSignal extends AvatarMethod {
         return cpt;
 	}
 
-
+    //DG 13.06.
+    /* public int getCumulSizeParams(){
+        int cumul = 0;
+	
+        for(AvatarAttribute attribute: parameters) { 
+	    AvatarType type = attribute.getType();
+	    cumul += 4;  //hack          
+        }
+        return cumul;
+	}*/
+    //fin DG 
     public AvatarSignal advancedClone(AvatarStateMachineOwner _block) {
 	AvatarSignal as = new AvatarSignal(getName(), getInOut(), getReferenceObject());
 	setAdvancedClone((AvatarMethod)as, _block);
diff --git a/src/main/java/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java b/src/main/java/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java
index 81e1976c9ee7ba0aa1d62b2fbe7dd31ebd17c311..a5d42aaf513b5f9dc6c57c8cd9dd17debf58db1a 100755
--- a/src/main/java/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java
+++ b/src/main/java/ddtranslatorSoclib/toSoclib/TasksAndMainGenerator.java
@@ -201,7 +201,7 @@ public class TasksAndMainGenerator {
     	mainFile.appendToMainCode("pthread_attr_t *attr_t = malloc(sizeof(pthread_attr_t));" +CR);
     	mainFile.appendToMainCode("pthread_attr_init(attr_t);" + CR );
     	mainFile.appendToMainCode("pthread_mutex_init(&__mainMutex, NULL);" +CR2);       
-	 	    
+	mainFile.appendToMainCode("int sizeParams;" +CR2);   //DG 13.06.
     }
   
     public void makeSynchronousChannels() {
@@ -212,10 +212,9 @@ public class TasksAndMainGenerator {
         mainFile.appendToMainCode("/* Synchronous channels */" + CR);
  k=0;
         for(AvatarRelation ar: avspec.getRelations()) {
-	    // k=0; DG 6.6.
+	  
 	if (!ar.isAsynchronous()) {
-	    //k=0;
-	    //k= ar.nbOfSignals()-1;    //DG 2.6. 
+	   
 	   		    
 	    for(i=0; i<ar.nbOfSignals() ; i++) {
 		ar.setId(i);
@@ -231,14 +230,44 @@ public class TasksAndMainGenerator {
 	
 
 	AvatarSignal sig = ar.getSignal1(i);
-        int nbParams= sig.getNbParams();	
+        int nbParams= sig.getNbParams();
+	// int nbOfMaxParams = _block.getMaxNbOfParams();
+	//DG 13.06. variant dans le code C
+
+	//ainsi on declare les attributs au debut d'une tache:
+
+	//s += makeAttributesDeclaration(_block, _taskFile);
+	//fonction dans tasksAndMainGenerator
+
+	/*mainFile.appendToMainCode("sizeParams = sizeof(" );
+	int cpt = 0;
 	
+	for(AvatarAttribute attribute: parameters) {
+	    String param_type = getCTypeOf(attribute);//Attention sizeof(bool)=sizeof(int)
+	    mainFile.appendToMainCode(attribute.getName() + "sizeof("+ret);
+	}
+	mainFile.appendToMainCode(");"+ CR);*/
+	int sizeParams = 0;
+	// DG 13.06. variant calcule mais risque que cela ne cqpte pqs les data types
+	//for(AvatarAttribute attribute: parameters) {
+	//    sizeParams+=4;//soit int soit bool?
+	//}
+
+	//ici variant calcule
 	if (nbParams>0)
 	    mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ (nbParams*4)+";" + CR);
-	else mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ 4 +";" + CR);
-
-         mainFile.appendToMainCode(getChannelName(ar, i) + ".depth = 100;" + CR);
-	//mainFile.appendToMainCode(getChannelName(ar, i) + ".depth = "+((nbParams*4)+4)+";" + CR);
+	    //mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ sizeParams +";" + CR);
+	//mainFile.appendToMainCode(getChannelName(ar, i) + ".width = sizeParams;" + CR);
+
+	//int sizeParams= sig.getCumulSizeParams();
+	//DG 13.06. Attention paramaters have not all size 4!!
+	//if (nbParams>0)
+	    //mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ (nbParams*4) +";" + CR);
+	    //mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ sizeParams +";" + CR);
+	//else mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ 4 +";" + CR);
+	else mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ 4 +";" + CR);//DG 13.06.
+	mainFile.appendToMainCode(getChannelName(ar, i) + ".depth = 100;" + CR);
+	
 	mainFile.appendToMainCode(getChannelName(ar, i) + ".gdepth = " +getChannelName(ar, i)+".depth;" + CR);
 	mainFile.appendToMainCode(getChannelName(ar, i) + ".buffer = "+getChannelName(ar, i)+"_data;" + CR);
 	mainFile.appendToMainCode(getChannelName(ar, i) + ".status = &"+getChannelName(ar, i)+"_status;" + CR2);
@@ -247,31 +276,31 @@ public class TasksAndMainGenerator {
 	mainFile.appendToMainCode("__" +getChannelName(ar, i) + ".outname =\"" + ar.getOutSignal(i).getName() + "\";" + CR);		
 	mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".mwmr_fifo = &" + getChannelName(ar, i) + ";" + CR);
 	
-if(sig.isIn()){//DG 19.05. sig est deja declare (sig1 du block :-)
+	if(sig.isIn()){
 	    mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok_send = 0;" + CR);	mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok_receive = 1;" + CR);
-	    }
+	}
 
 	if(sig.isOut()){
 	    mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok_send = 1;" + CR);	mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".ok_receive = 0;" + CR);
-	    }
+	}
 
 	/* init because mutekh initializer does not work for this */		
 	mainFile.appendToMainCode(getChannelName(ar, i) + ".status =&"+ getChannelName(ar, i)+"_status;" + CR);
 
-			mainFile.appendToMainCode(getChannelName(ar, i)+".status->lock=0;" + CR);
-			mainFile.appendToMainCode(getChannelName(ar, i)+".status->rptr=0;" + CR);
-			mainFile.appendToMainCode(getChannelName(ar, i)+".status->usage=0;" + CR);
-			mainFile.appendToMainCode(getChannelName(ar, i) + ".status->wptr =0;" + CR);
+	mainFile.appendToMainCode(getChannelName(ar, i)+".status->lock=0;" + CR);
+	mainFile.appendToMainCode(getChannelName(ar, i)+".status->rptr=0;" + CR);
+	mainFile.appendToMainCode(getChannelName(ar, i)+".status->usage=0;" + CR);
+	mainFile.appendToMainCode(getChannelName(ar, i) + ".status->wptr =0;" + CR);
 				     		
-		mainFile.appendToBeforeMainCode("uint32_t const "+ getChannelName(ar, i)+"_lock LOCK"+k+";" + CR); 
+	mainFile.appendToBeforeMainCode("uint32_t const "+ getChannelName(ar, i)+"_lock LOCK"+k+";" + CR); 
 	mainFile.appendToBeforeMainCode("struct mwmr_status_s "+ getChannelName(ar, i) +"_status CHANNEL"+k+";" + CR); 		
 	       
 	mainFile.appendToBeforeMainCode("uint8_t "+getChannelName(ar, i) +"_data[32] CHANNEL"+k+";" + CR);
 		
 	mainFile.appendToBeforeMainCode("struct mwmr_s "+getChannelName(ar, i) +" CHANNEL"+k+";" + CR2);
 	k++;			
-	//k--;//DG 24.05.//DG 2.6.	    
-	    }
+	
+	}
 	}
 	}
     }
@@ -284,12 +313,11 @@ if(sig.isIn()){//DG 19.05. sig est deja declare (sig1 du block :-)
 	    mainFile.appendToMainCode("/* Asynchronous channels */" + CR);
             int j=0;
 	    for(AvatarRelation ar: avspec.getRelations()) {
-		//ar.setId(j); j++;//DG
-   //DG 24.05.2017 pas reinitialiser k car 0 to n syncchannels n+1 to m asyncchannels
+	
 		if (ar.isAsynchronous()) {
 		    for(int i=0; i<ar.nbOfSignals() ; i++) {
 
-			ar.setId(i);//DG 15.05.2017
+			ar.setId(i);
 			mainFile.appendToHCode("extern asyncchannel __" + getChannelName(ar, i) + ";" + CR);
 
 			mainFile.appendToBeforeMainCode("asyncchannel __" +getChannelName(ar, i) + ";" + CR);
@@ -299,15 +327,26 @@ if(sig.isIn()){//DG 19.05. sig est deja declare (sig1 du block :-)
 			mainFile.appendToMainCode(getChannelName(ar, i) + "_status.usage = 0;" + CR);
 			mainFile.appendToMainCode(getChannelName(ar, i) + "_status.lock = 0;" + CR2);
 
-			//DG 27.03. width = nbParams
-			//	mainFile.appendToMainCode(getChannelName(ar, i) + ".width = 1;" + CR);
+		
 			AvatarSignal sig = ar.getSignal1(0);
 			int nbParams= sig.getNbParams();
+			//int sizeParams= sig.getCumulSizeParams();
+			//DG 13.06. Attention paramaters have not all size 4!!
+
+			//mainFile.appendToMainCode("sizeParams = sizeof(" );
+			//int cpt = 0;
+			//for(AvatarAttribute attribute: parameters) {
+			//    mainFile.appendToMainCode(attribute.getName() + "sizeof(");
+			//}
+			//mainFile.appendToMainCode(");"+ CR);
+		
 			if (nbParams>0)
 			    mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ (nbParams*4)+";" + CR);
+			    //mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ sizeParams +";" + CR);
+			    //mainFile.appendToMainCode(getChannelName(ar, i) + ".width = sizeParams;" + CR);
 			else mainFile.appendToMainCode(getChannelName(ar, i) + ".width = "+ 4 +";" + CR);
 
-			mainFile.appendToMainCode(getChannelName(ar, i) + ".depth = "+ ar.getSizeOfFIFO()+";" + CR);//DG 27.03.
+			mainFile.appendToMainCode(getChannelName(ar, i) + ".depth = "+ ar.getSizeOfFIFO()+";" + CR);
 			mainFile.appendToMainCode(getChannelName(ar, i) + ".gdepth = "+getChannelName(ar, i)+".depth;" + CR); 
 			mainFile.appendToMainCode(getChannelName(ar, i) + ".buffer = "+getChannelName(ar, i)+"_data;" + CR);
 			mainFile.appendToMainCode(getChannelName(ar, i) + ".status = &"+getChannelName(ar, i)+"_status;" + CR);
@@ -323,23 +362,17 @@ if(sig.isIn()){//DG 19.05. sig est deja declare (sig1 du block :-)
 			
 			mainFile.appendToMainCode("__" + getChannelName(ar, i) + ".mwmr_fifo = &" + getChannelName(ar, i) + ";" + CR);
 				
-	/* force init because mutekh initializer does not work her */		
-	mainFile.appendToMainCode(getChannelName(ar, i) + ".status =&"+ getChannelName(ar, i)+"_status;" + CR);
-
-	mainFile.appendToMainCode(getChannelName(ar, i) +".status->lock=0;" + CR);
-	mainFile.appendToMainCode(getChannelName(ar, i)+".status->rptr=0;" + CR);
-	mainFile.appendToMainCode(getChannelName(ar, i)+".status->usage=0;" + CR);
-	mainFile.appendToMainCode(getChannelName(ar, i)+".status->wptr=0;" + CR);
-	    	    
-	
-	mainFile.appendToBeforeMainCode("uint32_t const "+ getChannelName(ar, i)+"_lock LOCK"+k+";" + CR); 
-	mainFile.appendToBeforeMainCode("struct mwmr_status_s "+ getChannelName(ar, i) +"_status CHANNEL"+k+";" + CR); 		
-	       
-	mainFile.appendToBeforeMainCode("uint8_t "+getChannelName(ar, i) +"_data[32] CHANNEL"+k+";" + CR);
-		
-	mainFile.appendToBeforeMainCode("struct mwmr_s "+getChannelName(ar, i) +" CHANNEL"+k+";" + CR2);
-	//k--;	    
-	k++;//DG 2.6.
+			/* force init because mutekh initializer does not work her */		
+			mainFile.appendToMainCode(getChannelName(ar, i) + ".status =&"+ getChannelName(ar, i)+"_status;" + CR);
+			mainFile.appendToMainCode(getChannelName(ar, i) +".status->lock=0;" + CR);
+			mainFile.appendToMainCode(getChannelName(ar, i)+".status->rptr=0;" + CR);
+			mainFile.appendToMainCode(getChannelName(ar, i)+".status->usage=0;" + CR);
+			mainFile.appendToMainCode(getChannelName(ar, i)+".status->wptr=0;" + CR);	    	    	
+			mainFile.appendToBeforeMainCode("uint32_t const "+ getChannelName(ar, i)+"_lock LOCK"+k+";" + CR); 
+			mainFile.appendToBeforeMainCode("struct mwmr_status_s "+ getChannelName(ar, i) +"_status CHANNEL"+k+";" + CR); 			       
+			mainFile.appendToBeforeMainCode("uint8_t "+getChannelName(ar, i) +"_data[32] CHANNEL"+k+";" + CR);		
+			mainFile.appendToBeforeMainCode("struct mwmr_s "+getChannelName(ar, i) +" CHANNEL"+k+";" + CR2);	 
+			k++;
 		    }
 		}
 	    }
@@ -943,7 +976,7 @@ if(sig.isIn()){//DG 19.05. sig est deja declare (sig1 du block :-)
 
 		    } else {
 
-			ret += "debug2Msg(__myname, \"-> (=====) test "+getChannelName(ar, as) + "\");" + CR;//DG 18.05.
+			ret += "debug2Msg(__myname, \"-> (=====) test "+getChannelName(ar, as) + "\");" + CR;
 
 			ret += "makeNewRequest(&__req" + _index + ", " + _aaos.getID()+ ", SEND_SYNC_REQUEST, " + delay + ", " + _aaos.getNbOfValues() + ", __params" + _index + ");" + CR;
 			ret += "__req" + _index + ".syncChannel = &__" + getChannelName(ar, as) + ";" + CR;
diff --git a/src/main/java/ui/window/JDialogAvatarddExecutableCodeGeneration.java b/src/main/java/ui/window/JDialogAvatarddExecutableCodeGeneration.java
index 070ec969e552744cd71a04617be88f33c6d36093..37ed2a6a1b81b4637e2a91e3b0b1244a2e8c1ed0 100755
--- a/src/main/java/ui/window/JDialogAvatarddExecutableCodeGeneration.java
+++ b/src/main/java/ui/window/JDialogAvatarddExecutableCodeGeneration.java
@@ -48,9 +48,11 @@
 
 package ui.window;
 
+import avatartranslator.AvatarRelation;
 import avatartranslator.AvatarSpecification;
 import ddtranslatorSoclib.AvatarddSpecification;
 import ddtranslatorSoclib.toSoclib.TasksAndMainGenerator;
+import ddtranslatorSoclib.toTopCell.Deployinfo;
 import ddtranslatorSoclib.toTopCell.TopCellGenerator;
 import launcher.LauncherException;
 import launcher.RshClient;
@@ -532,6 +534,7 @@ public class JDialogAvatarddExecutableCodeGeneration extends javax.swing.JFrame
 		ADDDiagramPanel deploymentDiagramPanel = mgui.getFirstAvatarDeploymentPanelFound();
 		AvatarDeploymentPanelTranslator avdeploymenttranslator = new AvatarDeploymentPanelTranslator(deploymentDiagramPanel);
 		AvatarddSpecification avddspec = avdeploymenttranslator.getAvatarddSpecification();
+		AvatarSpecification avspec = mgui.gtm.getAvatarSpecification();
 
 		// Generating code
 		if ( avddspec == null) {
@@ -539,7 +542,7 @@ public class JDialogAvatarddExecutableCodeGeneration extends javax.swing.JFrame
 		} else {
 		    System.err.println("**AVATAR TOPCELL found");
 
-		    TopCellGenerator topCellGenerator = new TopCellGenerator(avddspec, tracemode.isSelected());
+		    TopCellGenerator topCellGenerator = new TopCellGenerator(avddspec, tracemode.isSelected(),avspec);
 		    testGo();
 		    jta.append("Generation of TopCell executable code: done\n");
 		   
@@ -555,6 +558,7 @@ public class JDialogAvatarddExecutableCodeGeneration extends javax.swing.JFrame
 		    } catch (Exception e) {
 			jta.append("Could not generate files\n"); 
 			System.err.println("Could not generate MPSoC files\n");
+			e.printStackTrace();
 		    }
 		}
 						     
@@ -596,7 +600,7 @@ public class JDialogAvatarddExecutableCodeGeneration extends javax.swing.JFrame
 
 		selectedUnit = units.getSelectedIndex();
 		//System.out.println("Selected item=" + selectedItem);
-		AvatarSpecification avspec = mgui.gtm.getAvatarSpecification();
+		//AvatarSpecification avspec = mgui.gtm.getAvatarSpecification();
 
 		// Generating code
 		if (avspec == null) {
@@ -614,7 +618,7 @@ public class JDialogAvatarddExecutableCodeGeneration extends javax.swing.JFrame
 			System.err.println("AVATAR TOPCELL found");
 		    }
 
-		    TopCellGenerator topCellGenerator = new TopCellGenerator(avddspec, tracemode.isSelected());
+		    TopCellGenerator topCellGenerator = new TopCellGenerator(avddspec, tracemode.isSelected(),avspec);
 		    testGo();
 		    jta.append("Generation of TopCell executable code: done\n");