[143] | 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; |
---|
| 42 | |
---|
| 43 | Port_num: natural:=1); -- port_num est l'id du port |
---|
| 44 | Port ( data_in : in STD_LOGIC_VECTOR (Word-1 downto 0); |
---|
| 45 | data_in_en : in STD_LOGIC; -- signaler la présence des données en entrée |
---|
| 46 | cmd_in_en :in STD_LOGIC; --permet d'identifier les données qui sont dans le tampon |
---|
| 47 | reset : in STD_LOGIC; |
---|
| 48 | clk : in STD_LOGIC; |
---|
| 49 | request : out STD_LOGIC_VECTOR (number_of_ports downto 1); --demande de canal de transmission |
---|
| 50 | grant : in STD_LOGIC_VECTOR (number_of_ports downto 1); -- autorisation de transmission |
---|
| 51 | fifo_full : out STD_LOGIC; -- signaler que les données ne peuvent plus être acceptées en entrée |
---|
| 52 | fifo_empty : out STD_LOGIC; -- le tampon d'entrée est vide |
---|
| 53 | priority_rotation : out std_logic; -- reserver le canal de transmission |
---|
| 54 | data_out : out STD_LOGIC_VECTOR (Word-1 downto 0); --données vers le réseau crossbar |
---|
| 55 | data_out_pulse : out std_logic); -- permet de ... |
---|
| 56 | |
---|
| 57 | end INPUT_PORT_MODULE; |
---|
| 58 | |
---|
| 59 | architecture Behavioral of INPUT_PORT_MODULE is |
---|
| 60 | |
---|
| 61 | -- declaration du fifo 64 octet utilisé pour chaque port |
---|
| 62 | component FIFO_256_FWFT |
---|
| 63 | port ( |
---|
| 64 | clk: IN std_logic; |
---|
| 65 | din: IN std_logic_VECTOR(Word-1 downto 0); |
---|
| 66 | rd_en: IN std_logic; |
---|
| 67 | srst: IN std_logic; |
---|
| 68 | wr_en: IN std_logic; |
---|
| 69 | dout: OUT std_logic_VECTOR(Word-1 downto 0); |
---|
| 70 | empty: OUT std_logic; |
---|
| 71 | full: OUT std_logic); |
---|
| 72 | end component; |
---|
| 73 | |
---|
| 74 | --definition du type etat pour les fsm |
---|
| 75 | type fsm_states is (state0, CmdOn, WaitGrant, ReqPort, state1, state2,strecover,stpulse,stateErr, state3);-- definition du type etat pour le codage des etats des fsm |
---|
| 76 | type fsm_states2 is(cmdstart,cmdwait,cmdread,cmdSetDest,cmdSetCount,cmdSetId,cmdpulse,CmdEnd); |
---|
| 77 | signal pop_state : fsm_states; |
---|
| 78 | signal cmdstate : fsm_states2; |
---|
| 79 | signal cmd_exec : std_logic:='0'; --indique que le port est en train d'exécuter une commande |
---|
| 80 | signal dat_exec :std_logic:='0'; -- indique le port est en train de transférer des données |
---|
| 81 | signal dat_Err :std_logic:='0'; -- signal une erreur pendant l'exécution |
---|
| 82 | signal wrok,readOk,CmdReadOk : std_logic:='0'; --indique s'il est possible de lire les données |
---|
| 83 | -- signaux utilisés dans les fsm |
---|
| 84 | signal request_decoder,req_grant : STD_LOGIC_VECTOR(number_of_ports downto 1); |
---|
| 85 | signal request_decoder_en : std_logic; |
---|
| 86 | signal request_latch : STD_LOGIC_VECTOR(4 downto 1):=(others=>'0'); -- pourquoi pas 3 downto 0 ? |
---|
| 87 | signal request_latch_en : std_logic; |
---|
| 88 | signal pipeline_latch : std_logic_vector(Word-1 downto 0); |
---|
| 89 | signal pipeline_latch_en : std_logic; |
---|
| 90 | signal request_word : std_logic_vector(5 downto 1); |
---|
| 91 | signal port_granted : std_logic; |
---|
| 92 | signal rd_en_signal : std_logic; |
---|
| 93 | --signaux utilisés dans la MAE de gestion des commandes |
---|
| 94 | signal cmd_request_latch_en :std_logic; |
---|
| 95 | signal cmd_pipeline_latch_en :std_logic; |
---|
| 96 | signal cmd_fifo_read_signal :std_logic; |
---|
| 97 | signal cmd_request_decoder_en :std_logic; |
---|
| 98 | signal cmd_data_out_pulse :std_logic; |
---|
| 99 | signal cmd_priority_rotation :std_logic; |
---|
| 100 | --signaux utilisés dans la MAE de transfert des données |
---|
| 101 | signal dat_request_latch_en :std_logic; |
---|
| 102 | signal dat_pipeline_latch_en :std_logic; |
---|
| 103 | signal dat_fifo_read_signal :std_logic; |
---|
| 104 | signal dat_request_decoder_en :std_logic; |
---|
| 105 | signal dat_data_out_pulse :std_logic; |
---|
| 106 | signal dat_priority_rotation :std_logic; |
---|
| 107 | -- signaux utilisés pour les connections entre composants |
---|
| 108 | signal clk_signal : std_logic; |
---|
| 109 | signal reset_signal : std_logic; |
---|
| 110 | signal fifo_empty_signal : std_logic; |
---|
| 111 | signal fifo_read_signal : std_logic; |
---|
| 112 | signal fifo_out_signal,cmd_data_signal : std_logic_vector(Word-1 downto 0); |
---|
| 113 | signal push_dout : std_logic_vector(Word-1 downto 0); |
---|
| 114 | signal empty_latch : std_logic ; |
---|
| 115 | signal PORT_ID :std_logic_vector(Word-1 downto 0):=STD_LOGIC_VECTOR(to_unsigned(number_of_ports-1,4))& STD_LOGIC_VECTOR(to_unsigned(port_num-1,4)); |
---|
| 116 | -- signaux du compteur de données |
---|
| 117 | signal data_counter : std_logic_vector(Word-1 downto 0); |
---|
| 118 | |
---|
| 119 | begin |
---|
| 120 | -- instantiation du FIFO_256 |
---|
| 121 | INPUT_PORT_FIFO : FIFO_256_FWFT |
---|
| 122 | port map ( |
---|
| 123 | clk => clk_signal, |
---|
| 124 | din => data_in, |
---|
| 125 | rd_en => fifo_read_signal, |
---|
| 126 | srst => reset_signal, |
---|
| 127 | wr_en => data_in_en, |
---|
| 128 | dout => fifo_out_signal, |
---|
| 129 | empty => fifo_empty_signal, |
---|
| 130 | full => fifo_full); |
---|
| 131 | -- connections avec les ports de l'entité |
---|
| 132 | |
---|
| 133 | data_out <= pipeline_latch ;--when cmd_exec='0' else cmd_data_signal; |
---|
| 134 | fifo_empty <= empty_latch; |
---|
| 135 | reset_signal <= reset; |
---|
| 136 | grant_proc:process(req_grant) |
---|
| 137 | begin |
---|
| 138 | --if rising_edge(clk) then |
---|
| 139 | -- if unsigned(grant)> 0 then |
---|
| 140 | if unsigned(req_grant) > 0 then |
---|
| 141 | port_granted <= '1'; --il faut veiller à ce que ce port soit vraiment autorisé |
---|
| 142 | else |
---|
| 143 | Port_granted<='0'; --ceci présuppose que la valeur qu'il reçoit est forcément la sienne |
---|
| 144 | end if; |
---|
| 145 | --end if; |
---|
| 146 | end process; |
---|
| 147 | rd_en_signal <= not(fifo_empty_signal);--not(empty_latch) ; |
---|
| 148 | request <= request_decoder; |
---|
| 149 | reg_grant:process (request_decoder,grant) |
---|
| 150 | begin |
---|
| 151 | req_grant<=request_decoder and grant; |
---|
| 152 | end process reg_grant; |
---|
| 153 | request_word <= request_latch & request_decoder_en; |
---|
| 154 | clk_signal <= clk; |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | |
---|
| 158 | WITH cmd_exec SELECT |
---|
| 159 | request_latch_en <= dat_request_latch_en WHEN '0', |
---|
| 160 | cmd_request_latch_en WHEN others; |
---|
| 161 | |
---|
| 162 | WITH cmd_exec SELECT |
---|
| 163 | pipeline_latch_en <= dat_pipeline_latch_en WHEN '0', |
---|
| 164 | cmd_pipeline_latch_en WHEN others; |
---|
| 165 | |
---|
| 166 | WITH cmd_exec SELECT |
---|
| 167 | fifo_read_signal <=dat_fifo_read_signal WHEN '0', |
---|
| 168 | |
---|
| 169 | cmd_fifo_read_signal WHEN others; |
---|
| 170 | WITH cmd_exec SELECT |
---|
| 171 | request_decoder_en <=dat_request_decoder_en WHEN '0', |
---|
| 172 | cmd_request_decoder_en WHEN others; |
---|
| 173 | WITH cmd_exec SELECT |
---|
| 174 | data_out_pulse <=dat_data_out_pulse WHEN '0', |
---|
| 175 | cmd_data_out_pulse WHEN others; |
---|
| 176 | WITH cmd_exec SELECT |
---|
| 177 | priority_rotation<=dat_priority_rotation WHEN '0', |
---|
| 178 | cmd_priority_rotation WHEN others; |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | --processus permettant de latcher le signal empty |
---|
| 182 | -- evite une perte de données en cas d'arret au cours d'une transmission |
---|
| 183 | empty_latch_process : process(clk) |
---|
| 184 | begin |
---|
| 185 | if rising_edge(clk) then |
---|
| 186 | if reset_signal = '1' then |
---|
| 187 | empty_latch <= '1'; |
---|
| 188 | else |
---|
| 189 | empty_latch <= fifo_empty_signal; |
---|
| 190 | end if; |
---|
| 191 | end if; |
---|
| 192 | |
---|
| 193 | end process; |
---|
| 194 | -- decodeur de requete en fonction de l'adresse destination |
---|
| 195 | -- le circuit genere depend du parametre generique nombre de ports |
---|
| 196 | -- switch 2 ports |
---|
| 197 | switch2x2 : if number_of_ports = 2 generate |
---|
| 198 | |
---|
| 199 | with request_word select |
---|
| 200 | request_decoder <="01" when "00001", |
---|
| 201 | "10" when "00011", |
---|
| 202 | "00" when others; |
---|
| 203 | |
---|
| 204 | end generate switch2x2; |
---|
| 205 | |
---|
| 206 | |
---|
| 207 | -- switch 3 ports |
---|
| 208 | switch3x3 : if number_of_ports = 3 generate |
---|
| 209 | |
---|
| 210 | with request_word select |
---|
| 211 | request_decoder <="001" when "00001", |
---|
| 212 | "010" when "00011", |
---|
| 213 | "100" when "00101", |
---|
| 214 | "000" when others; |
---|
| 215 | |
---|
| 216 | end generate switch3x3; |
---|
| 217 | |
---|
| 218 | |
---|
| 219 | -- switch 4 ports |
---|
| 220 | switch4x4 : if number_of_ports = 4 generate |
---|
| 221 | |
---|
| 222 | with request_word select |
---|
| 223 | request_decoder <="0001" when "00001", |
---|
| 224 | "0010" when "00011", |
---|
| 225 | "0100" when "00101", |
---|
| 226 | "1000" when "00111", |
---|
| 227 | "0000" when others; |
---|
| 228 | |
---|
| 229 | end generate switch4x4; |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | -- switch 5 ports |
---|
| 233 | switch5x5 : if number_of_ports = 5 generate |
---|
| 234 | |
---|
| 235 | with request_word select |
---|
| 236 | request_decoder <="00001" when "00001", |
---|
| 237 | "00010" when "00011", |
---|
| 238 | "00100" when "00101", |
---|
| 239 | "01000" when "00111", |
---|
| 240 | "10000" when "01001", |
---|
| 241 | "00000" when others; |
---|
| 242 | |
---|
| 243 | end generate switch5x5; |
---|
| 244 | |
---|
| 245 | |
---|
| 246 | -- switch 6 ports |
---|
| 247 | switch6x6 : if number_of_ports = 6 generate |
---|
| 248 | |
---|
| 249 | with request_word select |
---|
| 250 | request_decoder <="000001" when "00001", |
---|
| 251 | "000010" when "00011", |
---|
| 252 | "000100" when "00101", |
---|
| 253 | "001000" when "00111", |
---|
| 254 | "010000" when "01001", |
---|
| 255 | "100000" when "01011", |
---|
| 256 | "000000" when others; |
---|
| 257 | |
---|
| 258 | end generate switch6x6; |
---|
| 259 | |
---|
| 260 | |
---|
| 261 | -- switch 7 ports |
---|
| 262 | switch7x7 : if number_of_ports = 7 generate |
---|
| 263 | |
---|
| 264 | with request_word select |
---|
| 265 | request_decoder <="0000001" when "00001", |
---|
| 266 | "0000010" when "00011", |
---|
| 267 | "0000100" when "00101", |
---|
| 268 | "0001000" when "00111", |
---|
| 269 | "0010000" when "01001", |
---|
| 270 | "0100000" when "01011", |
---|
| 271 | "1000000" when "01101", |
---|
| 272 | "0000000" when others; |
---|
| 273 | |
---|
| 274 | end generate switch7x7; |
---|
| 275 | |
---|
| 276 | |
---|
| 277 | -- switch 8 ports |
---|
| 278 | switch8x8 : if number_of_ports = 8 generate |
---|
| 279 | |
---|
| 280 | with request_word select |
---|
| 281 | request_decoder <="00000001" when "00001", |
---|
| 282 | "00000010" when "00011", |
---|
| 283 | "00000100" when "00101", |
---|
| 284 | "00001000" when "00111", |
---|
| 285 | "00010000" when "01001", |
---|
| 286 | "00100000" when "01011", |
---|
| 287 | "01000000" when "01101", |
---|
| 288 | "10000000" when "01111", |
---|
| 289 | "00000000" when others; |
---|
| 290 | |
---|
| 291 | end generate switch8x8; |
---|
| 292 | |
---|
| 293 | |
---|
| 294 | -- switch 9 ports |
---|
| 295 | switch9x9 : if number_of_ports = 9 generate |
---|
| 296 | |
---|
| 297 | with request_word select |
---|
| 298 | request_decoder <="000000001" when "00001", |
---|
| 299 | "000000010" when "00011", |
---|
| 300 | "000000100" when "00101", |
---|
| 301 | "000001000" when "00111", |
---|
| 302 | "000010000" when "01001", |
---|
| 303 | "000100000" when "01011", |
---|
| 304 | "001000000" when "01101", |
---|
| 305 | "010000000" when "01111", |
---|
| 306 | "100000000" when "10001", |
---|
| 307 | "000000000" when others; |
---|
| 308 | |
---|
| 309 | end generate switch9x9; |
---|
| 310 | |
---|
| 311 | |
---|
| 312 | -- switch 10 ports |
---|
| 313 | switch10x10 : if number_of_ports = 10 generate |
---|
| 314 | |
---|
| 315 | with request_word select |
---|
| 316 | request_decoder <="0000000001" when "00001", |
---|
| 317 | "0000000010" when "00011", |
---|
| 318 | "0000000100" when "00101", |
---|
| 319 | "0000001000" when "00111", |
---|
| 320 | "0000010000" when "01001", |
---|
| 321 | "0000100000" when "01011", |
---|
| 322 | "0001000000" when "01101", |
---|
| 323 | "0010000000" when "01111", |
---|
| 324 | "0100000000" when "10001", |
---|
| 325 | "1000000000" when "10011", |
---|
| 326 | "0000000000" when others; |
---|
| 327 | |
---|
| 328 | end generate switch10x10; |
---|
| 329 | |
---|
| 330 | |
---|
| 331 | -- switch 11 ports |
---|
| 332 | switch11x11 : if number_of_ports = 11 generate |
---|
| 333 | |
---|
| 334 | with request_word select |
---|
| 335 | request_decoder <="00000000001" when "00001", |
---|
| 336 | "00000000010" when "00011", |
---|
| 337 | "00000000100" when "00101", |
---|
| 338 | "00000001000" when "00111", |
---|
| 339 | "00000010000" when "01001", |
---|
| 340 | "00000100000" when "01011", |
---|
| 341 | "00001000000" when "01101", |
---|
| 342 | "00010000000" when "01111", |
---|
| 343 | "00100000000" when "10001", |
---|
| 344 | "01000000000" when "10011", |
---|
| 345 | "10000000000" when "10101", |
---|
| 346 | "00000000000" when others; |
---|
| 347 | |
---|
| 348 | end generate switch11x11; |
---|
| 349 | |
---|
| 350 | |
---|
| 351 | -- switch 12 ports |
---|
| 352 | switch12x12 : if number_of_ports = 12 generate |
---|
| 353 | |
---|
| 354 | with request_word select |
---|
| 355 | request_decoder <="000000000001" when "00001", |
---|
| 356 | "000000000010" when "00011", |
---|
| 357 | "000000000100" when "00101", |
---|
| 358 | "000000001000" when "00111", |
---|
| 359 | "000000010000" when "01001", |
---|
| 360 | "000000100000" when "01011", |
---|
| 361 | "000001000000" when "01101", |
---|
| 362 | "000010000000" when "01111", |
---|
| 363 | "000100000000" when "10001", |
---|
| 364 | "001000000000" when "10011", |
---|
| 365 | "010000000000" when "10101", |
---|
| 366 | "100000000000" when "10111", |
---|
| 367 | "000000000000" when others; |
---|
| 368 | |
---|
| 369 | end generate switch12x12; |
---|
| 370 | |
---|
| 371 | |
---|
| 372 | -- switch 13 ports |
---|
| 373 | switch13x13 : if number_of_ports = 13 generate |
---|
| 374 | |
---|
| 375 | with request_word select |
---|
| 376 | request_decoder <="0000000000001" when "00001", |
---|
| 377 | "0000000000010" when "00011", |
---|
| 378 | "0000000000100" when "00101", |
---|
| 379 | "0000000001000" when "00111", |
---|
| 380 | "0000000010000" when "01001", |
---|
| 381 | "0000000100000" when "01011", |
---|
| 382 | "0000001000000" when "01101", |
---|
| 383 | "0000010000000" when "01111", |
---|
| 384 | "0000100000000" when "10001", |
---|
| 385 | "0001000000000" when "10011", |
---|
| 386 | "0010000000000" when "10101", |
---|
| 387 | "0100000000000" when "10111", |
---|
| 388 | "1000000000000" when "11001", |
---|
| 389 | "0000000000000" when others; |
---|
| 390 | |
---|
| 391 | end generate switch13x13; |
---|
| 392 | |
---|
| 393 | |
---|
| 394 | -- switch 14 ports |
---|
| 395 | switch14x14 : if number_of_ports = 14 generate |
---|
| 396 | |
---|
| 397 | with request_word select |
---|
| 398 | request_decoder <="00000000000001" when "00001", |
---|
| 399 | "00000000000010" when "00011", |
---|
| 400 | "00000000000100" when "00101", |
---|
| 401 | "00000000001000" when "00111", |
---|
| 402 | "00000000010000" when "01001", |
---|
| 403 | "00000000100000" when "01011", |
---|
| 404 | "00000001000000" when "01101", |
---|
| 405 | "00000010000000" when "01111", |
---|
| 406 | "00000100000000" when "10001", |
---|
| 407 | "00001000000000" when "10011", |
---|
| 408 | "00010000000000" when "10101", |
---|
| 409 | "00100000000000" when "10111", |
---|
| 410 | "01000000000000" when "11001", |
---|
| 411 | "10000000000000" when "11011", |
---|
| 412 | "00000000000000" when others; |
---|
| 413 | |
---|
| 414 | end generate switch14x14; |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | -- switch 15 ports |
---|
| 418 | switch15x15 : if number_of_ports = 15 generate |
---|
| 419 | |
---|
| 420 | with request_word select |
---|
| 421 | request_decoder <="000000000000001" when "00001", |
---|
| 422 | "000000000000010" when "00011", |
---|
| 423 | "000000000000100" when "00101", |
---|
| 424 | "000000000001000" when "00111", |
---|
| 425 | "000000000010000" when "01001", |
---|
| 426 | "000000000100000" when "01011", |
---|
| 427 | "000000001000000" when "01101", |
---|
| 428 | "000000010000000" when "01111", |
---|
| 429 | "000000100000000" when "10001", |
---|
| 430 | "000001000000000" when "10011", |
---|
| 431 | "000010000000000" when "10101", |
---|
| 432 | "000100000000000" when "10111", |
---|
| 433 | "001000000000000" when "11001", |
---|
| 434 | "010000000000000" when "11011", |
---|
| 435 | "100000000000000" when "11101", |
---|
| 436 | "000000000000000" when others; |
---|
| 437 | |
---|
| 438 | end generate switch15x15; |
---|
| 439 | |
---|
| 440 | |
---|
| 441 | -- switch 16 ports |
---|
| 442 | switch16x16 : if number_of_ports = 16 generate |
---|
| 443 | |
---|
| 444 | with request_word select |
---|
| 445 | request_decoder <="0000000000000001" when "00001", |
---|
| 446 | "0000000000000010" when "00011", |
---|
| 447 | "0000000000000100" when "00101", |
---|
| 448 | "0000000000001000" when "00111", |
---|
| 449 | "0000000000010000" when "01001", |
---|
| 450 | "0000000000100000" when "01011", |
---|
| 451 | "0000000001000000" when "01101", |
---|
| 452 | "0000000010000000" when "01111", |
---|
| 453 | "0000000100000000" when "10001", |
---|
| 454 | "0000001000000000" when "10011", |
---|
| 455 | "0000010000000000" when "10101", |
---|
| 456 | "0000100000000000" when "10111", |
---|
| 457 | "0001000000000000" when "11001", |
---|
| 458 | "0010000000000000" when "11011", |
---|
| 459 | "0100000000000000" when "11101", |
---|
| 460 | "1000000000000000" when "11111", |
---|
| 461 | "0000000000000000" when others; |
---|
| 462 | |
---|
| 463 | end generate switch16x16; |
---|
| 464 | --latch du fifo de sortie ?? |
---|
| 465 | pipeline_latch_process : process(clk) |
---|
| 466 | begin |
---|
| 467 | if rising_edge(clk) then |
---|
| 468 | if reset_signal = '1' then |
---|
| 469 | pipeline_latch <= (others => '0'); |
---|
| 470 | elsif pipeline_latch_en = '1' and cmd_exec='0' then |
---|
| 471 | pipeline_latch <= push_dout; |
---|
| 472 | elsif pipeline_latch_en = '1' and cmd_exec='1' then |
---|
| 473 | pipeline_latch <= cmd_data_signal; |
---|
| 474 | end if; |
---|
| 475 | end if; |
---|
| 476 | end process; |
---|
| 477 | |
---|
| 478 | --latch qui memorise l'adresse de destination du packet |
---|
| 479 | |
---|
| 480 | request_latch_process : process(clk) |
---|
| 481 | begin |
---|
| 482 | if rising_edge(clk) then |
---|
| 483 | if reset_signal = '1' then |
---|
| 484 | request_latch <= (others => '0'); |
---|
| 485 | elsif request_latch_en = '1' and cmd_in_en='0' then --si la lecture de la destination est autorisée |
---|
| 486 | request_latch <=fifo_out_signal(3 downto 0); --fifo_out_signal(3) & fifo_out_signal(2) & fifo_out_signal(1) & fifo_out_signal(0); |
---|
| 487 | assert (unsigned(fifo_out_signal(3 downto 0))<number_of_ports) |
---|
| 488 | report "Input_port_module n° " & integer'image(port_num) & " Le port sollicité n'existe pas le NoC va être bloqué !" |
---|
| 489 | severity failure; |
---|
| 490 | 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 |
---|
| 491 | request_latch<=Port_ID(3 downto 0); --car les ports commencent à 0 |
---|
| 492 | end if; |
---|
| 493 | |
---|
| 494 | end if; |
---|
| 495 | end process; |
---|
| 496 | |
---|
| 497 | -- machine à etat de mealy qui depile les donnees dans le fifo |
---|
| 498 | -- |
---|
| 499 | -- processus determinant l'etat futur |
---|
| 500 | pop_fsm_nsl : process(clk) |
---|
| 501 | begin |
---|
| 502 | if rising_edge(clk) then |
---|
| 503 | if reset_signal = '1' then |
---|
| 504 | pop_state <= state0; |
---|
| 505 | data_counter <= (others => '0'); |
---|
| 506 | elsif cmd_exec='0' then --il ne faut pas exécuter cette MAE |
---|
| 507 | -- lorsque l'autre est en cours |
---|
| 508 | wrok<='0'; |
---|
| 509 | case pop_state is |
---|
| 510 | when state0 => if cmd_in_en='0' then --il ne faut pas exécuter les deux MAE ... |
---|
| 511 | if empty_latch ='0' then -- pile pas vide on doit dépiler |
---|
| 512 | pop_state <= WaitGrant; |
---|
| 513 | end if; |
---|
| 514 | else |
---|
| 515 | pop_state <= CmdOn; |
---|
| 516 | end if; |
---|
| 517 | when CmdOn => if empty_latch='1' and cmd_in_en='0' then |
---|
| 518 | pop_state <= state0; |
---|
| 519 | elsif empty_latch='0' and cmd_in_en='1' then |
---|
| 520 | pop_state <= CmdOn; |
---|
| 521 | elsif empty_latch='1' and cmd_in_en='1' then |
---|
| 522 | pop_state <= state0; |
---|
| 523 | else -- empty_latch='0' and cmd_in_en='0' |
---|
| 524 | pop_state <= WaitGrant; |
---|
| 525 | end if; |
---|
| 526 | |
---|
| 527 | when WaitGrant => if port_granted = '1' then |
---|
| 528 | -- |
---|
| 529 | pop_state <= ReqPort; |
---|
| 530 | end if; |
---|
| 531 | |
---|
| 532 | when ReqPort => --if port_granted = '1' then |
---|
| 533 | -- |
---|
| 534 | pop_state <= state1; |
---|
| 535 | |
---|
| 536 | --end if; |
---|
| 537 | |
---|
| 538 | when state1 => if port_granted ='1' then --lecture de la longueur des données |
---|
| 539 | data_counter <= fifo_out_signal; |
---|
| 540 | if unsigned(fifo_out_signal)<=3 then |
---|
| 541 | ReadOk<='1'; |
---|
| 542 | else |
---|
| 543 | readOk<='1'; |
---|
| 544 | end if; |
---|
| 545 | pop_state <= state2; |
---|
| 546 | wrok<='1'; |
---|
| 547 | else |
---|
| 548 | wrok<='0'; |
---|
| 549 | end if; |
---|
| 550 | |
---|
| 551 | when state2 => if port_granted='1' then |
---|
| 552 | wrok<='1'; |
---|
| 553 | if fifo_empty_signal ='0' then |
---|
| 554 | if rd_en_signal ='1' and unsigned(data_counter)<= 2 then |
---|
| 555 | data_counter <= data_counter - 1; |
---|
| 556 | pop_state <= stpulse; |
---|
| 557 | ReadOk<='1'; |
---|
| 558 | elsif rd_en_signal ='1' then |
---|
| 559 | data_counter <= data_counter - 1; |
---|
| 560 | pop_state <= state2; |
---|
| 561 | ReadOk<='1'; |
---|
| 562 | else --fifo_empty_signal='1' fin prématurée de la lecture |
---|
| 563 | ReadOk<='0'; |
---|
| 564 | wrok<='0'; |
---|
| 565 | --pop_state<=stateErr; |
---|
| 566 | --data_counter<=(others => '0'); |
---|
| 567 | end if; |
---|
| 568 | else |
---|
| 569 | pop_state<=strecover; |
---|
| 570 | data_counter <= data_counter + 1; |
---|
| 571 | report "Input_port_module : Le fifo d'entrée du port " & integer'image(to_integer(unsigned(Port_id(3 downto 0))+1)) & " est vide !!!"; |
---|
| 572 | wrok<='0'; |
---|
| 573 | readok<='0'; |
---|
| 574 | end if; |
---|
| 575 | else |
---|
| 576 | wrOk<='0'; |
---|
| 577 | readok<='0'; |
---|
| 578 | report "Input_port_module : Le fifo de réception du port " & integer'image(to_integer(unsigned(request_latch)+1)) & " est probablement plein !!!"; |
---|
| 579 | pop_state<=strecover; |
---|
| 580 | data_counter <= data_counter + 1; |
---|
| 581 | end if; |
---|
| 582 | when strecover => if fifo_empty_signal='0' and port_granted='1' then |
---|
| 583 | pop_state<=state2; |
---|
| 584 | readok<='0'; |
---|
| 585 | wrok<='0'; |
---|
| 586 | else |
---|
| 587 | readok<='0'; |
---|
| 588 | wrok<='0'; |
---|
| 589 | end if; |
---|
| 590 | |
---|
| 591 | |
---|
| 592 | when stpulse => if port_granted='1' then |
---|
| 593 | pop_state <= state3; --pousser la dernière donnée dehors |
---|
| 594 | data_counter <= data_counter - 1; |
---|
| 595 | wrok<='1'; |
---|
| 596 | end if; |
---|
| 597 | wrok<='0'; |
---|
| 598 | when state3 => wrok<='0'; |
---|
| 599 | data_counter <= data_counter - 1; |
---|
| 600 | pop_state <= state0; |
---|
| 601 | when stateErr => wrok<='0'; |
---|
| 602 | data_counter <= data_counter; |
---|
| 603 | pop_state <= stateErr; |
---|
| 604 | report "Error in the NoC when sending data " ; |
---|
| 605 | when others => pop_state <= state0; |
---|
| 606 | wrok<='0'; |
---|
| 607 | end case; |
---|
| 608 | end if; |
---|
| 609 | end if; |
---|
| 610 | end process; |
---|
| 611 | |
---|
| 612 | -- actions associées à chaque etat de la fsm de mealy |
---|
| 613 | pop_fsm_action : process(pop_state, fifo_out_signal,empty_latch, rd_en_signal,readok,wrok, port_granted ) |
---|
| 614 | begin |
---|
| 615 | -- code fonctionnel |
---|
| 616 | case pop_state is |
---|
| 617 | when state0 => dat_request_latch_en <= '0'; |
---|
| 618 | dat_pipeline_latch_en <= '0'; |
---|
| 619 | dat_fifo_read_signal <='0'; |
---|
| 620 | dat_request_decoder_en <= '0'; |
---|
| 621 | dat_data_out_pulse <= '0'; |
---|
| 622 | dat_priority_rotation <= '1'; |
---|
| 623 | dat_exec<='0'; |
---|
| 624 | dat_Err<='0'; |
---|
| 625 | push_dout<=fifo_out_signal; |
---|
| 626 | |
---|
| 627 | when CmdOn => dat_request_latch_en <= '0'; |
---|
| 628 | dat_pipeline_latch_en <= '0'; |
---|
| 629 | dat_fifo_read_signal <='0'; |
---|
| 630 | dat_request_decoder_en <= '0'; |
---|
| 631 | dat_data_out_pulse <= '0'; |
---|
| 632 | dat_priority_rotation <= '1'; |
---|
| 633 | dat_exec<='0'; |
---|
| 634 | dat_Err<='0'; |
---|
| 635 | push_dout<=fifo_out_signal; |
---|
| 636 | when WaitGrant => |
---|
| 637 | dat_request_latch_en <='1'; --autoriser l'identification du port de destination |
---|
| 638 | dat_pipeline_latch_en <= '0'; --pour le transmettre à travers le réseau |
---|
| 639 | dat_fifo_read_signal <= '0'; |
---|
| 640 | dat_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 641 | dat_data_out_pulse <= '0'; --transmettre le signal pour le dernier mot |
---|
| 642 | dat_priority_rotation <= Port_granted; --dès qu'on a la priorité on la garde |
---|
| 643 | dat_exec<='1'; |
---|
| 644 | dat_Err<='0'; |
---|
| 645 | push_dout<=fifo_out_signal(7 downto 4) & PORT_ID(3 downto 0); |
---|
| 646 | when ReqPort => |
---|
| 647 | dat_request_latch_en <='1'; --autoriser l'identification du port de destination |
---|
| 648 | dat_pipeline_latch_en <= '0'; --pour le transmettre à travers le réseau |
---|
| 649 | dat_fifo_read_signal <= '1'; |
---|
| 650 | dat_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 651 | dat_data_out_pulse <= '0'; --transmettre le signal pour le dernier mot |
---|
| 652 | dat_priority_rotation <= '0'; |
---|
| 653 | dat_exec<='1'; |
---|
| 654 | dat_Err<='0'; |
---|
| 655 | push_dout<=fifo_out_signal(7 downto 4) & PORT_ID(3 downto 0); |
---|
| 656 | |
---|
| 657 | when state1 => dat_request_latch_en <= '0'; |
---|
| 658 | dat_pipeline_latch_en <= rd_en_signal and port_granted; |
---|
| 659 | dat_fifo_read_signal <= rd_en_signal and port_granted; |
---|
| 660 | dat_request_decoder_en <= '1'; |
---|
| 661 | dat_data_out_pulse <= '0';--port_granted; |
---|
| 662 | dat_priority_rotation <= '0'; |
---|
| 663 | dat_exec<='1'; |
---|
| 664 | dat_Err<='0'; |
---|
| 665 | push_dout<=fifo_out_signal; |
---|
| 666 | |
---|
| 667 | when state2 |strecover => dat_request_latch_en <= '0'; |
---|
| 668 | dat_pipeline_latch_en <= port_granted and wrok and not(fifo_empty_signal); --autoriser la lecture du fifo en sortie |
---|
| 669 | dat_fifo_read_signal <= port_granted and readok; |
---|
| 670 | dat_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 671 | dat_data_out_pulse <= port_granted and wrOk and not(fifo_empty_signal); |
---|
| 672 | dat_priority_rotation <= '0'; |
---|
| 673 | dat_exec<='1'; |
---|
| 674 | dat_Err<='0'; |
---|
| 675 | push_dout<=fifo_out_signal; |
---|
| 676 | |
---|
| 677 | when stpulse => dat_request_latch_en <= '0'; --pousser la dernière donnée |
---|
| 678 | dat_pipeline_latch_en <= '0'; --autoriser la lecture du fifo en sortie |
---|
| 679 | dat_fifo_read_signal <='0'; |
---|
| 680 | dat_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 681 | dat_data_out_pulse <= '1'; -- pousser le dernier mot |
---|
| 682 | dat_priority_rotation <= '0'; |
---|
| 683 | dat_exec<='1'; |
---|
| 684 | dat_Err<='0'; |
---|
| 685 | push_dout<=fifo_out_signal; |
---|
| 686 | |
---|
| 687 | when state3 => dat_request_latch_en <= '0'; |
---|
| 688 | dat_pipeline_latch_en <= '0'; |
---|
| 689 | dat_priority_rotation <= '1'; -- libérer la priorité |
---|
| 690 | dat_fifo_read_signal <= '0'; |
---|
| 691 | dat_request_decoder_en <= '0'; --libérer le décodeur |
---|
| 692 | dat_data_out_pulse <= '0'; |
---|
| 693 | dat_exec<='0'; |
---|
| 694 | dat_Err<='0'; |
---|
| 695 | push_dout<=fifo_out_signal; |
---|
| 696 | when stateErr => dat_request_latch_en <= '0'; |
---|
| 697 | dat_pipeline_latch_en <= '0'; |
---|
| 698 | dat_priority_rotation <= '1'; -- libérer la priorité |
---|
| 699 | dat_fifo_read_signal <= '0'; |
---|
| 700 | dat_request_decoder_en <= '0'; --libérer le décodeur |
---|
| 701 | dat_data_out_pulse <= '0'; |
---|
| 702 | dat_exec<='1'; |
---|
| 703 | dat_Err<='1'; |
---|
| 704 | push_dout<=fifo_out_signal; |
---|
| 705 | when others => dat_request_latch_en <= '0'; |
---|
| 706 | dat_pipeline_latch_en <= '0'; |
---|
| 707 | dat_priority_rotation <= '1'; |
---|
| 708 | dat_fifo_read_signal <= '0'; |
---|
| 709 | dat_request_decoder_en <= '0'; |
---|
| 710 | dat_data_out_pulse <= '0'; |
---|
| 711 | dat_exec<='0'; |
---|
| 712 | dat_Err<='0'; |
---|
| 713 | push_dout<=fifo_out_signal; |
---|
| 714 | |
---|
| 715 | end case; |
---|
| 716 | end process; |
---|
| 717 | -- traitement des commandes reçues par le switch |
---|
| 718 | fsm_cmd:process(clk,cmd_in_en) |
---|
| 719 | variable timeout : natural:=0; |
---|
| 720 | variable cmdcode : natural range 0 to 255; |
---|
| 721 | begin |
---|
| 722 | if rising_edge(clk) then |
---|
| 723 | if reset_signal = '1' then |
---|
| 724 | cmdstate<=cmdstart; |
---|
| 725 | else -- il ne faut pas traiter les cmdes et les données en même temps |
---|
| 726 | case cmdstate is |
---|
| 727 | |
---|
| 728 | when cmdstart => |
---|
| 729 | if cmd_in_en='1' and dat_exec='0' and empty_latch='0' then |
---|
| 730 | cmdstate<=cmdread; |
---|
| 731 | end if; |
---|
| 732 | cmdReadOk<='0'; |
---|
| 733 | when cmdwait => if port_granted='1' then -- demande du port de sortie |
---|
| 734 | |
---|
| 735 | cmdstate<=cmdsetdest; |
---|
| 736 | elsif cmd_in_en='1' then |
---|
| 737 | cmdstate<=cmdwait; |
---|
| 738 | else |
---|
| 739 | cmdstate<=cmdstart; |
---|
| 740 | end if; |
---|
| 741 | cmdReadOk<='0'; |
---|
| 742 | when cmdread => |
---|
| 743 | -- if port_granted ='1'then -- ne pas modifier l'état des priorités si on ne l'avait pas |
---|
| 744 | cmdcode:= to_integer(unsigned(fifo_out_signal)); |
---|
| 745 | if cmdcode=1 then --code de getportid |
---|
| 746 | cmdstate<=cmdwait; |
---|
| 747 | cmdReadOk<='1'; |
---|
| 748 | else |
---|
| 749 | --ne pas prendre le code inconnu en compte |
---|
| 750 | cmdstate<=cmdend; -- la commande n'a pas été reconnu |
---|
| 751 | |
---|
| 752 | cmdReadOk<='0'; |
---|
| 753 | end if; |
---|
| 754 | -- end if; |
---|
| 755 | when cmdsetdest => |
---|
| 756 | if port_granted='1' then |
---|
| 757 | cmdstate<=cmdsetcount; |
---|
| 758 | end if; |
---|
| 759 | cmdReadOk<='0'; |
---|
| 760 | when cmdsetcount => |
---|
| 761 | if port_granted='1' then |
---|
| 762 | cmdstate<=cmdsetID; |
---|
| 763 | else |
---|
| 764 | cmdstate<=cmdsetdest; |
---|
| 765 | end if; |
---|
| 766 | cmdReadOk<='0'; |
---|
| 767 | when cmdsetID=> |
---|
| 768 | if port_granted='1' then |
---|
| 769 | cmdstate <=cmdpulse; |
---|
| 770 | end if; |
---|
| 771 | cmdReadOk<='0'; |
---|
| 772 | when cmdpulse => |
---|
| 773 | if port_granted='1' then |
---|
| 774 | cmdstate <=cmdEnd; |
---|
| 775 | end if; |
---|
| 776 | cmdReadOk<='0'; |
---|
| 777 | when cmdend => |
---|
| 778 | if cmd_in_en='0' then --éviter l'exécution en boucle |
---|
| 779 | cmdstate<=cmdstart; |
---|
| 780 | end if; |
---|
| 781 | cmdReadOk<='0'; |
---|
| 782 | |
---|
| 783 | end case; |
---|
| 784 | end if; |
---|
| 785 | end if; |
---|
| 786 | end process fsm_cmd; |
---|
| 787 | |
---|
| 788 | cmdaffect:process (cmdstate,fifo_empty_signal, port_granted, PORT_ID) |
---|
| 789 | begin |
---|
| 790 | case cmdstate is |
---|
| 791 | |
---|
| 792 | when cmdstart => |
---|
| 793 | cmd_exec<='0'; |
---|
| 794 | cmd_pipeline_latch_en <='0'; |
---|
| 795 | cmd_priority_rotation <= '1'; |
---|
| 796 | cmd_request_latch_en<='0'; |
---|
| 797 | cmd_fifo_read_signal <= '0'; |
---|
| 798 | cmd_request_decoder_en <= '0'; |
---|
| 799 | cmd_data_signal<=(others=>'0'); |
---|
| 800 | cmd_data_out_pulse <= '0'; |
---|
| 801 | |
---|
| 802 | when cmdread => |
---|
| 803 | cmd_exec<='1'; |
---|
| 804 | cmd_pipeline_latch_en <= '0'; |
---|
| 805 | cmd_fifo_read_signal <= '1'; -- vider le tampon d'entrée |
---|
| 806 | cmd_request_latch_en<='1'; --mémoriser l'adresse de destination |
---|
| 807 | cmd_request_decoder_en <= '1'; --demande d'émission |
---|
| 808 | cmd_data_out_pulse <= '0'; |
---|
| 809 | cmd_priority_rotation <= '1'; --sans priorité |
---|
| 810 | cmd_data_signal<=Port_ID; |
---|
| 811 | when cmdwait => |
---|
| 812 | cmd_exec<='1'; |
---|
| 813 | cmd_pipeline_latch_en <='0'; |
---|
| 814 | cmd_fifo_read_signal <= '0'; |
---|
| 815 | cmd_request_latch_en<='1'; |
---|
| 816 | cmd_priority_rotation <= '0'; --avec priorité |
---|
| 817 | cmd_request_decoder_en <= '1'; --demande d'émission |
---|
| 818 | cmd_data_signal<=Port_ID; |
---|
| 819 | cmd_data_out_pulse <= '0'; |
---|
| 820 | when cmdsetdest => |
---|
| 821 | --cmd_request_decoder_en <= '1'; |
---|
| 822 | cmd_exec<='1'; |
---|
| 823 | cmd_pipeline_latch_en <='1'; --empiler dans le tampon de sortie la donnée |
---|
| 824 | cmd_fifo_read_signal <='0'; |
---|
| 825 | cmd_request_latch_en<='0'; |
---|
| 826 | cmd_request_decoder_en <= '1'; --autoriser le decodeur à activer le dernier bit de request |
---|
| 827 | cmd_data_out_pulse <= '0'; |
---|
| 828 | cmd_priority_rotation <= '0'; |
---|
| 829 | cmd_data_signal<=Port_ID; -- le numéro du port et le nombre total des ports est envoyé |
---|
| 830 | when cmdsetcount => |
---|
| 831 | |
---|
| 832 | cmd_exec<='1'; |
---|
| 833 | cmd_pipeline_latch_en <='1'; -- empiler dans le tampon de sortie les données |
---|
| 834 | cmd_fifo_read_signal <='0'; |
---|
| 835 | cmd_request_latch_en<='0'; --enregistrer l'adresse de destination |
---|
| 836 | cmd_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 837 | cmd_data_out_pulse <= port_granted; |
---|
| 838 | cmd_priority_rotation <= '0'; |
---|
| 839 | cmd_data_signal<=STD_LOGIC_VECTOR(to_unsigned(3,8)); |
---|
| 840 | when cmdSetId => |
---|
| 841 | --cmd_request_decoder_en <= '1'; |
---|
| 842 | cmd_exec<='1'; |
---|
| 843 | cmd_pipeline_latch_en <='1'; |
---|
| 844 | cmd_fifo_read_signal <='0'; |
---|
| 845 | cmd_request_latch_en<='0'; --enregistrer l'adresse de destination |
---|
| 846 | cmd_request_decoder_en <= '1'; --autoriser le decodeur à activer le dernier bit de request |
---|
| 847 | cmd_data_out_pulse <= port_granted; |
---|
| 848 | cmd_priority_rotation <= '0'; |
---|
| 849 | cmd_data_signal<=Port_ID; -- le numéro du port et le nombre total des ports est envoyé |
---|
| 850 | |
---|
| 851 | when cmdpulse => cmd_exec<='1'; |
---|
| 852 | cmd_pipeline_latch_en <='0'; |
---|
| 853 | cmd_fifo_read_signal <='0'; |
---|
| 854 | cmd_request_latch_en<='0'; |
---|
| 855 | cmd_request_decoder_en <= '1'; --autoriser le decodeur activer le dernier bit de request |
---|
| 856 | cmd_data_out_pulse <= '1';--port_granted; --s'assurer que la dernière donnée est bien lue |
---|
| 857 | cmd_priority_rotation <= '0'; |
---|
| 858 | --cmd_data_signal<=Port_ID ; |
---|
| 859 | cmd_data_signal<=Port_ID; |
---|
| 860 | |
---|
| 861 | when cmdend => |
---|
| 862 | cmd_exec<='0'; |
---|
| 863 | cmd_request_latch_en <= '0'; |
---|
| 864 | cmd_pipeline_latch_en <= '0'; |
---|
| 865 | cmd_fifo_read_signal <= '0'; |
---|
| 866 | cmd_request_latch_en<='0'; |
---|
| 867 | cmd_request_decoder_en <= '0'; |
---|
| 868 | cmd_data_out_pulse <= '0'; |
---|
| 869 | cmd_priority_rotation <= '1'; |
---|
| 870 | cmd_data_signal<=(others=>'0'); |
---|
| 871 | |
---|
| 872 | |
---|
| 873 | end case ; |
---|
| 874 | end process cmdaffect; |
---|
| 875 | |
---|
| 876 | end Behavioral; |
---|
| 877 | |
---|
| 878 | |
---|