source: PROJECT_CORE_MPI/MPI_HCL/BRANCHES/v2.0/NOC/OUTPUT_PORT_MODULE.vhd @ 139

Last change on this file since 139 was 139, checked in by rolagamo, 10 years ago

Ceci est la version 16 bits de la plateforme ainsi que la version hierarchique du NoCNoC

File size: 7.1 KB
Line 
1
2----------------------------------------------------------------------------------
3-- Company:
4-- Engineer:
5--
6-- Create Date:    09:29:48 04/18/2011
7-- Design Name:
8-- Module Name:    OUTPUT_PORT_MODULE - Behavioral_description
9-- Project Name:
10-- Target Devices:
11-- Tool versions:
12-- Description:
13-- cette version du module de sortie se limite à une instance du fifo ordinaire
14-- les données son emise en sortie à chaque cycle d'horloge
15-- Dependencies:
16--
17-- Revision: 07-08-2013
18-- Revision 0.01 - File Created
19-- Additional Comments: Ajout d'un délai pour ignorer les paquets qui sont là depuis
20-- longtemps
21--Revision: Mai-02-2014
22-- Revision 0.01 - File
23-- Additional Comments: Passage à la version 16 bits
24-- longtemps
25----------------------------------------------------------------------------------
26library IEEE;
27use IEEE.STD_LOGIC_1164.ALL;
28--use IEEE.STD_LOGIC_ARITH.ALL;
29--use IEEE.STD_LOGIC_UNSIGNED.ALL;
30USE ieee.numeric_std.ALL;
31Library NocLib;
32use NocLib.CoreTypes.all;
33---- Uncomment the following library declaration if instantiating
34---- any Xilinx primitives in this code.
35--library UNISIM;
36--use UNISIM.VComponents.all;
37
38entity OUTPUT_PORT_MODULE is
39        generic(        nbyte : positive:=2); -- le nombre de Byte dans chaque mot du port par défaut 2
40 
41    Port ( data_in : in  STD_LOGIC_VECTOR (7 downto 0);
42           reset : in  STD_LOGIC;
43           clk : in  STD_LOGIC;
44           wr_en : in  STD_LOGIC;
45           data_out : out  STD_LOGIC_VECTOR (Word-1 downto 0);
46                          fifo_full : out std_logic;
47                          data_avalaible : out std_logic;
48                          rd_out_en : in  STD_LOGIC);
49end OUTPUT_PORT_MODULE;
50
51architecture Behavioral_description of OUTPUT_PORT_MODULE is
52-- declaration du FIFO 64 octets
53component FIFO_256_FWFT
54        port (
55        clk: IN std_logic;
56        din: IN std_logic_VECTOR(Word-1 downto 0);
57        rd_en: IN std_logic;
58        srst: IN std_logic;
59        wr_en: IN std_logic;
60        dout: out std_logic_VECTOR(Word-1 downto 0);
61        empty: OUT std_logic;
62        full: OUT std_logic);
63end component;
64--definition du type etat pour les fsm
65type typ_outfsm is (Idle,waiting,dropping,reading);
66type typ_receiv is (r_wait,r_head,r_len,r_glen,r_data,r_pulse,r_end);
67type typ_store is (idle,accu,transf);
68signal EtRec : typ_receiv;
69signal Et_store,next_et_store: typ_store;
70signal Et_out_fsm : typ_outfsm;
71signal fifo_empty ,fifo_wr: std_logic:='0';     
72signal sw : std_logic:='0'; -- permet de positionner le mux sur les signaux internes
73signal tlimit : natural:=0; --permet de compter les impulsions de temps
74signal n : natural:=0; --utiliser pour la mae du tampon de sortie
75signal nib : natural:=nbyte; --nombre de byte à transférer
76signal rcv_start :  std_logic; --début de la réception
77signal  rcv_ack : std_logic;   -- acquittement de la réception
78signal  rcv_comp :  std_logic; -- fin de la réception
79signal   spop,pop,rd_en,dat_avail :  std_logic:='0';
80signal fifo_in :std_logic_vector(Word-1 downto 0); --le tampon de données d'entrée
81signal  mem,fifo_out :  std_logic_vector(Word-1 downto 0); --variable tampon sans intérêt réel
82begin
83-- instantiation du FIFO_64
84 OUTPUT_PORT_FIFO : FIFO_256_FWFT
85                port map (
86                        clk => clk,
87                        din => fifo_in,
88                        rd_en => rd_en,
89                        srst => reset,
90                        wr_en => fifo_wr,
91                        dout => fifo_out,
92                        empty => fifo_empty,
93                        full => fifo_full);
94--sync_store_state:process (clk)
95--begin
96--if rising_edge(clk) then
97--              if reset='1' then
98--                      et_store<=idle;
99--              else
100--                      et_store<=next_et_store;
101--              end if;
102--
103--end if;
104--end process sync_store_state;                 
105next_store_state:process (clk)
106begin
107if rising_edge(clk) then
108case et_store is
109when idle =>
110if wr_en='1' then
111et_store<=transf;
112nib<=nib-1;
113else
114 nib<=nbyte; 
115end if;
116
117
118when accu =>
119               
120                if nib=1 then
121                  et_store<=transf;
122                 
123                  nib<=nbyte;
124                else
125                 nib<=nib-1; 
126                end if;
127
128when transf =>
129        --next_et_store<=idle; 
130        if wr_en='1' then
131          if nib=1 then 
132            nib<=nbyte;
133           else
134         nib<=nib-1;
135          end if; 
136         et_store<=accu;
137        else
138         nib<=nbyte;
139         et_store<=idle;
140        end if;
141end case ;
142
143end if;
144end process next_store_state;
145
146val_store_state:process (et_store,nib,data_in,wr_en)
147begin
148--case et_store is
149--when transf =>fifo_wr<='1';
150--when others => fifo_wr<='0';
151--end case;
152if nib=1 then
153  fifo_wr<='1';
154else
155  fifo_wr<='0';
156end if;
157fifo_in(8*nib-1 downto 8*(nib-1))<=data_in;
158end process val_store_state;
159
160
161outport_proc : process(clk,reset,fifo_empty)
162begin
163
164if rising_edge(clk) then
165if reset='1' then
166n<=0;
167Et_out_fsm<=Idle;
168else
169case(Et_out_fsm) is 
170
171when Idle => --idle
172        if fifo_empty = '0' then
173                Et_Out_fsm<=waiting;
174        end if;
175        tlimit<=0;
176        sw<='0';
177when reading =>
178if rd_out_en='0' then
179        Et_out_fsm<=Idle;
180end if;
181sw<='0';
182when waiting =>  --counting
183if rd_out_en='1' then
184        Et_out_fsm<=reading;
185elsif tlimit=5000 then
186        Et_out_fsm<=dropping;
187        tlimit<=0;
188else
189        tlimit<=tlimit+1;
190end if;
191sw<='0';
192when dropping => --dropping packet
193        if n=0 then
194                rcv_start<='1';
195                n<=1;
196                sw<='1';
197        elsif n=1 then
198                if rcv_comp='1' then
199                        rcv_ack<='1';
200                        rcv_start<='0';
201                        n<=2;
202                end if;
203                sw<='1';
204        elsif n=2 then
205                sw<='0';
206                Et_out_fsm<=Idle;
207                report "Attention Paquet perdu !à Output_Port_Module";
208                n<=0;
209        end if;
210
211end case;
212end if;
213end if;
214end process outport_proc;
215data_out<=fifo_out;
216mux_proc : process (sw,rd_out_en,pop,fifo_empty)
217begin
218if sw='1' then --mode drop
219        rd_en<=pop;
220        data_avalaible <='0'; --plus de données dans le tampon !
221else
222        rd_en<=rd_out_en;
223        data_avalaible <= not fifo_empty;
224end if;
225end process mux_proc;
226proc_receiv : process (clk,reset)
227variable dlen,i: natural range 0 to 255 :=0;
228
229        begin
230        if reset='1' then 
231                                 etrec<=r_wait;
232                                 
233                                else 
234                                                if rising_edge(clk) then -- le process s'exécute sur chaque front
235                                                                                                                        -- montant de l'horloge
236                                                case etrec is
237                                                when r_wait  =>
238                                                       
239                                                        i:=0;
240                                                        if fifo_empty='0' and rcv_start='1' then
241                                                       
242                                                        etrec<=r_head;
243                                                        mem<=fifo_out;
244                                                       
245                                                        end if;
246                                                when r_head  =>
247                                                        mem<=fifo_out;  --l'en-tête
248                                                       
249                                                        etrec<=r_len;
250                                                when r_len =>
251                                                                dlen:=to_integer(unsigned(fifo_out));
252                                                                mem<=fifo_out; -- la longueur
253                                                               
254                                                                if dlen>2 then
255                                                                        etrec<=r_data;
256                                                                else
257                                                                        etrec<=r_end;
258                                                                end if;
259                                                                i:=1;
260                                                               
261                                                when r_data  =>
262                                                                if fifo_empty='0' then
263                                                                        if i<dlen-2 then
264                                                                                i:=i+1;
265                                                                                mem<=fifo_out;
266                                                                               
267                                                                               
268                                                                        else
269                                                                                etrec<=r_pulse;
270                                                                               
271                                                                                mem<=fifo_out;
272                                                                        end if;
273                                                                        -- time out à prévoir ici
274                                                                end if;
275                                                when r_pulse =>
276                                                                etrec<=r_end;
277                                                               
278                                                when r_end  =>
279                                                                if rcv_ack='1' then
280                                                                        etrec<=r_wait;
281                                                                end if;
282                                                               
283                                                when others =>
284                                                               
285                                                               
286                                                                etrec<=r_wait;
287                                                end case;
288                                                end if;
289                                end if;
290        end process;
291       
292        pop<=spop;
293       
294rec_value : process (etrec)
295begin
296case etrec is
297                                        when r_wait  =>
298                                                spop<='0';
299                                                rcv_comp<='0';
300                                        when r_head  =>
301                                                       
302                                                        spop<='1';
303                                                        rcv_comp<='0';
304
305                                        when r_len =>
306                                                        spop<='1';
307                                        when r_data =>
308                                                        spop<='1';
309                                        when r_pulse =>
310                                                                spop<='0';
311                                                                rcv_comp<='1';
312                                        when r_end =>
313                                                        spop<='0';
314                                                        rcv_comp<='1';
315                                        when others =>
316                                                        spop<='0';
317                                                        rcv_comp<='0';
318                                end case;
319        end process;
320
321end Behavioral_description;
322
Note: See TracBrowser for help on using the repository browser.