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

Legend:

Unmodified
Added
Removed
  • PROJECT_CORE_MPI/CORE_MPI/BRANCHES/v0.03/DMA_ARBITER.vhd

    r41 r64  
    1717-- Revision: 09/07/2012
    1818-- Revision 1.01 - File Created
     19-- Revision 1.2 - 19/03/2013
     20-- Correction de bugs et optimisation du nombre de cycles
     21--      Création d'un testbench                                 
    1922-- Additional Comments: Ce module pourra être optimisé pour générer les adresses automatiquement
    2023-- par le controleur DMA lorsqu'il est sollicité par la périphérie
     
    6265signal dma_rd_logic : std_logic_vector(3 downto 0):=(others=>'0');
    6366signal dma_wr_logic : std_logic_vector(3 downto 0):=(others=>'0');
     67signal dma_rd_latch,dma_wr_latch: std_logic_vector(3 downto 0):=(others=>'0');
    6468signal dma_req_wr, dma_req_rd : std_logic;
     69signal last_grant_rd,last_grant_wr : STD_LOGIC_vector(3 downto 0):=(others=>'0');
    6570signal tmp :std_logic_vector(3 downto 0):="0000";
    6671
     
    6873--==========================================================================
    6974---le MUX qui contrôle les adresses est géré à l'extérieur du contrôleur DMA
     75dma_sync: process (clk)
     76begin
    7077data_rd_out<=data_rd_mem ;
    7178data_wr_mem <= data_wr_in;
    7279address_out_rd <= address_rd;
    7380address_out_wr <= address_wr;
     81
     82end process;
     83--dma_rd_grant<= dma_rd_logic;
     84--dma_wr_grant<= dma_wr_logic;
     85dma_rd_grant<= dma_rd_latch;
     86dma_wr_grant<= dma_wr_latch;
    7487--==========================================================================
    7588
     
    8598-- dma_req_rd<=dma_req_rd or dma_rd_request(i);  -- construire le signal request vers l'extérieur
    8699--loop;
    87 hold_req<=dma_req_rd or dma_req_wr; --envoyer un Hold vers l'application
     100hold_req<='1' when dma_req_rd='1' or dma_req_wr='1' else '0'; --envoyer un Hold vers l'application
    88101
    89102
    90103-- machine à etat du DMAC
    91 dmac_process : process(clk)
     104dmac_process : process(clk,reset)
    92105--variable tmp : natural range 0 to 15;
    93106variable tmp_rd,tmp_wr: std_logic_vector(3 downto 0);
     
    106119                                req_wr:='0';
    107120          else
    108                                 if req_wr='0' or dma_wr_request="0000" then --tant que le Ctrl DMA est libre alors faire bouger la priorité en écriture
     121                                if req_wr='0' then --tant que le Ctrl DMA est libre alors faire bouger la priorité en écriture
    109122                                case dma_wr_request is
    110123                                when "0001" => pri_wr<=0;
     
    130143                                                                       
    131144                                when others =>
    132                                                                         if req_rd='1' then
     145                                                                        if req_rd='1' then --demande simultané de lecture et d'écriture
    133146                                                                       
    134147                                                                                if dma_rd_request(pri_rd)='1'  then
     
    148161                                                                                end if;
    149162                                                                               
    150                                                                         else
     163                                                                        else --on affecte l'accè à la mémoire suivant le round robbin
    151164                                                                                tmp_wr:= (dma_wr_request and prio_wr) ;
    152165                                                                                dma_wr_logic <=tmp_wr;
     
    166179                                                                 end if;
    167180                                end case;
    168                                        
     181                                else   --req_wr='1'
     182                               
     183                                 --demande simultané de lecture et d'écriture
     184                                                                       
     185                                                                                if dma_rd_request(pri_wr)='1'  then
     186                                                                                                pri_rd<=pri_wr;
     187                                                                                                req_rd:='1';
     188                                                                                                prio_rd<=prio_wr;
     189--                                                                                              for i in 0 to 3 loop
     190--                                                                                               if i=pri_rd then
     191--                                                                                                prio_wr(i)<='1';
     192--                                                                                                dma_wr_logic(i)<='1';
     193--                                                                                               else
     194--                                                                                                      prio_wr(i)<='0';
     195--                                                                                                 dma_wr_logic(i)<='0';
     196--                                                                                               end if;
     197--                                                                                              end loop;                                       
     198                                                                                               
     199                                                                                end if;
     200
    169201                                end if;
    170202                               
    171                                 if req_rd='0' or dma_rd_request="0000" then --tant que le Ctrl DMA est libre alors faire bouger la priorité
     203                                if req_rd='0' then --tant que le Ctrl DMA est libre alors faire bouger la priorité
    172204                                case dma_rd_request is
    173205                                when "0001" => pri_rd<=0;
     
    243275                                                                        req_rd:='0';
    244276                                                                        dma_req_rd<= '0';
    245                                                                         dma_rd_logic <="0000";
     277                                                                       
    246278                                                                       
    247279                                                                       
    248280                                                                        req_wr:='0';
    249281                                                                        dma_req_wr<= '0';
    250                                                                         dma_wr_logic <="0000";
     282                                                                       
     283                                                                        dma_wr_logic <="0000"; --aucun accès mémoire n'est accrédité
     284                                                                        dma_rd_logic <="0000";
    251285                                                                                       
    252286                                                        end if;
     287                                                       
    253288                        when wait_ack =>  -- l'application doit autoriser l'utilisation de la RAM par le Core
    254289                                                if dma_wr_request(pri_wr) ='1' or dma_rd_request(pri_rd) ='1' then
    255290                                                        if hold_ack='1' then
    256                                                                 dmac_state<=arbiter_ack;
    257                                                         end if;
    258                                                 else
    259                                                        
    260                                                         if dma_wr_request(pri_wr) ='0' then
    261                                                         req_wr:='0';-- forcer une nouvelle recherche de priorité
    262                                                         end if;
    263                                                        
    264                                                         if dma_rd_request(pri_rd) ='0' then
    265                                                                 req_rd:='0';
    266                                                         end if;
    267                                                         dmac_state<=Idle;
    268                                                 end if;
    269                                                
    270                                
    271                         when arbiter_ack => if dma_wr_request(pri_wr) ='1' and dma_rd_request(pri_rd) ='1' then --
     291                                                                --dmac_state<=arbiter_ack;
     292                                                                if dma_wr_request(pri_wr) ='1' and dma_rd_request(pri_rd) ='1' then --
    272293                                                                        dmac_state <= Readwrite;
    273294                                                                 elsif dma_wr_request(pri_wr) ='0' and dma_rd_request(pri_rd) ='1' then
     
    278299                                                                                        dmac_state<=Idle;
    279300                                                                end if;
    280                                                                
     301                                                        end if;
     302                                                else
     303                                                       
     304                                                        if dma_wr_request(pri_wr) ='0' then
     305                                                        req_wr:='0';-- forcer une nouvelle recherche de priorité
     306                                                        end if;
     307                                                       
     308                                                        if dma_rd_request(pri_rd) ='0' then
     309                                                                req_rd:='0';
     310                                                        end if;
     311                                                        dmac_state<=Idle;
     312                                                end if;
     313                                               
     314                               
     315                        when arbiter_ack =>
     316--                                                      if dma_wr_request(pri_wr) ='1' and dma_rd_request(pri_rd) ='1' then --
     317--                                                                      dmac_state <= Readwrite;
     318--                                                               elsif dma_wr_request(pri_wr) ='0' and dma_rd_request(pri_rd) ='1' then
     319--                                                                                      dmac_state <= Reading;
     320--                                                              elsif dma_wr_request(pri_wr) ='1' and dma_rd_request(pri_rd) ='0' then
     321--                                                                                      dmac_state <= Writing;
     322--                                                              else
     323                                                                                        dmac_state<=Idle;
     324--                                                              end if;
     325                                                                -- cet état a été combiné au précédent pour gagner un cycle
    281326                        when Writing => if dma_wr_request(pri_wr) ='1' then
    282327                                                                                if hold_ack='1' then
     
    292337                                                                 elsif dma_rd_request(pri_rd) ='1' then
    293338                                                                                dmac_state <= Reading;
     339                                                                                req_wr:='0';
    294340                                                                 else
    295341                                                                                dmac_state <= idle;
     342                                                                                req_wr:='0';
    296343                                                                end if;
    297344                       
     
    331378                                                                 elsif dma_wr_request(pri_wr) ='1' then
    332379                                                                                dmac_state<=writing;
     380                                                                                req_rd:='0';
    333381                                                                 else
    334382                                                                                dmac_state <= idle;
     383                                                                                req_rd:='0';
    335384                                                                end if;
    336385                        when others => dmac_state <= idle;
     
    349398                                                        ram_en <='0';
    350399                                                        ram_we <='0';
    351                                                         dma_wr_grant <=(others=>'0');
    352                                                         dma_rd_grant <=(others=>'0');
     400                                                        dma_wr_latch <=(others=>'0');
     401                                                        dma_rd_latch <=(others=>'0');
    353402                                                        --address_out_rd <= address_rd;
    354403                                                        --hold_req<='0';
     
    356405                                                        ram_en <='0';
    357406                                                        ram_we <='0';
    358                                                         dma_wr_grant<=(others=>'0');
    359                                                         dma_rd_grant<=(others=>'0');
     407                                                        dma_wr_latch<=(others=>'0');
     408                                                        dma_rd_latch<=(others=>'0');
    360409                                                        --address_out_rd <= (others=>'Z');
    361410                                                        --address_out_wr <= (others=>'Z');
    362411                                                        --hold_req<='1';
    363412                when arbiter_ack =>  --à optimiser pour gagner un cycle
    364                                                         ram_en <='1';
     413                                                        ram_en <='0';
    365414                                                        ram_we <='0';
    366                                                         dma_wr_grant<=(others=>'0');
    367                                                         dma_rd_grant<=(others=>'0');
     415                                                        dma_wr_latch<=(others=>'0');
     416                                                        dma_rd_latch<=(others=>'0');
    368417                                                        --address_out_rd <= (others=>'Z');
    369418                                                        --address_out_wr <= (others=>'Z');
     
    371420                                                        ram_en <='1';
    372421                                                        ram_we <='1';
    373                                                         dma_wr_grant<=(others=>'0');
    374                                                         dma_wr_grant(pri_wr) <='1';
    375                                                         dma_rd_grant <=(others=>'0');
     422                                                        dma_wr_latch<=(others=>'0');
     423                                                        dma_wr_latch(pri_wr) <='1';
     424                                                        dma_rd_latch <=(others=>'0');
    376425                                                        --address_out_rd <= (others=>'Z');
    377426                                                        --address_out_wr <= address_wr;
     
    381430                                                        ram_en <='1';
    382431                                                        ram_we <='1';
    383                                                         dma_wr_grant<=(others=>'0');
    384                                                         dma_wr_grant(pri_wr) <='1';
    385                                                         dma_rd_grant<=(others=>'0');
    386                                                         dma_rd_grant(pri_rd)<='1';
     432                                                        dma_wr_latch<=(others=>'0');
     433                                                        dma_wr_latch(pri_wr) <='1';
     434                                                        dma_rd_latch<=(others=>'0');
     435                                                        dma_rd_latch(pri_rd)<='1';
    387436                                                       
    388437                                                        --address_out_rd <= address_rd;
     
    392441                                                        ram_en <='1';
    393442                                                        ram_we <='0';
    394                                                         dma_wr_grant<=(others=>'0');
    395                                                         dma_rd_grant<=(others=>'0');
    396                                                         dma_rd_grant(pri_rd)<='1';
     443                                                        dma_wr_latch<=(others=>'0');
     444                                                        dma_rd_latch<=(others=>'0');
     445                                                        dma_rd_latch(pri_rd)<='1';
    397446                                                       
    398447                                                        --address_out_rd <= address_rd;
     
    402451                                                   ram_en <='0';
    403452                                                        ram_we <='0';
    404                                                         dma_wr_grant <=(others=>'0');
    405                                                         dma_rd_grant <=(others=>'0');
     453                                                        dma_wr_latch <=(others=>'0');
     454                                                        dma_rd_latch <=(others=>'0');
    406455                                                        --address_out_rd <= (others=>'Z');
    407456                                                        --address_out_wr <= (others=>'Z');
Note: See TracChangeset for help on using the changeset viewer.