Index: /PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/CoreTypes.vhd
===================================================================
--- /PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/CoreTypes.vhd	(revision 70)
+++ /PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/CoreTypes.vhd	(revision 71)
@@ -37,6 +37,37 @@
 	type memory is 
 	array (natural range <>) of std_logic_vector(word-1 downto 0);
-	
-type Core_io is
+
+type Core_i is
+	record
+		Instr_ack :std_logic;-- signal la prise en compte de l'instruction
+		Ready   :std_logic;-- indique que la dernière fonction est terminée
+		InitOk :std_logic; -- l'initialisation est terminée
+		Hold_Req :std_logic;--Demande DMA 
+		RamSel :std_logic;-- indique le statut de la RAM (0 ->dispo 1->occupé par Core_MPI)
+		IsMain : std_logic; -- indique si la librairie est principal
+		Rank : natural range 0 to 15; --donne le rang du processus courant
+		Spawned: std_logic; --indique que ce module a été activé par la bibliothèque
+end record;	
+type Core_o is
+	record
+		Instr_en :std_logic;  -- active une instruction MPI
+		Hold_Ack :std_logic;-- Autorisation DMA
+		MemBusy :std_logic;-- active le refus de DMA (1 -> ignoré la requête DMA de MPI HCL) 
+		Instruction :std_logic_vector (word-1 downto 0); -- fonction Mpi à exécuter	
+end record;
+type core_s is
+record
+		IntState1 : natural range 0 to 255; --permet de stocker l'état des MAE interne dans les procédures
+		IntState2 : natural range 0 to 255;
+		WinId :natural range  0 to 255; --stocke le dernier Id utilisé par WinCreate
+end record;
+type core_io is
+record
+		I:core_i; --les entrées
+		O:core_o; --les sorties
+		S:core_s; --les signaux temporaires
+end record;
+
+type Core_io_old is
 	record
 		Instr_en :std_logic;  -- active une instruction MPI
@@ -53,14 +84,17 @@
 		WinId :natural range  0 to 255; --stocke le dernier Id utilisé par WinCreate
 		IsMain : std_logic; -- indique si la librairie est principal
-		Rank : natural range 0 to 16; --donne le rang du processus courant
+		Rank : natural range 0 to 15; --donne le rang du processus courant
 		Spawned: std_logic; --indique que ce module a été activé par la bibliothèque
 end record;
 
-type typ_dpram is
-record
-			  
-           
-	    clk_wr :  STD_LOGIC;
-	    clk_rd :  STD_LOGIC;
+type typ_dpram_i is
+record
+		data_out :  STD_LOGIC_VECTOR (Word-1 downto 0); 
+			             		  
+end record;        
+type typ_dpram_o is
+record
+	   clk_wr :  STD_LOGIC;
+	   clk_rd :  STD_LOGIC;
 		we     :  STD_LOGIC;
 		ena    :  STD_LOGIC;
@@ -68,9 +102,11 @@
 		addr_wr:  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
 		addr_rd :  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
-		data_in  :  STD_LOGIC_VECTOR (Word-1 downto 0);
-		data_out :  STD_LOGIC_VECTOR (Word-1 downto 0); 
-			  
-           		  
-end record;        
+		data_in  :  STD_LOGIC_VECTOR (Word-1 downto 0); 
+end record;     
+type typ_dpram is
+record
+O : typ_dpram_o;
+I : typ_dpram_I;
+end record;   
 type Typ_MPIPort_in is
 record
Index: /PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/INPUT_PORT_MODULE.vhd
===================================================================
--- /PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/INPUT_PORT_MODULE.vhd	(revision 70)
+++ /PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/INPUT_PORT_MODULE.vhd	(revision 71)
@@ -552,5 +552,5 @@
 											ReadOk<='0';
 											pop_state<=stateErr;
-											data_counter<=(others => '0');
+											--data_counter<=(others => '0');
 										end if;
 									else
@@ -605,5 +605,5 @@
 								dat_request_decoder_en <= '1';          --autoriser le decodeur activer le dernier bit de request
 								dat_data_out_pulse <= '0';     --transmettre le signal pour le dernier mot
-								dat_priority_rotation <= '0';
+								dat_priority_rotation <= Port_granted; --dès qu'on a la priorité on la garde
 								dat_exec<='1';
 								dat_Err<='0';
Index: /PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/proto_send.vhd
===================================================================
--- /PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/proto_send.vhd	(revision 70)
+++ /PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/proto_send.vhd	(revision 71)
@@ -21,5 +21,5 @@
 use IEEE.STD_LOGIC_1164.ALL;
 USE ieee.numeric_std.ALL;
-use CoreTypes.all;
+use work.CoreTypes.all;
 -- Uncomment the following library declaration if using
 -- arithmetic functions with Signed or Unsigned values
@@ -35,11 +35,16 @@
  port (
  clk,reset : in std_logic;
- fifo_empty,fifo_full : in std_logic;
-  push : out std_logic:='0';
- fifo_in : out std_logic_vector(Word-1 downto 0);
+ fifo_in_empty,fifo_in_full : in std_logic; --signaux pour le fifo d'entrée
+ fifo_out_empty,fifo_out_full : in std_logic; --signaux pour le fifo de sortie
+ fifo_out_wr_en : out std_logic:='0'; --écriture autorisée dans la fifo de sortie
+ fifo_in_rd_en : out std_logic:='0'; --lecture autorisée dans la fifo d'entrée
+ fifo_in_data_out : in std_logic_vector(Word-1 downto 0);
+ fifo_out_data_in : out std_logic_vector(Word-1 downto 0);
+ packet_len : in std_logic_vector(Word-1 downto 0); --la longueur du paquet
+ copy_mode : in std_logic; --Fifo_to_mem ou Fifo_to_fifo
  snd_start : in std_logic; --début de la réception
  snd_ack :in std_logic;   -- acquittement de la réception
  snd_comp : out std_logic; -- fin de la réception
- mem :in memory(0 to sizemem-1));
+ mem :in memory(0 to sizemem-1)); --données à copier vers le fifo
 
 end proto_send;
@@ -48,87 +53,108 @@
 type typ_send is (s_head,s_len,s_len2,s_data,s_pulse,s_end);
  signal etsnd : typ_send;
- signal sfifo_in : std_logic_vector(Word-1 downto 0);
+ signal snd_state,next_snd_state:natural range 0 to 7:=0;
+ signal p_len,p_len_i : natural range 0 to 255;
+ signal n,n_i:natural range 0 to 7;
+ signal wr_ok,rd_ok:std_logic:='0';
+ signal sfifo_in,Data_to_send : std_logic_vector(Word-1 downto 0);
  signal spush : std_logic:='0';
  signal err : std_logic_vector(Word-1 downto 0):=(others =>'0');
 begin
 
-proc_send : process (clk,reset)
-variable dlen,i: natural range 0 to 255 :=0;
+Fifo_copy_sync:process(clk)
+
+begin
+if rising_edge(clk) then
+
+  if reset='1' then
+  n<=0;
+  Snd_state<=0;
+  P_len<=0;
+else
+  Snd_state<=Next_Snd_state;
+  n<=n_i;	
+  p_len<=P_len_i;
+end if;
+end if;
+end process fifo_copy_sync;
+	-- affectation concurentes
+	 Fifo_copy_val:process (Snd_state,Etsnd,copy_mode,data_to_send,rd_ok,wr_ok,spush)
+begin
+	if copy_mode='0' then 
+	  fifo_out_wr_en<=wr_ok;
+	  fifo_out_data_in<=data_to_send;
+	  fifo_in_rd_en<='0';
+else
+    if (Snd_state=1) or (snd_state=2) then
+	    	  fifo_out_wr_en<=wr_ok;
+	    	  fifo_in_rd_en<=rd_ok;
+	    	  fifo_out_data_in<=data_to_send;
+	  end if;
+end if;
+end process fifo_copy_val;
+	-- process qui envoie des données en provenance d'un Fifo vers un Fifo
+	FIfo_to_fifo:process(snd_state,copy_mode,snd_start,snd_ack,fifo_in_empty,
+	fifo_out_full,Fifo_in_data_out,p_len)
+	variable onepop:std_logic:='0';
 	begin
-	if reset='1' then 
-				 etsnd<=s_head;
-				 err<=(others =>'0');
-				else  
-						if rising_edge(clk) then -- le process s'exécute sur chaque front 
-															-- montant de l'horloge
-						case etsnd is
-						when s_head  =>
-							sfifo_in<=mem(0);
-							snd_comp<='0';
-							i:=0;
-							
-							if fifo_empty='1' and snd_start='1' then
-							spush<='1';
-							snd_comp<='0';
-							etsnd<=s_len;
-							end if;
-						when s_pulse =>
-							spush<='1';
-							etsnd<=s_len;
-						when s_len  =>
-							sfifo_in<=mem(1); --8 données
-							i:=i+1;
-							dlen:=to_integer(unsigned(mem(i)));
-							if dlen > 2 then
-								spush<='1';
-								snd_comp<='0';
-								etsnd<=s_data;
-							else
-								spush<='1';
-								snd_comp<='1';
-								etsnd<=s_end;
-							
-							end if;
-						when s_len2 =>
-							snd_comp<='0';
-								etsnd<=s_data;
-								
-						when s_data  =>
-								if (fifo_full='0') and (dlen >2) then 
-								i:=i+1;
-								sfifo_in<=mem(i);
-									if i>=dlen-1 then --les indices 0 et 1 étant réservés
-															--les données sont comptés à partir de 2
-										etsnd<=s_end;
-										snd_comp<='1';
-										spush<='1';
-									else
-										spush<='1';
-									end if;
-									
-								else
-								spush<='0';
-								end if;
-						
-						when s_end  =>
-								spush<='0';
-								etsnd<=s_head;
-								sfifo_in<=(others=>'-');
-								if snd_ack='1' then
-									etsnd<=s_head;
-								end if;
-						when others =>
-								spush<='0';
-								etsnd<=s_head;
-								sfifo_in<=(others=>'0');
-						end case;
-						end if;
-				end if;
-	end process;
+	  	  Next_snd_state<=snd_state; --valeur par defaut
+	  case snd_state is
+
+	  when 0 => if snd_start='1' then
+	               P_len_i<=to_integer(unsigned(packet_len));
+	                 next_snd_state<=1;
+	                 n_i<=0;
+	             end if;
+	             wr_ok<='0';rd_ok<='0';onepop:='0';
+	             snd_comp<='0';
+	  when 1=>         if P_len>0 then  
+										    if copy_mode='1' then 
+												if  fifo_in_empty='0' and onepop='0' then
+														data_to_send <=fifo_in_data_out ;
+														rd_Ok<='1';
+															onepop:=not onepop; --une donnée lue il faut arrêter de dépiler
+															
+												else
+															rd_Ok<='0';
+												end if;
+												else
+												  onepop:='1';
+												  data_to_send<=mem(n);
+												 end if;
+
+											  if (fifo_out_full = '0') and onepop='1'   then	 										wr_ok<='1';
+													onepop:=not onepop;
+													wr_ok<='1';
+													p_len_i<=p_len-1;
+													n_i<=n+1;
+													
+												else
+														wr_Ok<='0';
+													
+												end if;
+											else
+											 rd_ok<='0';wr_ok<='0';
+											 next_snd_state<=2;
+											 snd_comp<='1';
+											end if; 
+		when 2 =>  --fin de la copie
+												if  snd_ack='1' then 
+												
+												    next_snd_state<=3;
+												end if;
+												wr_ok<='0';rd_ok<='0';
+												snd_comp<='1';		
+														data_to_send <=(others=>'-');
+	when 3 =>next_snd_state<=0;
+	         snd_comp<='0';
+															
+when others => next_snd_state<=0;
+                  snd_comp<='0';
+                  rd_ok<='0';
+                  wr_ok<='0';
+                  data_to_send <=(others=>'-');
+  end case;
+	end process FIfo_to_fifo;
 	
-	-- affectation concurentes
-	
-	push<=spush;
-	fifo_in<=sfifo_in;
 end Behavioral;
 
