source: PROJECT_CORE_MPI/MPI_HCL/BRANCHES/v2.1/NOC/SCHEDULER4_4.VHD.bak @ 143

Last change on this file since 143 was 143, checked in by rolagamo, 10 years ago
File size: 13.0 KB
Line 
1---------------------------------------------------------------------------------
2-- Company:
3-- Engineer: KIEGAING EMMANUEL GEL EN 5
4--
5-- Create Date:    03:56:34 05/06/2011
6-- Design Name:
7-- Module Name:    Sheduler - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description: Module de l'ordonnanceur du switch crossbar
12-- l'algorithme utilisée est le DPA (diagonal propagation arbiter)
13--
14-- Dependencies:
15--
16-- Revision:
17-- Revision 0.01 - File Created
18-- Additional Comments:
19--
20----------------------------------------------------------------------------------
21library IEEE;
22use IEEE.STD_LOGIC_1164.ALL;
23use IEEE.STD_LOGIC_ARITH.ALL;
24use IEEE.STD_LOGIC_UNSIGNED.ALL;
25--use Work.Sheduler_package.all;
26
27---- Uncomment the following library declaration if instantiating
28---- any Xilinx primitives in this code.
29--library UNISIM;
30--use UNISIM.VComponents.all;
31entity Scheduler4_4 is
32    Port ( Req : in  STD_LOGIC_VECTOR (16 downto 1);
33                   Fifo_full : in STD_LOGIC_VECTOR (4 downto 1);
34           clk : in  STD_LOGIC;
35           reset : in  STD_LOGIC;
36            priority_rotation : in  STD_LOGIC_VECTOR (4 downto 1);
37           port_grant : out  STD_LOGIC_VECTOR (16 downto 1));
38end Scheduler4_4;
39
40architecture Behavioral of Scheduler4_4 is
41--déclaration de constantes
42Constant NB_IO : positive:=4; --le nombre de ports d'entrée/sortie
43--Declaration du types
44--tableau de signaux de connexion des cellules arbitres
45TYPE C_Bar_Signal_Array IS ARRAY(7 downto 1) of STD_LOGIC_VECTOR(NB_IO downto 1);
46-- declaration du composant cellule d'arbitrage
47Component Arbiter
48  PORT (P, Fifo_full,Request, West,North : in  STD_LOGIC;
49        Grant,East,South : out  STD_LOGIC );
50End Component;--Signaux de connexion des cellues
51
52constant NB_IO2 :positive:=NB_IO**2; -- le carré du nombre de ports d'E/S
53
54SIGNAL south_2_north :  C_Bar_Signal_Array; -- connexion south north
55SIGNAL east_2_west   :  C_Bar_Signal_Array; -- connexion east west
56SIGNAL Signal_mask      : C_Bar_Signal_Array;-- connexion des masques de priorité
57SIGNAL Signal_grant     : C_Bar_Signal_Array;-- connexion des signaux de validation
58SIGNAL Signal_priority  : STD_LOGIC_VECTOR (7 DOWNTO 1);--signal pour la connection des vecteur de priorité
59SIGNAL High         : std_logic;--niveau pour les cellules des extremités nord et ouest
60 signal grant_latch : std_logic_vector(NB_IO2 downto 1);
61 signal priority_rotation_en : std_logic;
62signal Grant,request,req_grant,Grant_bak :  std_logic_vector(NB_IO2 downto 1):=(others=>'0');
63 signal Mreq :  std_logic_vector(NB_IO2 downto 1):=(others=>'1');
64
65 begin
66
67--validation de la rotation de priorité lorsque aucun port n'emet
68 req_grant<=(req and grant );
69 priority_rotation_en <= '1' when   unsigned(priority_rotation) = 2**NB_IO-1 else       '0';
70request<=req and mreq;
71--latch  qui memorise le signal grant pendant la transmission
72grant_latch_process : process(clk)
73  begin
74  if rising_edge(clk) then
75   if reset = '1' then
76                grant_latch <= (others => '0');
77                Fifo_out_full<=(others => '0');
78         elsif priority_rotation_en = '1' or unsigned(req_grant)=0 then
79           grant_latch <= Grant;
80           Fifo_out_full<=fifo_full;
81  else
82         grant_latch <= Grant;
83         Fifo_out_full<=fifo_full;
84   end if;
85   end if;
86
87 end process;
88 def_mreq: process(grant_latch,fifo_full)
89
90variable t:std_logic_vector(NB_IO2 downto 1):=(others=>'0');
91begin
92   
93  for i in 0 to NB_IO2-1 loop
94    t(i+1):='0';
95    --sur le front montant de fifo_full sauver l'état Grant courant
96    if fifo_full(i mod NB_IO+1)='1' and  fifo_out_full(i mod NB_IO+1)='0' then
97      Grant_bak(i+1)<= grant_latch(i+1);
98    elsif fifo_full(i mod NB_IO+1)='0' and  fifo_out_full(i mod NB_IO+1)='0'  then
99      Grant_bak(i+1)<='0';
100    end if;
101  for j in 0 to NB_IO-1 loop
102    t(i+1):=t(i+1) or grant_latch(j*NB_IO+1+i mod NB_IO) or fifo_out_full(i mod NB_IO+1);
103   
104  end loop;
105      mreq(i+1)<=not(t(i+1) ) or grant_latch(i+1)or grant_bak(i+1);   
106  end loop;
107end process;
108 port_grant <=  grant;
109 Grant(1)  <= Signal_grant(1)(1) or Signal_grant(5)(1); --  Grant(1,1)
110Grant(2)  <= Signal_grant(2)(2) or Signal_grant(6)(2); --  Grant(1,2)
111Grant(3)  <= Signal_grant(3)(3) or Signal_grant(7)(3); --  Grant(1,3)
112Grant(4)  <= Signal_grant(4)(4) ;                      --  Grant(1,4)
113Grant(5)  <= Signal_grant(2)(1) or Signal_grant(6)(1); --  Grant(2,1)
114Grant(6)  <= Signal_grant(3)(2) or Signal_grant(7)(2); --  Grant(2,2)
115Grant(7)  <= Signal_grant(4)(3) ;                      --  Grant(2,3)
116Grant(8)  <= Signal_grant(1)(4) or Signal_grant(5)(4); --  Grant(2,4)
117Grant(9)  <= Signal_grant(3)(1) or Signal_grant(7)(1); --  Grant(3,1)
118Grant(10)  <= Signal_grant(4)(2) ;                      --  Grant(3,2)
119Grant(11)  <= Signal_grant(1)(3) or Signal_grant(5)(3); --  Grant(3,3)
120Grant(12)  <= Signal_grant(2)(4) or Signal_grant(6)(4); --  Grant(3,4)
121Grant(13)  <= Signal_grant(4)(1) ;                      --  Grant(4,1)
122Grant(14)  <= Signal_grant(1)(2) or Signal_grant(5)(2); --  Grant(4,2)
123Grant(15)  <= Signal_grant(2)(3) or Signal_grant(6)(3); --  Grant(4,3)
124Grant(16)  <= Signal_grant(3)(4) or Signal_grant(7)(4); --  Grant(4,4)
125High <= '1';
126
127----instantiations des cellules arbitres et interconnection
128
129-------------------------- Diagonale n° 1
130
131
132Arbiter_1_1 : Arbiter
133
134PORT MAP (Request => Request(1), North => High, West => High, P => Signal_priority(7), Fifo_full => Fifo_full(1), 
135South => south_2_north(1)(1), East => east_2_west(1)(1) , Grant => Signal_grant(1)(1));
136
137Arbiter_1_2 : Arbiter
138
139PORT MAP (Request => Request(14), North => High, West => High, P => Signal_priority(7), Fifo_full => Fifo_full(2), 
140South => south_2_north(1)(2), East => east_2_west(1)(2) , Grant => Signal_grant(1)(2));
141
142Arbiter_1_3 : Arbiter
143
144PORT MAP (Request => Request(11), North => High, West => High, P => Signal_priority(7), Fifo_full => Fifo_full(3), 
145South => south_2_north(1)(3), East => east_2_west(1)(3) , Grant => Signal_grant(1)(3));
146
147Arbiter_1_4 : Arbiter
148
149PORT MAP (Request => Request(8), North => High, West => High, P => Signal_priority(7), Fifo_full => Fifo_full(4), 
150South => south_2_north(1)(4), East => east_2_west(1)(4) , Grant => Signal_grant(1)(4));
151
152-------------------------- Diagonale n° 2
153
154
155Arbiter_2_1 : Arbiter
156
157PORT MAP (Request => Request(5), North => south_2_north(1)(1), West => east_2_west(1)(4), P => Signal_priority(6), Fifo_full => Fifo_full(1), 
158South => south_2_north(2)(1), East => east_2_west(2)(1) , Grant => Signal_grant(2)(1));
159
160Arbiter_2_2 : Arbiter
161
162PORT MAP (Request => Request(2), North => south_2_north(1)(2), West => east_2_west(1)(1), P => Signal_priority(6), Fifo_full => Fifo_full(2), 
163South => south_2_north(2)(2), East => east_2_west(2)(2) , Grant => Signal_grant(2)(2));
164
165Arbiter_2_3 : Arbiter
166
167PORT MAP (Request => Request(15), North => south_2_north(1)(3), West => east_2_west(1)(2), P => Signal_priority(6), Fifo_full => Fifo_full(3), 
168South => south_2_north(2)(3), East => east_2_west(2)(3) , Grant => Signal_grant(2)(3));
169
170Arbiter_2_4 : Arbiter
171
172PORT MAP (Request => Request(12), North => south_2_north(1)(4), West => east_2_west(1)(3), P => Signal_priority(6), Fifo_full => Fifo_full(4), 
173South => south_2_north(2)(4), East => east_2_west(2)(4) , Grant => Signal_grant(2)(4));
174
175-------------------------- Diagonale n° 3
176
177
178Arbiter_3_1 : Arbiter
179
180PORT MAP (Request => Request(9), North => south_2_north(2)(1), West => east_2_west(2)(4), P => Signal_priority(5), Fifo_full => Fifo_full(1), 
181South => south_2_north(3)(1), East => east_2_west(3)(1) , Grant => Signal_grant(3)(1));
182
183Arbiter_3_2 : Arbiter
184
185PORT MAP (Request => Request(6), North => south_2_north(2)(2), West => east_2_west(2)(1), P => Signal_priority(5), Fifo_full => Fifo_full(2), 
186South => south_2_north(3)(2), East => east_2_west(3)(2) , Grant => Signal_grant(3)(2));
187
188Arbiter_3_3 : Arbiter
189
190PORT MAP (Request => Request(3), North => south_2_north(2)(3), West => east_2_west(2)(2), P => Signal_priority(5), Fifo_full => Fifo_full(3), 
191South => south_2_north(3)(3), East => east_2_west(3)(3) , Grant => Signal_grant(3)(3));
192
193Arbiter_3_4 : Arbiter
194
195PORT MAP (Request => Request(16), North => south_2_north(2)(4), West => east_2_west(2)(3), P => Signal_priority(5), Fifo_full => Fifo_full(4), 
196South => south_2_north(3)(4), East => east_2_west(3)(4) , Grant => Signal_grant(3)(4));
197
198-------------------------- Diagonale n° 4
199
200
201Arbiter_4_1 : Arbiter
202
203PORT MAP (Request => Request(13), North => south_2_north(3)(1), West => east_2_west(3)(4), P => Signal_priority(4), Fifo_full => Fifo_full(1), 
204South => south_2_north(4)(1), East => east_2_west(4)(1) , Grant => Signal_grant(4)(1));
205
206Arbiter_4_2 : Arbiter
207
208PORT MAP (Request => Request(10), North => south_2_north(3)(2), West => east_2_west(3)(1), P => Signal_priority(4), Fifo_full => Fifo_full(2), 
209South => south_2_north(4)(2), East => east_2_west(4)(2) , Grant => Signal_grant(4)(2));
210
211Arbiter_4_3 : Arbiter
212
213PORT MAP (Request => Request(7), North => south_2_north(3)(3), West => east_2_west(3)(2), P => Signal_priority(4), Fifo_full => Fifo_full(3), 
214South => south_2_north(4)(3), East => east_2_west(4)(3) , Grant => Signal_grant(4)(3));
215
216Arbiter_4_4 : Arbiter
217
218PORT MAP (Request => Request(4), North => south_2_north(3)(4), West => east_2_west(3)(3), P => Signal_priority(4), Fifo_full => Fifo_full(4), 
219South => south_2_north(4)(4), East => east_2_west(4)(4) , Grant => Signal_grant(4)(4));
220
221-------------------------- Diagonale n° 5
222
223
224Arbiter_5_1 : Arbiter
225
226PORT MAP (Request => Request(1), North => south_2_north(4)(1), West => east_2_west(4)(4), P => Signal_priority(3), Fifo_full => Fifo_full(1), 
227South => south_2_north(5)(1), East => east_2_west(5)(1) , Grant => Signal_grant(5)(1));
228
229Arbiter_5_2 : Arbiter
230
231PORT MAP (Request => Request(14), North => south_2_north(4)(2), West => east_2_west(4)(1), P => Signal_priority(3), Fifo_full => Fifo_full(2), 
232South => south_2_north(5)(2), East => east_2_west(5)(2) , Grant => Signal_grant(5)(2));
233
234Arbiter_5_3 : Arbiter
235
236PORT MAP (Request => Request(11), North => south_2_north(4)(3), West => east_2_west(4)(2), P => Signal_priority(3), Fifo_full => Fifo_full(3), 
237South => south_2_north(5)(3), East => east_2_west(5)(3) , Grant => Signal_grant(5)(3));
238
239Arbiter_5_4 : Arbiter
240
241PORT MAP (Request => Request(8), North => south_2_north(4)(4), West => east_2_west(4)(3), P => Signal_priority(3), Fifo_full => Fifo_full(4), 
242South => south_2_north(5)(4), East => east_2_west(5)(4) , Grant => Signal_grant(5)(4));
243
244-------------------------- Diagonale n° 6
245
246
247Arbiter_6_1 : Arbiter
248
249PORT MAP (Request => Request(5), North => south_2_north(5)(1), West => east_2_west(5)(4), P => Signal_priority(2), Fifo_full => Fifo_full(1), 
250South => south_2_north(6)(1), East => east_2_west(6)(1) , Grant => Signal_grant(6)(1));
251
252Arbiter_6_2 : Arbiter
253
254PORT MAP (Request => Request(2), North => south_2_north(5)(2), West => east_2_west(5)(1), P => Signal_priority(2), Fifo_full => Fifo_full(2), 
255South => south_2_north(6)(2), East => east_2_west(6)(2) , Grant => Signal_grant(6)(2));
256
257Arbiter_6_3 : Arbiter
258
259PORT MAP (Request => Request(15), North => south_2_north(5)(3), West => east_2_west(5)(2), P => Signal_priority(2), Fifo_full => Fifo_full(3), 
260South => south_2_north(6)(3), East => east_2_west(6)(3) , Grant => Signal_grant(6)(3));
261
262Arbiter_6_4 : Arbiter
263
264PORT MAP (Request => Request(12), North => south_2_north(5)(4), West => east_2_west(5)(3), P => Signal_priority(2), Fifo_full => Fifo_full(4), 
265South => south_2_north(6)(4), East => east_2_west(6)(4) , Grant => Signal_grant(6)(4));
266
267-------------------------- Diagonale n° 7
268
269
270Arbiter_7_1 : Arbiter
271
272PORT MAP (Request => Request(9), North => south_2_north(6)(1), West => east_2_west(6)(4), P => Signal_priority(1), Fifo_full => Fifo_full(1), 
273South => south_2_north(7)(1), East => east_2_west(7)(1) , Grant => Signal_grant(7)(1));
274
275Arbiter_7_2 : Arbiter
276
277PORT MAP (Request => Request(6), North => south_2_north(6)(2), West => east_2_west(6)(1), P => Signal_priority(1), Fifo_full => Fifo_full(2), 
278South => south_2_north(7)(2), East => east_2_west(7)(2) , Grant => Signal_grant(7)(2));
279
280Arbiter_7_3 : Arbiter
281
282PORT MAP (Request => Request(3), North => south_2_north(6)(3), West => east_2_west(6)(2), P => Signal_priority(1), Fifo_full => Fifo_full(3), 
283South => south_2_north(7)(3), East => east_2_west(7)(3) , Grant => Signal_grant(7)(3));
284
285Arbiter_7_4 : Arbiter
286
287PORT MAP (Request => Request(16), North => south_2_north(6)(4), West => east_2_west(6)(3), P => Signal_priority(1), Fifo_full => Fifo_full(4), 
288South => south_2_north(7)(4), East => east_2_west(7)(4) , Grant => Signal_grant(7)(4));
289
290
291--processus permettant de roter la priorité des diagonales à chaque front d'horloge
292 -- rotation round robin
293         round_robin : process(clk)
294        begin
295                if rising_edge(clk) then
296                 if reset ='1' then
297                    Signal_priority <= "1111000";
298                  elsif priority_rotation_en = '1' then
299                    case Signal_priority is
300                       when "1111000" => Signal_priority <= "0111100";
301                       when "0111100" => Signal_priority <= "0011110";
302                       when "0011110" => Signal_priority <= "0001111";
303                       when "0001111" => Signal_priority <= "1111000";
304                       when others    => Signal_priority <= "1111000";
305                  end case;
306                 end if;
307             end if;
308         end process;
309
310end Behavioral;
311
Note: See TracBrowser for help on using the repository browser.