source: PROJECT_CORE_MPI/CORE_MPI/BRANCHES/v0.01/FIFO_64_FWFT_old.vhd @ 43

Last change on this file since 43 was 15, checked in by rolagamo, 12 years ago
File size: 5.9 KB
Line 
1----------------------------------------------------------------------------------
2-- Company:
3-- Engineer: KIEGAING EMMANUEL/GAMOM
4--
5-- Create Date:    19:51:54 04/19/2011
6-- Design Name:
7-- Module Name:    FIFO_64 - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description:
12--FIFO 64 Octets utisé pour les modules d'entrée
13-- ce fifo est de type fwft first word falls throught ce qui
14-- signifie que l'on a toujours la donnée au sommet de la pile en
15-- sortie du fifo.
16-- Dependencies:  RAM_64.vhd
17--
18-- Revision: 30-07-2012
19-- Revision 0.01 - File Created
20-- Additional Comments: suppression du signal counter_en dans les expressions
21--
22----------------------------------------------------------------------------------
23library IEEE;
24use IEEE.STD_LOGIC_1164.ALL;
25use IEEE.STD_LOGIC_ARITH.ALL;
26use IEEE.STD_LOGIC_UNSIGNED.ALL;
27Library NocLib;
28use NocLib.CoreTypes.all;
29---- Uncomment the following library declaration if instantiating
30---- any Xilinx primitives in this code.
31--library UNISIM;
32--use UNISIM.VComponents.all;
33
34entity FIFO_64_FWFT is
35    Port ( clk : in  STD_LOGIC;
36           din : in  STD_LOGIC_VECTOR (Word-1 downto 0);
37           rd_en : in  STD_LOGIC;
38           srst : in  STD_LOGIC;
39           wr_en : in  STD_LOGIC;
40           dout : out  STD_LOGIC_VECTOR (Word-1 downto 0);
41           empty : out  STD_LOGIC;
42           full : out  STD_LOGIC);
43end FIFO_64_FWFT;
44
45architecture Behavioral of FIFO_64_FWFT is
46-- declaration de la ram 64 octets
47COMPONENT RAM_64
48        PORT(
49                clka : IN std_logic;
50                clkb : IN std_logic;
51                wea : IN std_logic;
52                ena : IN std_logic;
53                enb : IN std_logic;
54                addra : IN std_logic_vector(5 downto 0);
55                addrb : IN std_logic_vector(5 downto 0);
56                dia : IN std_logic_vector(Word-1 downto 0);         
57                --doa : OUT std_logic_vector(Word-1 downto 0);
58                dob : OUT std_logic_vector(Word-1 downto 0)
59                );
60        END COMPONENT;
61type fsm_states is (state0, state1, state2);-- definition du type etat pour le codage des etats des fsm
62signal fwft_fsm_state : fsm_states;
63-- declaration des signeaux des compteurs
64signal push_address_counter : std_logic_vector(5 downto 0);
65signal pop_address_counter : std_logic_vector(5 downto 0);
66signal fifo_counter : std_logic_vector(5 downto 0);
67--autre signaux
68signal empty_signal : std_logic;
69signal full_signal  : std_logic;
70signal wr_en_signal : std_logic;
71signal rd_en_signal : std_logic;
72signal clk_signal :  std_logic;
73signal dob_signal : std_logic_vector(Word-1 downto 0);
74signal dout_signal : std_logic_vector(Word-1 downto 0);
75signal doa_signal : std_logic_vector(Word-1 downto 0);
76signal counter_en : std_logic; 
77
78begin
79
80-- ram instantiation de la ram 64 octets du FIFO
81fifo_RAM_64: RAM_64 PORT MAP(
82                clka => clk_signal,
83                clkb => clk_signal,
84                wea => wr_en_signal,
85                ena => wr_en_signal,
86                enb => rd_en_signal,
87                addra => push_address_counter,
88                addrb => pop_address_counter,
89                dia => din,
90                --doa => doa_signal,
91                dob => dob_signal
92        );
93-- circuiterie des signaux de validation et d'etat du fifo
94wr_en_signal <= wr_en and (not full_signal); -- la donnée est ignorée si le fifo est plein
95rd_en_signal <= rd_en and (not empty_signal);-- pas de lecture si le fifo est vide
96full_signal <= '1' when fifo_counter = "111111" else
97                                   '0';
98empty_signal <= '1' when fifo_counter = "000000" else
99                                         '0';
100clk_signal <= clk;
101full <= full_signal;
102empty <= empty_signal;
103
104-- sortie du fifo fwft
105dout <= dout_signal;
106
107-- le processus des transistion
108fwft_fsm_nsl : process(clk)
109 begin
110    if rising_edge(clk) then
111           if srst = '1' then
112                   fwft_fsm_state  <= state0;
113                else
114                   case fwft_fsm_state  is
115                                        when state0 => if wr_en_signal = '1' then
116                                                                                        fwft_fsm_state  <= state1;
117                                                                                end if;
118                                        when state1 => if rd_en_signal = '1' then
119                                                                                        fwft_fsm_state  <= state2;
120                                                                                end if;
121                                        when state2 => if rd_en_signal='1' and fifo_counter = "000001" then --lecture avec écriture
122                                                                                        fwft_fsm_state  <= state0;
123                                                                                elsif fifo_counter = "000000" then
124                                                                                        fwft_fsm_state  <= state0;
125                                                                                end if;
126                                       
127                                        when others => fwft_fsm_state <= state0;
128                        end case;
129           end if;
130        end if;
131 end process;
132 -- actions associées à la fsm
133 -- mux qui oriente les sortie doa et dob vers out
134 with fwft_fsm_state select
135    dout_signal <= dob_signal when state0, 
136                        doa_signal when state1,
137                        dob_signal when state2, 
138                                                 doa_signal when others;
139 -- counter_en
140 with fwft_fsm_state select
141    counter_en   <= '0' when state0, 
142                         '1' when state1,
143                         '1' when state2, 
144                                                  '0' when others;
145doa_latch_process : process(clk)
146begin
147  if rising_edge(clk) then
148                if wr_en_signal ='1'  then
149                        doa_signal <= din;
150                end if;
151  end if;
152end process;
153                       
154-- processus de comptage des adresses d'empilement
155push_process : process(clk)
156 begin
157 if rising_edge(clk) then
158   if srst = '1' then
159         push_address_counter <= (others =>'0');
160        elsif wr_en_signal ='1' then
161                push_address_counter <= push_address_counter +1;
162         end if;
163 end if;
164end process;
165 
166 -- processus de comptage des adresses depilement du fifo
167pop_process : process(clk)
168 begin
169 if rising_edge(clk) then
170   if srst = '1' then
171          pop_address_counter <= (others =>'0');
172        elsif rd_en_signal ='1' then
173                pop_address_counter <= pop_address_counter +1;
174        end if;
175 end if;
176 end process;
177 
178 -- processus de comptage des octets dans le fifo
179 fifo_counter_process : process(clk)
180begin
181 if rising_edge(clk) then
182   if srst = '1' then
183         fifo_counter <= (others =>'0');
184        else
185         if wr_en_signal ='1' and rd_en_signal ='0' then --and counter_en='1' ???
186                fifo_counter <= fifo_counter +1;
187          end if;
188         if rd_en_signal ='1' and wr_en_signal ='0' then
189                fifo_counter <= fifo_counter - 1;       
190         end if;
191  end if;
192 end if;
193end process;
194
195end Behavioral;
196
Note: See TracBrowser for help on using the repository browser.