Ignore:
Timestamp:
Apr 22, 2013, 11:35:33 AM (11 years ago)
Author:
rolagamo
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/INPUT_PORT_MODULE.vhd

    r22 r65  
    4444    Port ( data_in : in  STD_LOGIC_VECTOR (Word-1 downto 0);
    4545           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
     46                          cmd_in_en :in STD_LOGIC;    --permet d'identifier les données qui sont dans le tampon
    4747           reset : in  STD_LOGIC;
    4848                          clk   : in  STD_LOGIC;
     
    7373
    7474--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
     75type fsm_states is (state0, CmdOn, WaitGrant, ReqPort, state1, state2,stpulse,stateErr, state3);-- definition du type etat pour le codage des etats des fsm
    7676type fsm_states2 is(cmdstart,cmdwait,cmdread,cmdSetDest,cmdSetCount,cmdSetId,cmdpulse,CmdEnd);
    7777signal pop_state : fsm_states;
     
    7979signal cmd_exec : std_logic:='0';  --indique que le port est en train d'exécuter une commande
    8080signal 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
     81signal dat_Err :std_logic:='0'; -- signal une erreur pendant l'exécution
     82signal readOk,CmdReadOk : std_logic:='0'; --indique s'il est possible de lire les données
    8283-- signaux utilisés dans les fsm
    83 signal request_decoder : STD_LOGIC_VECTOR(number_of_ports  downto 1);
     84signal request_decoder,req_grant : STD_LOGIC_VECTOR(number_of_ports  downto 1);
    8485signal request_decoder_en : std_logic;
    85 signal request_latch : STD_LOGIC_VECTOR(4 downto 1);   -- pourquoi pas 3 downto 0 ?
     86signal request_latch : STD_LOGIC_VECTOR(4 downto 1):=(others=>'0');   -- pourquoi pas 3 downto 0 ?
    8687signal request_latch_en : std_logic;
    8788signal pipeline_latch : std_logic_vector(Word-1 downto 0);
     
    131132
    132133data_out <= pipeline_latch ;--when cmd_exec='0' else cmd_data_signal;
    133 fifo_empty <= fifo_empty_signal;
     134fifo_empty <= empty_latch;
    134135reset_signal <= reset;
    135136grant_proc:process(clk)
    136137begin
    137138if rising_edge(clk) then
    138         if unsigned(grant)> 0 then
     139--      if unsigned(grant)> 0 then
     140        if unsigned(req_grant) > 0 then
    139141                port_granted <= '1';            --il faut veiller à ce que ce port soit vraiment autorisé
    140142        else
     
    145147rd_en_signal <= not(empty_latch) ;
    146148request <= request_decoder;
     149reg_grant:process (request_decoder,grant)
     150begin
     151req_grant<=request_decoder and grant;
     152end process reg_grant;
    147153request_word <=  request_latch & request_decoder_en;
    148154clk_signal <= clk;
     
    499505                  case pop_state is
    500506                        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                                                                       
     507                                                                        if empty_latch  ='0' then -- pile pas vide on doit dépiler                                                                     
    502508                                                                                pop_state <= WaitGrant;
    503509                                                                        end if;
     
    505511                                                                        pop_state <= CmdOn;
    506512                                                                end if;
    507                         when CmdOn => if fifo_empty_signal='1' then
     513                        when CmdOn => if empty_latch='1' and cmd_in_en='0' then
    508514                                                                pop_state <= state0;
     515                                                                elsif empty_latch='0' and cmd_in_en='1' then
     516                                                                pop_state <= CmdOn;
     517                                                                elsif empty_latch='1' and cmd_in_en='1' then
     518                                                                pop_state <= state0;
     519                                                                else -- empty_latch='0' and cmd_in_en='0'
     520                                                                pop_state <= WaitGrant;
    509521                                                                end if;
     522                                                               
    510523                        when WaitGrant => if port_granted = '1' then
    511524                                                                                --
     
    536549                                                                                  pop_state <= state2;
    537550                                                                                  ReadOk<='1';
     551                                                                                else --rd_en_signal='0' fin prématurée de la lecture
     552                                                                                        ReadOk<='0';
     553                                                                                        pop_state<=stateErr;
     554                                                                                        data_counter<=(others => '0');
    538555                                                                                end if;
    539556                                                                        else
     
    549566                                                                                data_counter <= data_counter - 1;
    550567                                                                                pop_state <= state0;
    551                                                                                                                                                                                
     568                        when stateErr =>         
     569                                                                                data_counter <= data_counter;
     570                                                                                pop_state <= stateErr;                                                                                         
    552571                        when others => pop_state <= state0;
    553572                   end case;
     
    557576
    558577-- 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 )
     578pop_fsm_action : process(pop_state, fifo_out_signal,empty_latch, rd_en_signal,readok, port_granted )
    560579  begin   
    561580-- code fonctionnel     
     
    568587                                                                dat_priority_rotation <= '1';
    569588                                                                dat_exec<='0';
     589                                                                dat_Err<='0';
    570590                                                                push_dout<=fifo_out_signal;
     591                                                               
    571592                when CmdOn =>           dat_request_latch_en <= '0'; 
    572                                                                 dat_pipeline_latch_en <= rd_en_signal;
     593                                                                dat_pipeline_latch_en <= '0';
    573594                                                                dat_fifo_read_signal <='0';
    574595                                                                dat_request_decoder_en <= '0';
     
    576597                                                                dat_priority_rotation <= '1';
    577598                                                                dat_exec<='0';
     599                                                                dat_Err<='0';
    578600                                                                push_dout<=fifo_out_signal;
    579601                when WaitGrant =>       
     
    585607                                                                dat_priority_rotation <= '0';
    586608                                                                dat_exec<='1';
     609                                                                dat_Err<='0';
    587610                                                                push_dout<=fifo_out_signal(7 downto 4) & PORT_ID(3 downto 0);
    588611                when ReqPort =>
    589612                                                                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;
     613                                                                dat_pipeline_latch_en <= '1'; --pour le transmettre à travers le réseau
     614                                                                dat_fifo_read_signal <= '1';
    592615                                                                dat_request_decoder_en <= '1';          --autoriser le decodeur activer le dernier bit de request
    593616                                                                dat_data_out_pulse <= '0';     --transmettre le signal pour le dernier mot
    594617                                                                dat_priority_rotation <= '0';
    595618                                                                dat_exec<='1';
     619                                                                dat_Err<='0';
    596620                                                                push_dout<=fifo_out_signal(7 downto 4) & PORT_ID(3 downto 0);
    597621                                                       
     
    600624                                                                dat_fifo_read_signal <= rd_en_signal and port_granted;
    601625                                                                dat_request_decoder_en <= '1';
    602                                                                 dat_data_out_pulse <= '1';
     626                                                                dat_data_out_pulse <= port_granted;
    603627                                                                dat_priority_rotation <= '0';
    604628                                                                dat_exec<='1';
     629                                                                dat_Err<='0';
    605630                                                                push_dout<=fifo_out_signal;
    606631                                                               
     
    612637                                                                dat_priority_rotation <= '0';
    613638                                                                dat_exec<='1';
     639                                                                dat_Err<='0';
    614640                                                                push_dout<=fifo_out_signal;
    615641                                                               
     
    621647                                                                dat_priority_rotation <= '0';
    622648                                                                dat_exec<='1';
     649                                                                dat_Err<='0';
    623650                                                                push_dout<=fifo_out_signal;
    624651                                                               
     
    630657                                                                dat_data_out_pulse <= '0';
    631658                                                                dat_exec<='0';
     659                                                                dat_Err<='0';
    632660                                                                push_dout<=fifo_out_signal;
    633                
     661                when stateErr =>    dat_request_latch_en <= '0';
     662                                                                dat_pipeline_latch_en <= '0';
     663                                                                dat_priority_rotation <= '1';    -- libérer la priorité
     664                                                                dat_fifo_read_signal <= '0';
     665                                                                dat_request_decoder_en <= '0';   --libérer le décodeur
     666                                                                dat_data_out_pulse <= '0';
     667                                                                dat_exec<='1';
     668                                                                dat_Err<='1';
     669                                                                push_dout<=fifo_out_signal;
    634670                when others =>    dat_request_latch_en <= '0';
    635671                                                                dat_pipeline_latch_en <= '0';
     
    639675                                                                dat_data_out_pulse <= '0';
    640676                                                                dat_exec<='0';
     677                                                                dat_Err<='0';
    641678                                                                push_dout<=fifo_out_signal;
    642679                                                                               
     
    655692       
    656693           when cmdstart  =>
    657                                 if cmd_in_en='1' and dat_exec='0' and fifo_empty_signal='0' then
    658                                 cmdstate<=cmdwait;
     694                                if cmd_in_en='1' and dat_exec='0' and empty_latch='0' then
     695                                cmdstate<=cmdread;
    659696                                end if;
    660                 when cmdwait => if fifo_empty_signal='0' and port_granted ='1' then
     697                                cmdReadOk<='0';
     698                when cmdwait => if port_granted='1' then  -- demande du port de sortie
    661699                                                               
    662                                                                         cmdstate<=cmdread;
     700                                                                        cmdstate<=cmdsetdest;
     701                                                        elsif cmd_in_en='1' then
     702                                                                cmdstate<=cmdwait;
    663703                                                        else
    664704                                                                cmdstate<=cmdstart;
    665705                                                        end if;
     706                                                        cmdReadOk<='0';
    666707                when cmdread =>
    667                                 if port_granted ='1'then -- ne pas modifier l'état des priorités si on ne l'avait pas
     708--                              if port_granted ='1'then -- ne pas modifier l'état des priorités si on ne l'avait pas
    668709                                        cmdcode:= to_integer(unsigned(fifo_out_signal));
    669710                                        if cmdcode=1 then --code de getportid
    670                                                         cmdstate<=cmdsetdest;
     711                                                        cmdstate<=cmdwait;
     712                                                        cmdReadOk<='1';
    671713                                        else
    672                                                 if port_granted='1' then
    673                                                         cmdstate<=cmdend;
    674                                                 end if;
     714                                                        --ne pas prendre le code inconnu en compte
     715                                                        cmdstate<=cmdend; -- la commande n'a pas été reconnu
     716                                               
     717                                                cmdReadOk<='0';
    675718                                        end if;
    676                                 end if;
     719--                              end if;
    677720                when cmdsetdest =>
    678721                                if port_granted='1' then
    679722                                        cmdstate<=cmdsetcount;
    680723                                end if;
     724                                cmdReadOk<='0';
    681725                when cmdsetcount =>
    682726                                if port_granted='1' then
    683727                                        cmdstate<=cmdsetID;
     728                                else
     729                                        cmdstate<=cmdsetdest;
    684730                                end if;
     731                                cmdReadOk<='0';
    685732                when cmdsetID=>
    686733                        if port_granted='1' then
    687734                        cmdstate <=cmdpulse;
    688735                        end if;
     736                        cmdReadOk<='0';
    689737                when cmdpulse =>
    690738                        if port_granted='1' then
    691739                        cmdstate <=cmdEnd;
    692740                        end if;
     741                        cmdReadOk<='0';
    693742                when cmdend  =>
    694                        
     743                        if cmd_in_en='0' then --éviter l'exécution en boucle
    695744                                cmdstate<=cmdstart;
    696                        
    697                                
     745                        end if;
     746                        cmdReadOk<='0';
    698747         
    699748        end case;
     
    715764                                                cmd_data_signal<=(others=>'0');
    716765                                                cmd_data_out_pulse <= '0';
    717         when cmdwait =>
     766
     767        when cmdread =>
     768                                                cmd_exec<='1';
     769                                                cmd_pipeline_latch_en <= '0';
     770                                                cmd_fifo_read_signal <= '1'; -- vider le tampon d'entrée
     771                                                cmd_request_latch_en<='1';    --mémoriser l'adresse de destination
     772                                                cmd_request_decoder_en <= '1';                   --demande d'émission
     773                                                cmd_data_out_pulse <= '0';
     774                                                cmd_priority_rotation <= '1';                    --sans priorité
     775                                                cmd_data_signal<=Port_ID; 
     776                when cmdwait =>
    718777                                                cmd_exec<='1';
    719778                                                cmd_pipeline_latch_en <='0';
    720779                                                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; 
     780                                                cmd_request_latch_en<='1';
     781                                                cmd_priority_rotation <= '0';    --avec priorité
     782                                                cmd_request_decoder_en <= '1';   --demande d'émission
     783                                                cmd_data_signal<=Port_ID;
     784                                                cmd_data_out_pulse <= '0';                                     
    736785        when cmdsetdest  =>
    737786                                                --cmd_request_decoder_en <= '1';
    738787                                                cmd_exec<='1';
    739                                                 cmd_pipeline_latch_en <='1';
     788                                                cmd_pipeline_latch_en <='1'; --empiler dans le tampon de sortie la donnée
    740789                                                cmd_fifo_read_signal <='0';
    741790                                                cmd_request_latch_en<='0';
     
    744793                                                cmd_priority_rotation <= '0';
    745794                                                cmd_data_signal<=Port_ID;    -- le numéro du port et le nombre total des ports est envoyé
    746                                                
     795        when cmdsetcount =>
     796                                                                 
     797                                                cmd_exec<='1';   
     798                                                cmd_pipeline_latch_en <='1'; -- empiler dans le tampon de sortie les données
     799                                                cmd_fifo_read_signal <='0';
     800                                                cmd_request_latch_en<='0';  --enregistrer l'adresse de destination
     801                                                cmd_request_decoder_en <= '1';          --autoriser le decodeur activer le dernier bit de request
     802                                                cmd_data_out_pulse <= port_granted;
     803                                                cmd_priority_rotation <= '0';
     804                                                cmd_data_signal<=STD_LOGIC_VECTOR(to_unsigned(3,8));                                   
    747805        when cmdSetId =>
    748806                                                --cmd_request_decoder_en <= '1';
     
    750808                                                cmd_pipeline_latch_en <='1';
    751809                                                cmd_fifo_read_signal <='0';
    752                                                 cmd_request_latch_en<='0';
     810                                                cmd_request_latch_en<='0';                      --enregistrer l'adresse de destination
    753811                                                cmd_request_decoder_en <= '1';          --autoriser le decodeur à activer le dernier bit de request
    754                                                 cmd_data_out_pulse <= '1';
     812                                                cmd_data_out_pulse <= port_granted;
    755813                                                cmd_priority_rotation <= '0';
    756814                                                cmd_data_signal<=Port_ID;    -- le numéro du port et le nombre total des ports est envoyé
    757815                                                                                       
    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        
    769816        when cmdpulse =>        cmd_exec<='1';
    770817                                                cmd_pipeline_latch_en <='0';
Note: See TracChangeset for help on using the changeset viewer.