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