source: PROJECT_CORE_MPI/MPI_HCL/TRUNK/NOC/OUTPUT_PORT_MODULE.vhd @ 101

Last change on this file since 101 was 101, checked in by rolagamo, 10 years ago
File size: 5.6 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--
22----------------------------------------------------------------------------------
23library IEEE;
24use IEEE.STD_LOGIC_1164.ALL;
25--use IEEE.STD_LOGIC_ARITH.ALL;
26--use IEEE.STD_LOGIC_UNSIGNED.ALL;
27USE ieee.numeric_std.ALL;
28Library NocLib;
29use NocLib.CoreTypes.all;
30---- Uncomment the following library declaration if instantiating
31---- any Xilinx primitives in this code.
32--library UNISIM;
33--use UNISIM.VComponents.all;
34
35entity OUTPUT_PORT_MODULE is
36    Port ( data_in : in  STD_LOGIC_VECTOR (Word-1 downto 0);
37           reset : in  STD_LOGIC;
38           clk : in  STD_LOGIC;
39           wr_en : in  STD_LOGIC;
40           data_out : out  STD_LOGIC_VECTOR (Word-1 downto 0);
41                          fifo_full : out std_logic;
42                          data_avalaible : out std_logic;
43                          rd_out_en : in  STD_LOGIC);
44end OUTPUT_PORT_MODULE;
45
46architecture Behavioral_description of OUTPUT_PORT_MODULE is
47-- declaration du FIFO 64 octets
48component FIFO_256_FWFT
49        port (
50        clk: IN std_logic;
51        din: IN std_logic_VECTOR(Word-1 downto 0);
52        rd_en: IN std_logic;
53        srst: IN std_logic;
54        wr_en: IN std_logic;
55        dout: out std_logic_VECTOR(Word-1 downto 0);
56        empty: OUT std_logic;
57        full: OUT std_logic);
58end component;
59--definition du type etat pour les fsm
60type typ_outfsm is (Idle,waiting,dropping,reading);
61type typ_receiv is (r_wait,r_head,r_len,r_glen,r_data,r_pulse,r_end);
62
63signal EtRec : typ_receiv;
64signal Et_out_fsm : typ_outfsm;
65signal fifo_empty : std_logic; 
66signal sw : std_logic:='0'; -- permet de positionner le mux sur les signaux internes
67signal tlimit : natural:=0; --permet de compter les impulsions de temps
68signal n : natural:=0; --utiliser pour la mae du tampon de sortie
69signal rcv_start :  std_logic; --début de la réception
70signal  rcv_ack : std_logic;   -- acquittement de la réception
71signal  rcv_comp :  std_logic; -- fin de la réception
72signal   spop,pop,rd_en,dat_avail :  std_logic:='0';
73signal  mem,fifo_out :  std_logic_vector(Word-1 downto 0); --variable tampon sans intérêt réel
74begin
75-- instantiation du FIFO_64
76 OUTPUT_PORT_FIFO : FIFO_256_FWFT
77                port map (
78                        clk => clk,
79                        din => data_in,
80                        rd_en => rd_en,
81                        srst => reset,
82                        wr_en => wr_en,
83                        dout => fifo_out,
84                        empty => fifo_empty,
85                        full => fifo_full);
86                       
87
88outport_proc : process(clk,reset,fifo_empty)
89begin
90if rising_edge(clk) then
91if reset='1' then
92n<=0;
93Et_out_fsm<=Idle;
94else
95case(Et_out_fsm) is 
96
97when Idle => --idle
98        if fifo_empty = '0' then
99                Et_Out_fsm<=waiting;
100        end if;
101        tlimit<=0;
102        sw<='0';
103when reading =>
104if rd_out_en='0' then
105        Et_out_fsm<=Idle;
106end if;
107sw<='0';
108when waiting =>  --counting
109if rd_out_en='1' then
110        Et_out_fsm<=reading;
111elsif tlimit=5000 then
112        Et_out_fsm<=dropping;
113        tlimit<=0;
114else
115        tlimit<=tlimit+1;
116end if;
117sw<='0';
118when dropping => --dropping packet
119        if n=0 then
120                rcv_start<='1';
121                n<=1;
122                sw<='1';
123        elsif n=1 then
124                if rcv_comp='1' then
125                        rcv_ack<='1';
126                        rcv_start<='0';
127                        n<=2;
128                end if;
129                sw<='1';
130        elsif n=2 then
131                sw<='0';
132                Et_out_fsm<=Idle;
133                report "Attention Paquet perdu !à Output_Port_Module";
134                n<=0;
135        end if;
136
137end case;
138end if;
139end if;
140end process outport_proc;
141data_out<=fifo_out;
142mux_proc : process (sw,rd_out_en,pop,fifo_empty)
143begin
144if sw='1' then --mode drop
145        rd_en<=pop;
146        data_avalaible <='0'; --plus de données dans le tampon !
147else
148        rd_en<=rd_out_en;
149        data_avalaible <= not fifo_empty;
150end if;
151end process mux_proc;
152proc_receiv : process (clk,reset)
153variable dlen,i: natural range 0 to 255 :=0;
154
155        begin
156        if reset='1' then 
157                                 etrec<=r_wait;
158                                 
159                                else 
160                                                if rising_edge(clk) then -- le process s'exécute sur chaque front
161                                                                                                                        -- montant de l'horloge
162                                                case etrec is
163                                                when r_wait  =>
164                                                       
165                                                        i:=0;
166                                                        if fifo_empty='0' and rcv_start='1' then
167                                                       
168                                                        etrec<=r_head;
169                                                        mem<=fifo_out;
170                                                       
171                                                        end if;
172                                                when r_head  =>
173                                                        mem<=fifo_out;  --l'en-tête
174                                                       
175                                                        etrec<=r_len;
176                                                when r_len =>
177                                                                dlen:=to_integer(unsigned(fifo_out));
178                                                                mem<=fifo_out; -- la longueur
179                                                               
180                                                                if dlen>2 then
181                                                                        etrec<=r_data;
182                                                                else
183                                                                        etrec<=r_end;
184                                                                end if;
185                                                                i:=1;
186                                                               
187                                                when r_data  =>
188                                                                if fifo_empty='0' then
189                                                                        if i<dlen-2 then
190                                                                                i:=i+1;
191                                                                                mem<=fifo_out;
192                                                                               
193                                                                               
194                                                                        else
195                                                                                etrec<=r_pulse;
196                                                                               
197                                                                                mem<=fifo_out;
198                                                                        end if;
199                                                                        -- time out à prévoir ici
200                                                                end if;
201                                                when r_pulse =>
202                                                                etrec<=r_end;
203                                                               
204                                                when r_end  =>
205                                                                if rcv_ack='1' then
206                                                                        etrec<=r_wait;
207                                                                end if;
208                                                               
209                                                when others =>
210                                                               
211                                                               
212                                                                etrec<=r_wait;
213                                                end case;
214                                                end if;
215                                end if;
216        end process;
217       
218        pop<=spop;
219       
220rec_value : process (etrec)
221begin
222case etrec is
223                                        when r_wait  =>
224                                                spop<='0';
225                                                rcv_comp<='0';
226                                        when r_head  =>
227                                                       
228                                                        spop<='1';
229                                                        rcv_comp<='0';
230
231                                        when r_len =>
232                                                        spop<='1';
233                                        when r_data =>
234                                                        spop<='1';
235                                        when r_pulse =>
236                                                                spop<='0';
237                                                                rcv_comp<='1';
238                                        when r_end =>
239                                                        spop<='0';
240                                                        rcv_comp<='1';
241                                        when others =>
242                                                        spop<='0';
243                                                        rcv_comp<='0';
244                                end case;
245        end process;
246
247end Behavioral_description;
248
Note: See TracBrowser for help on using the repository browser.