[101] | 1 | ---------------------------------------------------------------------------------- |
---|
| 2 | -- Company: |
---|
| 3 | -- Engineer: KIEGAING EMMANUEL/GAMOM Roland CHristian |
---|
| 4 | -- |
---|
| 5 | -- Create Date: 03:47:50 04/24/2011 |
---|
| 6 | -- Design Name: |
---|
| 7 | -- Module Name: INPUT_PORT_MODULE - Behavioral |
---|
| 8 | -- Project Name: |
---|
| 9 | -- Target Devices: |
---|
| 10 | -- Tool versions: |
---|
| 11 | -- Description: |
---|
| 12 | -- Module de gestion des entrées des ports du switch crossbar |
---|
| 13 | -- il supose qu'une donnée est empilée à chaque cycle d'horloge |
---|
| 14 | -- Dependencies: |
---|
| 15 | -- FIFO_64_FWFT.vhd |
---|
| 16 | -- RAM_64.vhd |
---|
| 17 | -- Revision: 1 |
---|
| 18 | -- remplacement du fifo ordinaire par un fifo fwft |
---|
| 19 | -- Revision 1.01 - File Created |
---|
| 20 | -- Additional Comments: |
---|
| 21 | -- modifié le 14/05/20011 pour eviter une écriture multiple dans le FIFO de sortie |
---|
| 22 | -- si le FIFO d'entrée vient a se vider pendant le transfert d'un packet |
---|
| 23 | -- le machine a état on été re modeliser et sont maintenant du type FSMD |
---|
| 24 | -- remodéliation pour plus de vitesse |
---|
| 25 | --inclusion du signal priority rotation pour eviter la perte du grant pendant une transmission |
---|
| 26 | --02-08-2012 :Prise en compte du signal Port_Granted dans un process |
---|
| 27 | ---------------------------------------------------------------------------------- |
---|
| 28 | library IEEE; |
---|
| 29 | use IEEE.STD_LOGIC_1164.ALL; |
---|
| 30 | --use IEEE.STD_LOGIC_ARITH.ALL; |
---|
| 31 | use IEEE.STD_LOGIC_UNSIGNED.ALL; |
---|
| 32 | USE ieee.numeric_std.ALL; |
---|
| 33 | use work.Coretypes.all; |
---|
| 34 | ---- Uncomment the following library declaration if instantiating |
---|
| 35 | ---- any Xilinx primitives in this code. |
---|
| 36 | --library UNISIM; |
---|
| 37 | --use UNISIM.VComponents.all; |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | entity INPUT_PORT_MODULE is |
---|
| 41 | generic(number_of_ports : positive := 4; |
---|
[139] | 42 | adr_mask : natural := 0;--le nombre de'1' en partant le la gauche de l'adresse |
---|
| 43 | adr_len: positive:=10; --la taille en bit de l'adresse 10 bits --> 1024 hotes |
---|
| 44 | tot_ports: positive :=8; --Nomnre de ports total du réseau |
---|
| 45 | adr_sub_net : std_logic_vector(9 downto 0) := (others=>'0');--l'adresse du sous-réseau |
---|
| 46 | Port_num: natural:=1; -- port_num est l'id du port |
---|
| 47 | nbyte : positive:=2); -- le nombre de Byte dans chaque mot du port par défaut 2 |
---|
[101] | 48 | Port ( data_in : in STD_LOGIC_VECTOR (Word-1 downto 0); |
---|
| 49 | data_in_en : in STD_LOGIC; -- signaler la présence des données en entrée |
---|
| 50 | cmd_in_en :in STD_LOGIC; --permet d'identifier les données qui sont dans le tampon |
---|
| 51 | reset : in STD_LOGIC; |
---|
| 52 | clk : in STD_LOGIC; |
---|
| 53 | request : out STD_LOGIC_VECTOR (number_of_ports downto 1); --demande de canal de transmission |
---|
| 54 | grant : in STD_LOGIC_VECTOR (number_of_ports downto 1); -- autorisation de transmission |
---|
| 55 | fifo_full : out STD_LOGIC; -- signaler que les données ne peuvent plus être acceptées en entrée |
---|
| 56 | fifo_empty : out STD_LOGIC; -- le tampon d'entrée est vide |
---|
| 57 | priority_rotation : out std_logic; -- reserver le canal de transmission |
---|
[139] | 58 | data_out : out STD_LOGIC_VECTOR (7 downto 0); --données vers le réseau crossbar |
---|
[101] | 59 | data_out_pulse : out std_logic); -- permet de ... |
---|
| 60 | |
---|
| 61 | end INPUT_PORT_MODULE; |
---|
| 62 | |
---|
| 63 | architecture Behavioral of INPUT_PORT_MODULE is |
---|
| 64 | |
---|
| 65 | -- declaration du fifo 64 octet utilisé pour chaque port |
---|
| 66 | component FIFO_256_FWFT |
---|
| 67 | port ( |
---|
| 68 | clk: IN std_logic; |
---|
| 69 | din: IN std_logic_VECTOR(Word-1 downto 0); |
---|
| 70 | rd_en: IN std_logic; |
---|
| 71 | srst: IN std_logic; |
---|
| 72 | wr_en: IN std_logic; |
---|
| 73 | dout: OUT std_logic_VECTOR(Word-1 downto 0); |
---|
| 74 | empty: OUT std_logic; |
---|
| 75 | full: OUT std_logic); |
---|
| 76 | end component; |
---|
| 77 | |
---|
| 78 | --definition du type etat pour les fsm |
---|
[139] | 79 | type fsm_states is (state0, CmdOn, WaitGrant, ReqPort,addhead,addheadn, state1,state1n, state2,state2n,strecover,stpulse,stpulsen,stateErr, state3);-- definition du type etat pour le codage des etats des fsm |
---|
| 80 | type fsm_states2 is(cmdstart,cmdwait,cmdread,cmdSetDest,cmdSetCount,cmdSetId,cmdSetDestn,cmdSetCountn,cmdSetIdn,cmdpulse,cmdpulsen,CmdEnd); |
---|
[101] | 81 | signal pop_state : fsm_states; |
---|
| 82 | signal cmdstate : fsm_states2; |
---|
| 83 | signal cmd_exec : std_logic:='0'; --indique que le port est en train d'exécuter une commande |
---|
| 84 | signal dat_exec :std_logic:='0'; -- indique le port est en train de transférer des données |
---|
| 85 | signal dat_Err :std_logic:='0'; -- signal une erreur pendant l'exécution |
---|
| 86 | signal wrok,readOk,CmdReadOk : std_logic:='0'; --indique s'il est possible de lire les données |
---|
[139] | 87 | -- |
---|
| 88 | signal rt_err : std_logic;--erreur sur la route |
---|
| 89 | signal route :std_logic_vector(9 downto 0); |
---|
| 90 | signal dest_port:std_logic_vector(Word/2-1 downto 0); |
---|
| 91 | signal nib,cnib:natural range 0 to 4:=1;--indique le sous-octet à traiter |
---|
| 92 | signal pulseOn :std_logic:='0';--indique que le prochain état est celui de l'impulsion |
---|
[101] | 93 | -- signaux utilisés dans les fsm |
---|
| 94 | signal request_decoder,req_grant : STD_LOGIC_VECTOR(number_of_ports downto 1); |
---|
| 95 | signal request_decoder_en : std_logic; |
---|
| 96 | signal request_latch : STD_LOGIC_VECTOR(4 downto 1):=(others=>'0'); -- pourquoi pas 3 downto 0 ? |
---|
| 97 | signal request_latch_en : std_logic; |
---|
[139] | 98 | signal pipeline_latch : std_logic_vector(7 downto 0); |
---|
[101] | 99 | signal pipeline_latch_en : std_logic; |
---|
| 100 | signal request_word : std_logic_vector(5 downto 1); |
---|
| 101 | signal port_granted : std_logic; |
---|
| 102 | signal rd_en_signal : std_logic; |
---|
| 103 | --signaux utilisés dans la MAE de gestion des commandes |
---|
| 104 | signal cmd_request_latch_en :std_logic; |
---|
| 105 | signal cmd_pipeline_latch_en :std_logic; |
---|
| 106 | signal cmd_fifo_read_signal :std_logic; |
---|
| 107 | signal cmd_request_decoder_en :std_logic; |
---|
| 108 | signal cmd_data_out_pulse :std_logic; |
---|
| 109 | signal cmd_priority_rotation :std_logic; |
---|
| 110 | --signaux utilisés dans la MAE de transfert des données |
---|
| 111 | signal dat_request_latch_en :std_logic; |
---|
| 112 | signal dat_pipeline_latch_en :std_logic; |
---|
| 113 | signal dat_fifo_read_signal :std_logic; |
---|
| 114 | signal dat_request_decoder_en :std_logic; |
---|
| 115 | signal dat_data_out_pulse :std_logic; |
---|
| 116 | signal dat_priority_rotation :std_logic; |
---|
| 117 | -- signaux utilisés pour les connections entre composants |
---|
| 118 | signal clk_signal : std_logic; |
---|
| 119 | signal reset_signal : std_logic; |
---|
| 120 | signal fifo_empty_signal : std_logic; |
---|
| 121 | signal fifo_read_signal : std_logic; |
---|
[139] | 122 | signal fifo_out_signal,fifo_out2,cmd_data_signal : std_logic_vector(Word-1 downto 0); |
---|
| 123 | signal push_dout : std_logic_vector(7 downto 0); |
---|
[101] | 124 | signal empty_latch : std_logic ; |
---|
[139] | 125 | |
---|
[101] | 126 | -- signaux du compteur de données |
---|
| 127 | signal data_counter : std_logic_vector(Word-1 downto 0); |
---|
| 128 | |
---|
[139] | 129 | function count_bits(param:natural) return natural is |
---|
| 130 | |
---|
| 131 | variable p : natural range 0 to 127:=0; |
---|
[101] | 132 | begin |
---|
[139] | 133 | n1: for i in 0 to 127 loop |
---|
| 134 | if param<=2**i then |
---|
| 135 | p:=i; |
---|
| 136 | exit n1; |
---|
| 137 | end if; |
---|
| 138 | end loop n1; |
---|
| 139 | return p; |
---|
| 140 | end function; |
---|
| 141 | |
---|
| 142 | function Get_Port_ID(adr_sub_net:std_logic_vector;adr_mask:natural;n_ports:positive;numport:positive) return std_logic_vector is |
---|
| 143 | --cette fonction permet de calculer le port_id ou l'adresse de sous réseau en fonction du masque |
---|
| 144 | variable tport_id:std_logic_vector(adr_len-1 downto 0):=(others=>'0'); -- |
---|
| 145 | variable p : natural range 0 to 9:=0; |
---|
| 146 | begin |
---|
| 147 | --n1: for i in 0 to 9 loop |
---|
| 148 | -- if n_ports-1<2**i then |
---|
| 149 | -- p:=i; |
---|
| 150 | -- exit n1; |
---|
| 151 | -- end if; |
---|
| 152 | -- end loop n1; |
---|
| 153 | p:=count_bits(n_ports-1); |
---|
| 154 | tport_id:=adr_sub_net(adr_len-1 downto p) & std_logic_vector(to_unsigned(numport-1,p)); |
---|
| 155 | return tport_id; |
---|
| 156 | end function; |
---|
| 157 | --case n_ports is |
---|
| 158 | --when 1|2|3 =>tport_id(adr_len-1 downto adr_len-adr_mask-1):=adr_sub_net(adr_len-1 downto adr_len-adr_mask-1); |
---|
| 159 | --tport_id(adr_len-adr_mask-2 downto adr_len-adr_mask-2):= std_logic_vector(to_unsigned(numport,1)); |
---|
| 160 | --when 4|5 =>tport_id(adr_len-1 downto adr_len-adr_mask-1):=adr_sub_net(adr_len-1 downto adr_len-adr_mask-1); |
---|
| 161 | --tport_id(adr_len-adr_mask-2 downto adr_len-adr_mask-3):= std_logic_vector(to_unsigned(numport,2)); |
---|
| 162 | --when 6|9 =>tport_id(adr_len-1 downto adr_len-adr_mask-1):=adr_sub_net(adr_len-1 downto adr_len-adr_mask-1); |
---|
| 163 | --tport_id(adr_len-adr_mask-2 downto adr_len-adr_mask-4):= std_logic_vector(to_unsigned(numport,3)); |
---|
| 164 | -- |
---|
| 165 | --when others => --10 to 16 |
---|
| 166 | --tport_id(adr_len-1 downto adr_len-adr_mask-1):=adr_sub_net(adr_len-1 downto adr_len-adr_mask-1) ; |
---|
| 167 | --tport_id(adr_len-adr_mask-2 downto adr_len-adr_mask-5):= std_logic_vector(to_unsigned(numport,4)); |
---|
| 168 | -- |
---|
| 169 | --end case; |
---|
| 170 | -- return tport_id; |
---|
| 171 | --end function; |
---|
| 172 | signal PORT_ID :std_logic_vector(adr_len-1 downto 0):=GET_PORT_ID(adr_sub_net,adr_mask,number_of_ports,port_num); |
---|
| 173 | constant n_ports_bits:natural:=count_bits(number_of_ports-1);--compte le nombre de bit par port |
---|
| 174 | constant pid_bits:natural:=count_bits(tot_ports); --donne le nombre de bits utiles dans une adresse |
---|
| 175 | begin |
---|
[101] | 176 | -- instantiation du FIFO_256 |
---|
| 177 | INPUT_PORT_FIFO : FIFO_256_FWFT |
---|
| 178 | port map ( |
---|
| 179 | clk => clk_signal, |
---|
| 180 | din => data_in, |
---|
| 181 | rd_en => fifo_read_signal, |
---|
| 182 | srst => reset_signal, |
---|
| 183 | wr_en => data_in_en, |
---|
| 184 | dout => fifo_out_signal, |
---|
| 185 | empty => fifo_empty_signal, |
---|
| 186 | full => fifo_full); |
---|
| 187 | -- connections avec les ports de l'entité |
---|
| 188 | |
---|
| 189 | data_out <= pipeline_latch ;--when cmd_exec='0' else cmd_data_signal; |
---|
| 190 | fifo_empty <= empty_latch; |
---|
| 191 | reset_signal <= reset; |
---|
| 192 | grant_proc:process(req_grant) |
---|
| 193 | begin |
---|
| 194 | --if rising_edge(clk) then |
---|
| 195 | -- if unsigned(grant)> 0 then |
---|
| 196 | if unsigned(req_grant) > 0 then |
---|
| 197 | port_granted <= '1'; --il faut veiller à ce que ce port soit vraiment autorisé |
---|
| 198 | else |
---|
| 199 | Port_granted<='0'; --ceci présuppose que la valeur qu'il reçoit est forcément la sienne |
---|
| 200 | end if; |
---|
| 201 | --end if; |
---|
| 202 | end process; |
---|
[139] | 203 | rd_en_signal <= not(fifo_empty_signal);--not(empty_latch) ; |
---|
[101] | 204 | request <= request_decoder; |
---|
| 205 | reg_grant:process (request_decoder,grant) |
---|
| 206 | begin |
---|
| 207 | req_grant<=request_decoder and grant; |
---|
| 208 | end process reg_grant; |
---|
| 209 | request_word <= request_latch & request_decoder_en; |
---|
| 210 | clk_signal <= clk; |
---|
| 211 | |
---|
| 212 | |
---|
| 213 | |
---|
| 214 | WITH cmd_exec SELECT |
---|
| 215 | request_latch_en <= dat_request_latch_en WHEN '0', |
---|
| 216 | cmd_request_latch_en WHEN others; |
---|
| 217 | |
---|
| 218 | WITH cmd_exec SELECT |
---|
| 219 | pipeline_latch_en <= dat_pipeline_latch_en WHEN '0', |
---|
| 220 | cmd_pipeline_latch_en WHEN others; |
---|
| 221 | |
---|
| 222 | WITH cmd_exec SELECT |
---|
| 223 | fifo_read_signal <=dat_fifo_read_signal WHEN '0', |
---|
| 224 | |
---|
| 225 | cmd_fifo_read_signal WHEN others; |
---|
| 226 | WITH cmd_exec SELECT |
---|
| 227 | request_decoder_en <=dat_request_decoder_en WHEN '0', |
---|
| 228 | cmd_request_decoder_en WHEN others; |
---|
| 229 | WITH cmd_exec SELECT |
---|
| 230 | data_out_pulse <=dat_data_out_pulse WHEN '0', |
---|
| 231 | cmd_data_out_pulse WHEN others; |
---|
| 232 | WITH cmd_exec SELECT |
---|
| 233 | priority_rotation<=dat_priority_rotation WHEN '0', |
---|
| 234 | cmd_priority_rotation WHEN others; |
---|
| 235 | |
---|
| 236 | |
---|
| 237 | --processus permettant de latcher le signal empty |
---|
| 238 | -- evite une perte de données en cas d'arret au cours d'une transmission |
---|
| 239 | empty_latch_process : process(clk) |
---|
| 240 | begin |
---|
| 241 | if rising_edge(clk) then |
---|
| 242 | if reset_signal = '1' then |
---|
| 243 | empty_latch <= '1'; |
---|
| 244 | else |
---|
| 245 | empty_latch <= fifo_empty_signal; |
---|
| 246 | end if; |
---|
| 247 | end if; |
---|
| 248 | |
---|
| 249 | end process; |
---|
| 250 | -- decodeur de requete en fonction de l'adresse destination |
---|
| 251 | -- le circuit genere depend du parametre generique nombre de ports |
---|
| 252 | -- switch 2 ports |
---|
| 253 | switch2x2 : if number_of_ports = 2 generate |
---|
| 254 | |
---|
| 255 | with request_word select |
---|
| 256 | request_decoder <="01" when "00001", |
---|
| 257 | "10" when "00011", |
---|
| 258 | "00" when others; |
---|
| 259 | |
---|
| 260 | end generate switch2x2; |
---|
| 261 | |
---|
| 262 | |
---|
| 263 | -- switch 3 ports |
---|
| 264 | switch3x3 : if number_of_ports = 3 generate |
---|
| 265 | |
---|
| 266 | with request_word select |
---|
| 267 | request_decoder <="001" when "00001", |
---|
| 268 | "010" when "00011", |
---|
| 269 | "100" when "00101", |
---|
| 270 | "000" when others; |
---|
| 271 | |
---|
| 272 | end generate switch3x3; |
---|
| 273 | |
---|
| 274 | |
---|
| 275 | -- switch 4 ports |
---|
| 276 | switch4x4 : if number_of_ports = 4 generate |
---|
| 277 | |
---|
| 278 | with request_word select |
---|
| 279 | request_decoder <="0001" when "00001", |
---|
| 280 | "0010" when "00011", |
---|
| 281 | "0100" when "00101", |
---|
| 282 | "1000" when "00111", |
---|
| 283 | "0000" when others; |
---|
| 284 | |
---|
| 285 | end generate switch4x4; |
---|
| 286 | |
---|
| 287 | |
---|
| 288 | -- switch 5 ports |
---|
| 289 | switch5x5 : if number_of_ports = 5 generate |
---|
| 290 | |
---|
| 291 | with request_word select |
---|
| 292 | request_decoder <="00001" when "00001", |
---|
| 293 | "00010" when "00011", |
---|
| 294 | "00100" when "00101", |
---|
| 295 | "01000" when "00111", |
---|
| 296 | "10000" when "01001", |
---|
| 297 | "00000" when others; |
---|
| 298 | |
---|
| 299 | end generate switch5x5; |
---|
| 300 | |
---|
| 301 | |
---|
| 302 | -- switch 6 ports |
---|
| 303 | switch6x6 : if number_of_ports = 6 generate |
---|
| 304 | |
---|
| 305 | with request_word select |
---|
| 306 | request_decoder <="000001" when "00001", |
---|
| 307 | "000010" when "00011", |
---|
| 308 | "000100" when "00101", |
---|
| 309 | "001000" when "00111", |
---|
| 310 | "010000" when "01001", |
---|
| 311 | "100000" when "01011", |
---|
| 312 | "000000" when others; |
---|
| 313 | |
---|
| 314 | end generate switch6x6; |
---|
| 315 | |
---|
| 316 | |
---|
| 317 | -- switch 7 ports |
---|
| 318 | switch7x7 : if number_of_ports = 7 generate |
---|
| 319 | |
---|
| 320 | with request_word select |
---|
| 321 | request_decoder <="0000001" when "00001", |
---|
| 322 | "0000010" when "00011", |
---|
| 323 | "0000100" when "00101", |
---|
| 324 | "0001000" when "00111", |
---|
| 325 | "0010000" when "01001", |
---|
| 326 | "0100000" when "01011", |
---|
| 327 | "1000000" when "01101", |
---|
| 328 | "0000000" when others; |
---|
| 329 | |
---|
| 330 | end generate switch7x7; |
---|
| 331 | |
---|
| 332 | |
---|
| 333 | -- switch 8 ports |
---|
| 334 | switch8x8 : if number_of_ports = 8 generate |
---|
| 335 | |
---|
| 336 | with request_word select |
---|
| 337 | request_decoder <="00000001" when "00001", |
---|
| 338 | "00000010" when "00011", |
---|
| 339 | "00000100" when "00101", |
---|
| 340 | "00001000" when "00111", |
---|
| 341 | "00010000" when "01001", |
---|
| 342 | "00100000" when "01011", |
---|
| 343 | "01000000" when "01101", |
---|
| 344 | "10000000" when "01111", |
---|
| 345 | "00000000" when others; |
---|
| 346 | |
---|
| 347 | end generate switch8x8; |
---|
| 348 | |
---|
| 349 | |
---|
| 350 | -- switch 9 ports |
---|
| 351 | switch9x9 : if number_of_ports = 9 generate |
---|
| 352 | |
---|
| 353 | with request_word select |
---|
| 354 | request_decoder <="000000001" when "00001", |
---|
| 355 | "000000010" when "00011", |
---|
| 356 | "000000100" when "00101", |
---|
| 357 | "000001000" when "00111", |
---|
| 358 | "000010000" when "01001", |
---|
| 359 | "000100000" when "01011", |
---|
| 360 | "001000000" when "01101", |
---|
| 361 | "010000000" when "01111", |
---|
| 362 | "100000000" when "10001", |
---|
| 363 | "000000000" when others; |
---|
| 364 | |
---|
| 365 | end generate switch9x9; |
---|
| 366 | |
---|
| 367 | |
---|
| 368 | -- switch 10 ports |
---|
| 369 | switch10x10 : if number_of_ports = 10 generate |
---|
| 370 | |
---|
| 371 | with request_word select |
---|
| 372 | request_decoder <="0000000001" when "00001", |
---|
| 373 | "0000000010" when "00011", |
---|
| 374 | "0000000100" when "00101", |
---|
| 375 | "0000001000" when "00111", |
---|
| 376 | "0000010000" when "01001", |
---|
| 377 | "0000100000" when "01011", |
---|
| 378 | "0001000000" when "01101", |
---|
| 379 | "0010000000" when "01111", |
---|
| 380 | "0100000000" when "10001", |
---|
| 381 | "1000000000" when "10011", |
---|
| 382 | "0000000000" when others; |
---|
| 383 | |
---|
| 384 | end generate switch10x10; |
---|
| 385 | |
---|
| 386 | |
---|
| 387 | -- switch 11 ports |
---|
| 388 | switch11x11 : if number_of_ports = 11 generate |
---|
| 389 | |
---|
| 390 | with request_word select |
---|
| 391 | request_decoder <="00000000001" when "00001", |
---|
| 392 | "00000000010" when "00011", |
---|
| 393 | "00000000100" when "00101", |
---|
| 394 | "00000001000" when "00111", |
---|
| 395 | "00000010000" when "01001", |
---|
| 396 | "00000100000" when "01011", |
---|
| 397 | "00001000000" when "01101", |
---|
| 398 | "00010000000" when "01111", |
---|
| 399 | "00100000000" when "10001", |
---|
| 400 | "01000000000" when "10011", |
---|
| 401 | "10000000000" when "10101", |
---|
| 402 | "00000000000" when others; |
---|
| 403 | |
---|
| 404 | end generate switch11x11; |
---|
| 405 | |
---|
| 406 | |
---|
| 407 | -- switch 12 ports |
---|
| 408 | switch12x12 : if number_of_ports = 12 generate |
---|
| 409 | |
---|
| 410 | with request_word select |
---|
| 411 | request_decoder <="000000000001" when "00001", |
---|
| 412 | "000000000010" when "00011", |
---|
| 413 | "000000000100" when "00101", |
---|
| 414 | "000000001000" when "00111", |
---|
| 415 | "000000010000" when "01001", |
---|
| 416 | "000000100000" when "01011", |
---|
| 417 | "000001000000" when "01101", |
---|
| 418 | "000010000000" when "01111", |
---|
| 419 | "000100000000" when "10001", |
---|
| 420 | "001000000000" when "10011", |
---|
| 421 | "010000000000" when "10101", |
---|
| 422 | "100000000000" when "10111", |
---|
| 423 | "000000000000" when others; |
---|
| 424 | |
---|
| 425 | end generate switch12x12; |
---|
| 426 | |
---|
| 427 | |
---|
| 428 | -- switch 13 ports |
---|
| 429 | switch13x13 : if number_of_ports = 13 generate |
---|
| 430 | |
---|
| 431 | with request_word select |
---|
| 432 | request_decoder <="0000000000001" when "00001", |
---|
| 433 | "0000000000010" when "00011", |
---|
| 434 | "0000000000100" when "00101", |
---|
| 435 | "0000000001000" when "00111", |
---|
| 436 | "0000000010000" when "01001", |
---|
| 437 | "0000000100000" when "01011", |
---|
| 438 | "0000001000000" when "01101", |
---|
| 439 | "0000010000000" when "01111", |
---|
| 440 | "0000100000000" when "10001", |
---|
| 441 | "0001000000000" when "10011", |
---|
| 442 | "0010000000000" when "10101", |
---|
| 443 | "0100000000000" when "10111", |
---|
| 444 | "1000000000000" when "11001", |
---|
| 445 | "0000000000000" when others; |
---|
| 446 | |
---|
| 447 | end generate switch13x13; |
---|
| 448 | |
---|
| 449 | |
---|
| 450 | -- switch 14 ports |
---|
| 451 | switch14x14 : if number_of_ports = 14 generate |
---|
| 452 | |
---|
| 453 | with request_word select |
---|
| 454 | request_decoder <="00000000000001" when "00001", |
---|
| 455 | "00000000000010" when "00011", |
---|
| 456 | "00000000000100" when "00101", |
---|
| 457 | "00000000001000" when "00111", |
---|
| 458 | "00000000010000" when "01001", |
---|
| 459 | "00000000100000" when "01011", |
---|
| 460 | "00000001000000" when "01101", |
---|
| 461 | "00000010000000" when "01111", |
---|
| 462 | "00000100000000" when "10001", |
---|
| 463 | "00001000000000" when "10011", |
---|
| 464 | "00010000000000" when "10101", |
---|
| 465 | "00100000000000" when "10111", |
---|
| 466 | "01000000000000" when "11001", |
---|
| 467 | "10000000000000" when "11011", |
---|
| 468 | "00000000000000" when others; |
---|
| 469 | |
---|
| 470 | end generate switch14x14; |
---|
| 471 | |
---|
| 472 | |
---|
| 473 | -- switch 15 ports |
---|
| 474 | switch15x15 : if number_of_ports = 15 generate |
---|
| 475 | |
---|
| 476 | with request_word select |
---|
| 477 | request_decoder <="000000000000001" when "00001", |
---|
| 478 | "000000000000010" when "00011", |
---|
| 479 | "000000000000100" when "00101", |
---|
| 480 | "000000000001000" when "00111", |
---|
| 481 | "000000000010000" when "01001", |
---|
| 482 | "000000000100000" when "01011", |
---|
| 483 | "000000001000000" when "01101", |
---|
| 484 | "000000010000000" when "01111", |
---|
| 485 | "000000100000000" when "10001", |
---|
| 486 | "000001000000000" when "10011", |
---|
| 487 | "000010000000000" when "10101", |
---|
| 488 | "000100000000000" when "10111", |
---|
| 489 | "001000000000000" when "11001", |
---|
| 490 | "010000000000000" when "11011", |
---|
| 491 | "100000000000000" when "11101", |
---|
| 492 | "000000000000000" when others; |
---|
| 493 | |
---|
| 494 | end generate switch15x15; |
---|
| 495 | |
---|
| 496 | |
---|
| 497 | -- switch 16 ports |
---|
| 498 | switch16x16 : if number_of_ports = 16 generate |
---|
| 499 | |
---|
| 500 | with request_word select |
---|
| 501 | request_decoder <="0000000000000001" when "00001", |
---|
| 502 | "0000000000000010" when "00011", |
---|
| 503 | "0000000000000100" when "00101", |
---|
| 504 | "0000000000001000" when "00111", |
---|
| 505 | "0000000000010000" when "01001", |
---|
| 506 | "0000000000100000" when "01011", |
---|
| 507 | "0000000001000000" when "01101", |
---|
| 508 | "0000000010000000" when "01111", |
---|
| 509 | "0000000100000000" when "10001", |
---|
| 510 | "0000001000000000" when "10011", |
---|
| 511 | "0000010000000000" when "10101", |
---|
| 512 | "0000100000000000" when "10111", |
---|
| 513 | "0001000000000000" when "11001", |
---|
| 514 | "0010000000000000" when "11011", |
---|
| 515 | "0100000000000000" when "11101", |
---|
| 516 | "1000000000000000" when "11111", |
---|
| 517 | "0000000000000000" when others; |
---|
| 518 | |
---|
| 519 | end generate switch16x16; |
---|
| 520 | --latch du fifo de sortie ?? |
---|
| 521 | pipeline_latch_process : process(clk) |
---|
| 522 | begin |
---|
| 523 | if rising_edge(clk) then |
---|
| 524 | if reset_signal = '1' then |
---|
| 525 | pipeline_latch <= (others => '0'); |
---|
| 526 | elsif pipeline_latch_en = '1' and cmd_exec='0' then |
---|
| 527 | pipeline_latch <= push_dout; |
---|
| 528 | elsif pipeline_latch_en = '1' and cmd_exec='1' then |
---|
[139] | 529 | pipeline_latch <= cmd_data_signal(8*cnib-1 downto 8*(cnib-1)); |
---|
[101] | 530 | end if; |
---|
| 531 | end if; |
---|
| 532 | end process; |
---|
| 533 | |
---|
[139] | 534 | |
---|
[101] | 535 | --latch qui memorise l'adresse de destination du packet |
---|
| 536 | |
---|
| 537 | request_latch_process : process(clk) |
---|
[139] | 538 | variable rt:std_logic_vector(9 downto 0):=(others=>'0');--route |
---|
| 539 | variable reql:std_logic_vector(4 downto 1):=(others=>'0');--request_latch |
---|
| 540 | --variable adr_e,p:natural range 0 to 15:=0; |
---|
| 541 | |
---|
[101] | 542 | begin |
---|
| 543 | if rising_edge(clk) then |
---|
| 544 | if reset_signal = '1' then |
---|
[139] | 545 | reql := (others => '0'); |
---|
[101] | 546 | elsif request_latch_en = '1' and cmd_in_en='0' then --si la lecture de la destination est autorisée |
---|
[139] | 547 | rt:=(others=>'0'); |
---|
| 548 | |
---|
| 549 | if adr_mask=0 then |
---|
| 550 | reql(n_ports_bits downto 1):=fifo_out_signal(pid_bits-adr_mask-1 downto pid_bits-adr_mask-n_ports_bits); |
---|
| 551 | request_latch(n_ports_bits downto 1)<=fifo_out_signal(pid_bits-adr_mask-1 downto pid_bits-adr_mask-n_ports_bits); |
---|
| 552 | report "Route racine:"; |
---|
| 553 | else |
---|
| 554 | rt(pid_bits-1 downto pid_bits-adr_mask):=fifo_out_signal(pid_bits-1 downto pid_bits-adr_mask); |
---|
| 555 | if rt=adr_sub_net then |
---|
| 556 | report "Route trouvé:" & integer'image(to_integer(unsigned(rt))) & " adr_sub_net=" & integer'image(to_integer(unsigned(adr_sub_net))) & " fifo_out_sig:=" & image(fifo_out_signal) & " sur le port " & integer'image(to_integer(unsigned(port_id))+1); |
---|
| 557 | reql(n_ports_bits downto 1):=fifo_out_signal(pid_bits-adr_mask-1 downto pid_bits-adr_mask-n_ports_bits); |
---|
| 558 | request_latch(n_ports_bits downto 1)<=fifo_out_signal(pid_bits-adr_mask-1 downto pid_bits-adr_mask-n_ports_bits); |
---|
| 559 | |
---|
| 560 | else |
---|
| 561 | if number_of_ports=Port_num then --si c'est un paquet descendant alors le détruire |
---|
| 562 | report "Input_port_module n°" & integer'image(to_integer(unsigned(port_id))) & " La route sollicité n'existe pas dans ce sous réseau le paquet va être détruit ! fifo_out_sig:=" & image(fifo_out_signal); |
---|
| 563 | request_latch<="0000"; --à revoir il faut empêcher le routeur de se bloquer |
---|
| 564 | rt_err<='1'; --il faut activer la destruction du paquet |
---|
| 565 | else --faire monter les données vers le ports supérieur |
---|
| 566 | request_latch<=std_logic_vector(to_unsigned(number_of_ports-1,4)); |
---|
| 567 | reql:=std_logic_vector(to_unsigned(number_of_ports-1,4)); |
---|
| 568 | rt_err<='0'; |
---|
| 569 | end if; |
---|
| 570 | |
---|
| 571 | end if; |
---|
| 572 | end if; |
---|
| 573 | report "fifo_out=" & image(fifo_out_signal) & " pid_bits:=" & integer'image(pid_bits) & " adr_mask:=" & integer'image(adr_mask) & " rt:=" & image(rt) & " adr_sub_net=" & image(adr_sub_net) & " reql:=" & image(reql) & " sur le port " & integer'image(to_integer(unsigned(port_id))+1); |
---|
| 574 | |
---|
| 575 | assert (unsigned(reql)<number_of_ports-1) |
---|
| 576 | report "Input_port_module n° " & integer'image(port_num) & " Le port sollicité n'est pas dans la branche !" |
---|
| 577 | severity warning; |
---|
| 578 | elsif cmd_in_en='1' and request_latch_en='1' then --c'est une commande le port de dest est le même que le port d'entrée |
---|
[101] | 579 | request_latch<=Port_ID(3 downto 0); --car les ports commencent à 0 |
---|
| 580 | end if; |
---|
[139] | 581 | end if; |
---|
| 582 | --request_latch<=reql; |
---|
| 583 | route<=rt; --pour le débogage uniquement pas besoin de conserver ce paramètre en principe |
---|
| 584 | |
---|
| 585 | |
---|
[101] | 586 | end process; |
---|
| 587 | |
---|
| 588 | -- machine à etat de mealy qui depile les donnees dans le fifo |
---|
| 589 | -- |
---|
| 590 | -- processus determinant l'etat futur |
---|
| 591 | pop_fsm_nsl : process(clk) |
---|
| 592 | begin |
---|
| 593 | if rising_edge(clk) then |
---|
| 594 | if reset_signal = '1' then |
---|
| 595 | pop_state <= state0; |
---|
| 596 | data_counter <= (others => '0'); |
---|
| 597 | elsif cmd_exec='0' then --il ne faut pas exécuter cette MAE |
---|
| 598 | -- lorsque l'autre est en cours |
---|
| 599 | wrok<='0'; |
---|
| 600 | case pop_state is |
---|
| 601 | when state0 => if cmd_in_en='0' then --il ne faut pas exécuter les deux MAE ... |
---|
| 602 | if empty_latch ='0' then -- pile pas vide on doit dépiler |
---|
| 603 | pop_state <= WaitGrant; |
---|
| 604 | end if; |
---|
| 605 | else |
---|
| 606 | pop_state <= CmdOn; |
---|
| 607 | end if; |
---|
[139] | 608 | nib<=nbyte; |
---|
[101] | 609 | when CmdOn => if empty_latch='1' and cmd_in_en='0' then |
---|
| 610 | pop_state <= state0; |
---|
| 611 | elsif empty_latch='0' and cmd_in_en='1' then |
---|
| 612 | pop_state <= CmdOn; |
---|
| 613 | elsif empty_latch='1' and cmd_in_en='1' then |
---|
| 614 | pop_state <= state0; |
---|
| 615 | else -- empty_latch='0' and cmd_in_en='0' |
---|
| 616 | pop_state <= WaitGrant; |
---|
| 617 | end if; |
---|
| 618 | |
---|
| 619 | when WaitGrant => if port_granted = '1' then |
---|
| 620 | -- |
---|
| 621 | pop_state <= ReqPort; |
---|
| 622 | end if; |
---|
| 623 | |
---|
| 624 | when ReqPort => --if port_granted = '1' then |
---|
| 625 | -- |
---|
| 626 | pop_state <= state1; |
---|
[139] | 627 | fifo_out2<=fifo_out_signal; |
---|
[101] | 628 | --end if; |
---|
[139] | 629 | when addhead => |
---|
| 630 | pop_state <= addheadn; |
---|
| 631 | when addheadn => pop_state <= state1; |
---|
[101] | 632 | when state1 => if port_granted ='1' then --lecture de la longueur des données |
---|
| 633 | data_counter <= fifo_out_signal; |
---|
| 634 | if unsigned(fifo_out_signal)<=3 then |
---|
| 635 | ReadOk<='1'; |
---|
| 636 | else |
---|
| 637 | readOk<='1'; |
---|
| 638 | end if; |
---|
[139] | 639 | pop_state <= state1n; |
---|
| 640 | nib<=nib-1; |
---|
[101] | 641 | wrok<='1'; |
---|
| 642 | else |
---|
| 643 | wrok<='0'; |
---|
| 644 | end if; |
---|
[139] | 645 | |
---|
| 646 | when state1n => if nib=1 then |
---|
| 647 | pop_state <= state2; |
---|
| 648 | nib<=nbyte; |
---|
| 649 | else |
---|
| 650 | nib<=nib-1; |
---|
| 651 | end if; |
---|
| 652 | wrok<='1'; |
---|
| 653 | fifo_out2<=fifo_out_signal; |
---|
[101] | 654 | when state2 => if port_granted='1' then |
---|
| 655 | wrok<='1'; |
---|
| 656 | if fifo_empty_signal ='0' then |
---|
[139] | 657 | if rd_en_signal ='1' and unsigned(data_counter)<= 2 then |
---|
[101] | 658 | data_counter <= data_counter - 1; |
---|
[139] | 659 | pop_state <= state2n; |
---|
| 660 | nib<=nib-1; |
---|
[101] | 661 | ReadOk<='1'; |
---|
[139] | 662 | pulseon<='1'; |
---|
[101] | 663 | elsif rd_en_signal ='1' then |
---|
| 664 | data_counter <= data_counter - 1; |
---|
[139] | 665 | pop_state <= state2n; |
---|
| 666 | nib<=nib-1; |
---|
[101] | 667 | ReadOk<='1'; |
---|
| 668 | else --fifo_empty_signal='1' fin prématurée de la lecture |
---|
| 669 | ReadOk<='0'; |
---|
| 670 | wrok<='0'; |
---|
| 671 | --pop_state<=stateErr; |
---|
| 672 | --data_counter<=(others => '0'); |
---|
| 673 | end if; |
---|
| 674 | else |
---|
| 675 | pop_state<=strecover; |
---|
| 676 | data_counter <= data_counter + 1; |
---|
| 677 | report "Input_port_module : Le fifo d'entrée du port " & integer'image(to_integer(unsigned(Port_id(3 downto 0))+1)) & " est vide !!!"; |
---|
| 678 | wrok<='0'; |
---|
| 679 | readok<='0'; |
---|
| 680 | end if; |
---|
| 681 | else |
---|
| 682 | wrOk<='0'; |
---|
| 683 | readok<='0'; |
---|
| 684 | report "Input_port_module : Le fifo de réception du port " & integer'image(to_integer(unsigned(request_latch)+1)) & " est probablement plein !!!"; |
---|
| 685 | pop_state<=strecover; |
---|
| 686 | data_counter <= data_counter + 1; |
---|
| 687 | end if; |
---|
[139] | 688 | |
---|
| 689 | when state2n => if nib=1 then |
---|
| 690 | if pulseon='1' then |
---|
| 691 | pop_state <= stpulse; |
---|
| 692 | else |
---|
| 693 | pop_state <= state2; |
---|
| 694 | end if; |
---|
| 695 | nib<=nbyte; |
---|
| 696 | else |
---|
| 697 | nib<=nib-1; |
---|
| 698 | end if; |
---|
| 699 | wrok<='1'; |
---|
| 700 | fifo_out2<=fifo_out_signal; |
---|
[101] | 701 | when strecover => if fifo_empty_signal='0' and port_granted='1' then |
---|
| 702 | pop_state<=state2; |
---|
| 703 | readok<='0'; |
---|
| 704 | wrok<='0'; |
---|
| 705 | else |
---|
| 706 | readok<='0'; |
---|
| 707 | wrok<='0'; |
---|
| 708 | end if; |
---|
| 709 | |
---|
| 710 | |
---|
| 711 | when stpulse => if port_granted='1' then |
---|
[139] | 712 | pop_state <= state3;--stpulsen; --pousser la dernière donnée dehors |
---|
| 713 | --nib<=nib-1; |
---|
[101] | 714 | data_counter <= data_counter - 1; |
---|
| 715 | wrok<='1'; |
---|
[139] | 716 | pulseon<='0'; |
---|
| 717 | else |
---|
| 718 | wrok<='0'; |
---|
| 719 | end if; |
---|
| 720 | |
---|
| 721 | when stpulsen => wrok<='0'; |
---|
| 722 | if nib=1 then |
---|
| 723 | pop_state <= state3; |
---|
| 724 | nib<=nbyte; |
---|
| 725 | else |
---|
| 726 | nib<=nib-1; |
---|
| 727 | end if; |
---|
| 728 | fifo_out2<=fifo_out_signal; |
---|
[101] | 729 | when state3 => wrok<='0'; |
---|
| 730 | data_counter <= data_counter - 1; |
---|
| 731 | pop_state <= state0; |
---|
| 732 | when stateErr => wrok<='0'; |
---|
| 733 | data_counter <= data_counter; |
---|
| 734 | pop_state <= stateErr; |
---|
| 735 | report "Error in the NoC when sending data " ; |
---|
| 736 | when others => pop_state <= state0; |
---|
| 737 | wrok<='0'; |
---|
| 738 | end case; |
---|
| 739 | end if; |
---|
| 740 | end if; |
---|
| 741 | end process; |
---|
| 742 | |
---|
| 743 | -- actions associées à chaque etat de la fsm de mealy |
---|
[139] | 744 | pop_fsm_action : process(pop_state, fifo_out_signal,fifo_out2,empty_latch, rd_en_signal,readok, port_granted,nib ) |
---|
[101] | 745 | begin |
---|
| 746 | -- code fonctionnel |
---|
| 747 | case pop_state is |
---|
| 748 | when state0 => dat_request_latch_en <= '0'; |
---|
| 749 | dat_pipeline_latch_en <= '0'; |
---|
| 750 | dat_fifo_read_signal <='0'; |
---|
| 751 | dat_request_decoder_en <= '0'; |
---|
| 752 | dat_data_out_pulse <= '0'; |
---|
| 753 | dat_priority_rotation <= '1'; |
---|
| 754 | dat_exec<='0'; |
---|
| 755 | dat_Err<='0'; |
---|
[139] | 756 | push_dout<=fifo_out_signal(8*nib-1 downto 8*(nib-1)); |
---|
[101] | 757 | |
---|
| 758 | when CmdOn => dat_request_latch_en <= '0'; |
---|
| 759 | dat_pipeline_latch_en <= '0'; |
---|
| 760 | dat_fifo_read_signal <='0'; |
---|
| 761 | dat_request_decoder_en <= '0'; |
---|
| 762 | dat_data_out_pulse <= '0'; |
---|
| 763 | dat_priority_rotation <= '1'; |
---|
| 764 | dat_exec<='0'; |
---|
| 765 | dat_Err<='0'; |
---|
[139] | 766 | push_dout<=fifo_out_signal(8*nib-1 downto 8*(nib-1)); |
---|
[101] | 767 | when WaitGrant => |
---|
| 768 | dat_request_latch_en <='1'; --autoriser l'identification du port de destination |
---|
| 769 | dat_pipeline_latch_en <= '0'; --pour le transmettre à travers le réseau |
---|
| 770 | dat_fifo_read_signal <= '0'; |
---|
| 771 | dat_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 772 | dat_data_out_pulse <= '0'; --transmettre le signal pour le dernier mot |
---|
| 773 | dat_priority_rotation <= Port_granted; --dès qu'on a la priorité on la garde |
---|
| 774 | dat_exec<='1'; |
---|
| 775 | dat_Err<='0'; |
---|
[139] | 776 | push_dout<=fifo_out_signal(8*nib-1 downto 8*(nib-1)); |
---|
| 777 | --push_dout<=fifo_out_signal(Word-1 downto Word/2) & PORT_ID(Word/2-1 downto 0); |
---|
[101] | 778 | when ReqPort => |
---|
| 779 | dat_request_latch_en <='1'; --autoriser l'identification du port de destination |
---|
[139] | 780 | dat_pipeline_latch_en <= '0'; --pour le transmettre à travers le réseau |
---|
[101] | 781 | dat_fifo_read_signal <= '1'; |
---|
| 782 | dat_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 783 | dat_data_out_pulse <= '0'; --transmettre le signal pour le dernier mot |
---|
| 784 | dat_priority_rotation <= '0'; |
---|
| 785 | dat_exec<='1'; |
---|
| 786 | dat_Err<='0'; |
---|
[139] | 787 | push_dout<=fifo_out_signal(8*nib-1 downto 8*(nib-1)); |
---|
| 788 | --push_dout<=fifo_out_signal(Word-1 downto Word/2) & PORT_ID(Word/2-1 downto 0); |
---|
| 789 | when addhead => |
---|
| 790 | dat_request_latch_en <='0'; --autoriser l'identification du port de destination |
---|
| 791 | dat_pipeline_latch_en <= '1'; --pour le transmettre à travers le réseau |
---|
| 792 | dat_fifo_read_signal <= '0'; |
---|
| 793 | dat_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 794 | dat_data_out_pulse <= '0'; --transmettre le signal pour le dernier mot |
---|
| 795 | dat_priority_rotation <= '0'; |
---|
| 796 | dat_exec<='1'; |
---|
| 797 | dat_Err<='0'; |
---|
| 798 | push_dout<=fifo_out_signal(8*nib-1 downto 8*(nib-1)); |
---|
[101] | 799 | |
---|
| 800 | when state1 => dat_request_latch_en <= '0'; |
---|
| 801 | dat_pipeline_latch_en <= rd_en_signal and port_granted; |
---|
[139] | 802 | dat_fifo_read_signal <= '0';--rd_en_signal and port_granted; |
---|
[101] | 803 | dat_request_decoder_en <= '1'; |
---|
[139] | 804 | dat_data_out_pulse <= '0';--port_granted; |
---|
| 805 | dat_priority_rotation <= '0'; |
---|
| 806 | dat_exec<='1'; |
---|
| 807 | dat_Err<='0'; |
---|
| 808 | push_dout<=fifo_out2(8*nib-1 downto 8*(nib-1)); |
---|
| 809 | when state1n => dat_request_latch_en <= '0'; |
---|
| 810 | dat_pipeline_latch_en <= '1'; -- toujours actif pour cet octet |
---|
| 811 | dat_fifo_read_signal <= '0'; |
---|
| 812 | dat_request_decoder_en <= '1'; |
---|
[101] | 813 | dat_data_out_pulse <= port_granted; |
---|
| 814 | dat_priority_rotation <= '0'; |
---|
| 815 | dat_exec<='1'; |
---|
| 816 | dat_Err<='0'; |
---|
[139] | 817 | push_dout<=fifo_out2(8*nib-1 downto 8*(nib-1)); |
---|
[101] | 818 | |
---|
| 819 | when state2 |strecover => dat_request_latch_en <= '0'; |
---|
| 820 | dat_pipeline_latch_en <= port_granted and wrok and not(fifo_empty_signal); --autoriser la lecture du fifo en sortie |
---|
| 821 | dat_fifo_read_signal <= port_granted and readok; |
---|
| 822 | dat_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
[139] | 823 | dat_data_out_pulse <= port_granted and wrOk ;--and not(fifo_empty_signal); |
---|
[101] | 824 | dat_priority_rotation <= '0'; |
---|
| 825 | dat_exec<='1'; |
---|
| 826 | dat_Err<='0'; |
---|
[139] | 827 | push_dout<=fifo_out2(8*nib-1 downto 8*(nib-1)); |
---|
| 828 | |
---|
| 829 | when state2n => dat_request_latch_en <= '0'; |
---|
| 830 | dat_pipeline_latch_en <= '1'; --autoriser la lecture du fifo en sortie |
---|
| 831 | dat_fifo_read_signal <= '0'; |
---|
| 832 | dat_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 833 | dat_data_out_pulse <= port_granted and wrOk ;--and not(fifo_empty_signal); |
---|
| 834 | dat_priority_rotation <= '0'; |
---|
| 835 | dat_exec<='1'; |
---|
| 836 | dat_Err<='0'; |
---|
| 837 | push_dout<=fifo_out2(8*nib-1 downto 8*(nib-1)); |
---|
| 838 | when stpulse|stpulsen => dat_request_latch_en <= '0'; --pousser la dernière donnée |
---|
| 839 | dat_pipeline_latch_en <= wrok; --autoriser la lecture du fifo en sortie |
---|
[101] | 840 | dat_fifo_read_signal <='0'; |
---|
| 841 | dat_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 842 | dat_data_out_pulse <= '1'; -- pousser le dernier mot |
---|
| 843 | dat_priority_rotation <= '0'; |
---|
| 844 | dat_exec<='1'; |
---|
| 845 | dat_Err<='0'; |
---|
[139] | 846 | push_dout<=fifo_out2(8*nib-1 downto 8*(nib-1)); |
---|
| 847 | |
---|
[101] | 848 | |
---|
| 849 | when state3 => dat_request_latch_en <= '0'; |
---|
| 850 | dat_pipeline_latch_en <= '0'; |
---|
| 851 | dat_priority_rotation <= '1'; -- libérer la priorité |
---|
| 852 | dat_fifo_read_signal <= '0'; |
---|
| 853 | dat_request_decoder_en <= '0'; --libérer le décodeur |
---|
| 854 | dat_data_out_pulse <= '0'; |
---|
| 855 | dat_exec<='0'; |
---|
| 856 | dat_Err<='0'; |
---|
[139] | 857 | push_dout<=fifo_out_signal(8*nib-1 downto 8*(nib-1)); |
---|
[101] | 858 | when stateErr => dat_request_latch_en <= '0'; |
---|
| 859 | dat_pipeline_latch_en <= '0'; |
---|
| 860 | dat_priority_rotation <= '1'; -- libérer la priorité |
---|
| 861 | dat_fifo_read_signal <= '0'; |
---|
| 862 | dat_request_decoder_en <= '0'; --libérer le décodeur |
---|
| 863 | dat_data_out_pulse <= '0'; |
---|
| 864 | dat_exec<='1'; |
---|
| 865 | dat_Err<='1'; |
---|
[139] | 866 | push_dout<=fifo_out_signal(8*nib-1 downto 8*(nib-1)); |
---|
[101] | 867 | when others => dat_request_latch_en <= '0'; |
---|
| 868 | dat_pipeline_latch_en <= '0'; |
---|
| 869 | dat_priority_rotation <= '1'; |
---|
| 870 | dat_fifo_read_signal <= '0'; |
---|
| 871 | dat_request_decoder_en <= '0'; |
---|
| 872 | dat_data_out_pulse <= '0'; |
---|
| 873 | dat_exec<='0'; |
---|
| 874 | dat_Err<='0'; |
---|
[139] | 875 | push_dout<=fifo_out_signal(8*nib-1 downto 8*(nib-1)); |
---|
[101] | 876 | |
---|
| 877 | end case; |
---|
| 878 | end process; |
---|
| 879 | -- traitement des commandes reçues par le switch |
---|
[139] | 880 | fsm_cmd:process(clk) |
---|
[101] | 881 | variable timeout : natural:=0; |
---|
| 882 | variable cmdcode : natural range 0 to 255; |
---|
| 883 | begin |
---|
| 884 | if rising_edge(clk) then |
---|
| 885 | if reset_signal = '1' then |
---|
| 886 | cmdstate<=cmdstart; |
---|
| 887 | else -- il ne faut pas traiter les cmdes et les données en même temps |
---|
| 888 | case cmdstate is |
---|
| 889 | |
---|
| 890 | when cmdstart => |
---|
| 891 | if cmd_in_en='1' and dat_exec='0' and empty_latch='0' then |
---|
| 892 | cmdstate<=cmdread; |
---|
| 893 | end if; |
---|
| 894 | cmdReadOk<='0'; |
---|
[139] | 895 | cnib<=nbyte; |
---|
[101] | 896 | when cmdwait => if port_granted='1' then -- demande du port de sortie |
---|
| 897 | |
---|
| 898 | cmdstate<=cmdsetdest; |
---|
| 899 | elsif cmd_in_en='1' then |
---|
| 900 | cmdstate<=cmdwait; |
---|
| 901 | else |
---|
| 902 | cmdstate<=cmdstart; |
---|
| 903 | end if; |
---|
| 904 | cmdReadOk<='0'; |
---|
| 905 | when cmdread => |
---|
| 906 | -- if port_granted ='1'then -- ne pas modifier l'état des priorités si on ne l'avait pas |
---|
| 907 | cmdcode:= to_integer(unsigned(fifo_out_signal)); |
---|
| 908 | if cmdcode=1 then --code de getportid |
---|
| 909 | cmdstate<=cmdwait; |
---|
| 910 | cmdReadOk<='1'; |
---|
| 911 | else |
---|
| 912 | --ne pas prendre le code inconnu en compte |
---|
| 913 | cmdstate<=cmdend; -- la commande n'a pas été reconnu |
---|
| 914 | |
---|
| 915 | cmdReadOk<='0'; |
---|
| 916 | end if; |
---|
| 917 | -- end if; |
---|
| 918 | when cmdsetdest => |
---|
[139] | 919 | |
---|
[101] | 920 | if port_granted='1' then |
---|
[139] | 921 | cmdstate<=cmdsetdestn; |
---|
| 922 | cnib<=cnib-1; |
---|
[101] | 923 | end if; |
---|
| 924 | cmdReadOk<='0'; |
---|
[139] | 925 | when cmdsetdestn => if cnib=1 then |
---|
| 926 | cmdstate<=cmdsetcount; |
---|
| 927 | cnib<=nbyte; |
---|
| 928 | else |
---|
| 929 | cnib<=cnib-1; |
---|
| 930 | end if; |
---|
[101] | 931 | when cmdsetcount => |
---|
| 932 | if port_granted='1' then |
---|
[139] | 933 | cmdstate<=cmdsetcountn; |
---|
| 934 | cnib<=cnib-1; |
---|
[101] | 935 | else |
---|
[139] | 936 | cmdstate<=cmdsetcount; |
---|
[101] | 937 | end if; |
---|
| 938 | cmdReadOk<='0'; |
---|
[139] | 939 | |
---|
| 940 | when cmdsetcountn => if cnib=1 then |
---|
| 941 | cmdstate<=cmdsetID; |
---|
| 942 | cnib<=nbyte; |
---|
| 943 | else |
---|
| 944 | cnib<=cnib-1; |
---|
| 945 | end if; |
---|
[101] | 946 | when cmdsetID=> |
---|
| 947 | if port_granted='1' then |
---|
[139] | 948 | cmdstate <=cmdsetIDn; |
---|
| 949 | cnib<=cnib-1; |
---|
[101] | 950 | end if; |
---|
| 951 | cmdReadOk<='0'; |
---|
[139] | 952 | when cmdsetIDn => if cnib=1 then |
---|
| 953 | cmdstate<=cmdpulse; |
---|
| 954 | cnib<=nbyte; |
---|
| 955 | else |
---|
| 956 | cnib<=cnib-1; |
---|
| 957 | end if; |
---|
[101] | 958 | when cmdpulse => |
---|
| 959 | if port_granted='1' then |
---|
[139] | 960 | cmdstate <=cmdpulsen; |
---|
| 961 | cnib<=cnib-1; |
---|
[101] | 962 | end if; |
---|
| 963 | cmdReadOk<='0'; |
---|
[139] | 964 | when cmdpulsen => if cnib=1 then |
---|
| 965 | cmdstate<=cmdEnd; |
---|
| 966 | cnib<=nbyte; |
---|
| 967 | else |
---|
| 968 | cnib<=cnib-1; |
---|
| 969 | end if; |
---|
[101] | 970 | when cmdend => |
---|
| 971 | if cmd_in_en='0' then --éviter l'exécution en boucle |
---|
| 972 | cmdstate<=cmdstart; |
---|
| 973 | end if; |
---|
| 974 | cmdReadOk<='0'; |
---|
| 975 | |
---|
| 976 | end case; |
---|
| 977 | end if; |
---|
| 978 | end if; |
---|
| 979 | end process fsm_cmd; |
---|
| 980 | |
---|
| 981 | cmdaffect:process (cmdstate,fifo_empty_signal, port_granted, PORT_ID) |
---|
| 982 | begin |
---|
| 983 | case cmdstate is |
---|
| 984 | |
---|
| 985 | when cmdstart => |
---|
| 986 | cmd_exec<='0'; |
---|
| 987 | cmd_pipeline_latch_en <='0'; |
---|
| 988 | cmd_priority_rotation <= '1'; |
---|
| 989 | cmd_request_latch_en<='0'; |
---|
| 990 | cmd_fifo_read_signal <= '0'; |
---|
| 991 | cmd_request_decoder_en <= '0'; |
---|
| 992 | cmd_data_signal<=(others=>'0'); |
---|
| 993 | cmd_data_out_pulse <= '0'; |
---|
| 994 | |
---|
| 995 | when cmdread => |
---|
| 996 | cmd_exec<='1'; |
---|
| 997 | cmd_pipeline_latch_en <= '0'; |
---|
| 998 | cmd_fifo_read_signal <= '1'; -- vider le tampon d'entrée |
---|
| 999 | cmd_request_latch_en<='1'; --mémoriser l'adresse de destination |
---|
| 1000 | cmd_request_decoder_en <= '1'; --demande d'émission |
---|
| 1001 | cmd_data_out_pulse <= '0'; |
---|
| 1002 | cmd_priority_rotation <= '1'; --sans priorité |
---|
[139] | 1003 | cmd_data_signal<=std_logic_vector(to_unsigned(tot_ports,Word-adr_len)) & Port_ID; |
---|
[101] | 1004 | when cmdwait => |
---|
| 1005 | cmd_exec<='1'; |
---|
| 1006 | cmd_pipeline_latch_en <='0'; |
---|
| 1007 | cmd_fifo_read_signal <= '0'; |
---|
| 1008 | cmd_request_latch_en<='1'; |
---|
| 1009 | cmd_priority_rotation <= '0'; --avec priorité |
---|
| 1010 | cmd_request_decoder_en <= '1'; --demande d'émission |
---|
[139] | 1011 | cmd_data_signal<=std_logic_vector(to_unsigned(tot_ports,Word-adr_len)) & Port_ID; |
---|
[101] | 1012 | cmd_data_out_pulse <= '0'; |
---|
| 1013 | when cmdsetdest => |
---|
| 1014 | --cmd_request_decoder_en <= '1'; |
---|
| 1015 | cmd_exec<='1'; |
---|
| 1016 | cmd_pipeline_latch_en <='1'; --empiler dans le tampon de sortie la donnée |
---|
| 1017 | cmd_fifo_read_signal <='0'; |
---|
| 1018 | cmd_request_latch_en<='0'; |
---|
| 1019 | cmd_request_decoder_en <= '1'; --autoriser le decodeur à activer le dernier bit de request |
---|
| 1020 | cmd_data_out_pulse <= '0'; |
---|
| 1021 | cmd_priority_rotation <= '0'; |
---|
[139] | 1022 | cmd_data_signal<=std_logic_vector(to_unsigned(tot_ports,Word-adr_len)) & Port_ID; -- le numéro du port et le nombre total des ports est envoyé |
---|
| 1023 | when cmdsetdestn => |
---|
| 1024 | --cmd_request_decoder_en <= '1'; |
---|
| 1025 | cmd_exec<='1'; |
---|
| 1026 | cmd_pipeline_latch_en <='1'; --empiler dans le tampon de sortie la donnée |
---|
| 1027 | cmd_fifo_read_signal <='0'; |
---|
| 1028 | cmd_request_latch_en<='0'; |
---|
| 1029 | cmd_request_decoder_en <= '1'; --autoriser le decodeur à activer le dernier bit de request |
---|
| 1030 | cmd_data_out_pulse <= '1'; |
---|
| 1031 | cmd_priority_rotation <= '0'; |
---|
| 1032 | cmd_data_signal<=std_logic_vector(to_unsigned(tot_ports,Word-adr_len)) & Port_ID; -- le numéro du port et le nombre total des ports est envoyé |
---|
| 1033 | |
---|
| 1034 | when cmdsetcount|cmdsetcountn=> |
---|
[101] | 1035 | |
---|
| 1036 | cmd_exec<='1'; |
---|
| 1037 | cmd_pipeline_latch_en <='1'; -- empiler dans le tampon de sortie les données |
---|
| 1038 | cmd_fifo_read_signal <='0'; |
---|
| 1039 | cmd_request_latch_en<='0'; --enregistrer l'adresse de destination |
---|
| 1040 | cmd_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 1041 | cmd_data_out_pulse <= port_granted; |
---|
| 1042 | cmd_priority_rotation <= '0'; |
---|
[139] | 1043 | cmd_data_signal<=STD_LOGIC_VECTOR(to_unsigned(3,Word)); |
---|
| 1044 | when cmdSetId| cmdSetIdn=> |
---|
[101] | 1045 | --cmd_request_decoder_en <= '1'; |
---|
| 1046 | cmd_exec<='1'; |
---|
| 1047 | cmd_pipeline_latch_en <='1'; |
---|
| 1048 | cmd_fifo_read_signal <='0'; |
---|
| 1049 | cmd_request_latch_en<='0'; --enregistrer l'adresse de destination |
---|
| 1050 | cmd_request_decoder_en <= '1'; --autoriser le decodeur à activer le dernier bit de request |
---|
| 1051 | cmd_data_out_pulse <= port_granted; |
---|
| 1052 | cmd_priority_rotation <= '0'; |
---|
[139] | 1053 | cmd_data_signal<=std_logic_vector(to_unsigned(tot_ports,Word-adr_len)) & Port_ID; -- le numéro du port et le nombre total des ports est envoyé |
---|
[101] | 1054 | |
---|
| 1055 | when cmdpulse => cmd_exec<='1'; |
---|
[139] | 1056 | cmd_pipeline_latch_en <='1'; |
---|
[101] | 1057 | cmd_fifo_read_signal <='0'; |
---|
| 1058 | cmd_request_latch_en<='0'; |
---|
| 1059 | cmd_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 1060 | cmd_data_out_pulse <= '1';--port_granted; --s'assurer que la dernière donnée est bien lue |
---|
| 1061 | cmd_priority_rotation <= '0'; |
---|
[139] | 1062 | cmd_data_signal<=std_logic_vector(to_unsigned(tot_ports,Word-adr_len)) & Port_ID; |
---|
| 1063 | |
---|
| 1064 | when cmdpulsen => cmd_exec<='1'; |
---|
| 1065 | cmd_pipeline_latch_en <='0'; |
---|
| 1066 | cmd_fifo_read_signal <='0'; |
---|
| 1067 | cmd_request_latch_en<='0'; |
---|
| 1068 | cmd_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 1069 | cmd_data_out_pulse <= '0';--port_granted; --s'assurer que la dernière donnée est bien lue |
---|
| 1070 | cmd_priority_rotation <= '0'; |
---|
[101] | 1071 | --cmd_data_signal<=Port_ID ; |
---|
[139] | 1072 | cmd_data_signal<=std_logic_vector(to_unsigned(tot_ports,Word-adr_len)) & Port_ID; |
---|
[101] | 1073 | |
---|
| 1074 | when cmdend => |
---|
| 1075 | cmd_exec<='0'; |
---|
| 1076 | cmd_request_latch_en <= '0'; |
---|
| 1077 | cmd_pipeline_latch_en <= '0'; |
---|
| 1078 | cmd_fifo_read_signal <= '0'; |
---|
| 1079 | cmd_request_latch_en<='0'; |
---|
| 1080 | cmd_request_decoder_en <= '0'; |
---|
| 1081 | cmd_data_out_pulse <= '0'; |
---|
| 1082 | cmd_priority_rotation <= '1'; |
---|
| 1083 | cmd_data_signal<=(others=>'0'); |
---|
| 1084 | |
---|
| 1085 | |
---|
| 1086 | end case ; |
---|
| 1087 | end process cmdaffect; |
---|
| 1088 | |
---|
| 1089 | end Behavioral; |
---|
| 1090 | |
---|
| 1091 | |
---|