Changeset 64 for PROJECT_CORE_MPI/CORE_MPI/BRANCHES/v0.03/DMA_ARBITER.vhd
- Timestamp:
- Apr 22, 2013, 11:35:01 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PROJECT_CORE_MPI/CORE_MPI/BRANCHES/v0.03/DMA_ARBITER.vhd
r41 r64 17 17 -- Revision: 09/07/2012 18 18 -- 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 19 22 -- Additional Comments: Ce module pourra être optimisé pour générer les adresses automatiquement 20 23 -- par le controleur DMA lorsqu'il est sollicité par la périphérie … … 62 65 signal dma_rd_logic : std_logic_vector(3 downto 0):=(others=>'0'); 63 66 signal dma_wr_logic : std_logic_vector(3 downto 0):=(others=>'0'); 67 signal dma_rd_latch,dma_wr_latch: std_logic_vector(3 downto 0):=(others=>'0'); 64 68 signal dma_req_wr, dma_req_rd : std_logic; 69 signal last_grant_rd,last_grant_wr : STD_LOGIC_vector(3 downto 0):=(others=>'0'); 65 70 signal tmp :std_logic_vector(3 downto 0):="0000"; 66 71 … … 68 73 --========================================================================== 69 74 ---le MUX qui contrôle les adresses est géré à l'extérieur du contrôleur DMA 75 dma_sync: process (clk) 76 begin 70 77 data_rd_out<=data_rd_mem ; 71 78 data_wr_mem <= data_wr_in; 72 79 address_out_rd <= address_rd; 73 80 address_out_wr <= address_wr; 81 82 end process; 83 --dma_rd_grant<= dma_rd_logic; 84 --dma_wr_grant<= dma_wr_logic; 85 dma_rd_grant<= dma_rd_latch; 86 dma_wr_grant<= dma_wr_latch; 74 87 --========================================================================== 75 88 … … 85 98 -- dma_req_rd<=dma_req_rd or dma_rd_request(i); -- construire le signal request vers l'extérieur 86 99 --loop; 87 hold_req<= dma_req_rd or dma_req_wr; --envoyer un Hold vers l'application100 hold_req<='1' when dma_req_rd='1' or dma_req_wr='1' else '0'; --envoyer un Hold vers l'application 88 101 89 102 90 103 -- machine à etat du DMAC 91 dmac_process : process(clk )104 dmac_process : process(clk,reset) 92 105 --variable tmp : natural range 0 to 15; 93 106 variable tmp_rd,tmp_wr: std_logic_vector(3 downto 0); … … 106 119 req_wr:='0'; 107 120 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 écriture121 if req_wr='0' then --tant que le Ctrl DMA est libre alors faire bouger la priorité en écriture 109 122 case dma_wr_request is 110 123 when "0001" => pri_wr<=0; … … 130 143 131 144 when others => 132 if req_rd='1' then 145 if req_rd='1' then --demande simultané de lecture et d'écriture 133 146 134 147 if dma_rd_request(pri_rd)='1' then … … 148 161 end if; 149 162 150 else 163 else --on affecte l'accè à la mémoire suivant le round robbin 151 164 tmp_wr:= (dma_wr_request and prio_wr) ; 152 165 dma_wr_logic <=tmp_wr; … … 166 179 end if; 167 180 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 169 201 end if; 170 202 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é 172 204 case dma_rd_request is 173 205 when "0001" => pri_rd<=0; … … 243 275 req_rd:='0'; 244 276 dma_req_rd<= '0'; 245 dma_rd_logic <="0000";277 246 278 247 279 248 280 req_wr:='0'; 249 281 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"; 251 285 252 286 end if; 287 253 288 when wait_ack => -- l'application doit autoriser l'utilisation de la RAM par le Core 254 289 if dma_wr_request(pri_wr) ='1' or dma_rd_request(pri_rd) ='1' then 255 290 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 -- 272 293 dmac_state <= Readwrite; 273 294 elsif dma_wr_request(pri_wr) ='0' and dma_rd_request(pri_rd) ='1' then … … 278 299 dmac_state<=Idle; 279 300 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 281 326 when Writing => if dma_wr_request(pri_wr) ='1' then 282 327 if hold_ack='1' then … … 292 337 elsif dma_rd_request(pri_rd) ='1' then 293 338 dmac_state <= Reading; 339 req_wr:='0'; 294 340 else 295 341 dmac_state <= idle; 342 req_wr:='0'; 296 343 end if; 297 344 … … 331 378 elsif dma_wr_request(pri_wr) ='1' then 332 379 dmac_state<=writing; 380 req_rd:='0'; 333 381 else 334 382 dmac_state <= idle; 383 req_rd:='0'; 335 384 end if; 336 385 when others => dmac_state <= idle; … … 349 398 ram_en <='0'; 350 399 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'); 353 402 --address_out_rd <= address_rd; 354 403 --hold_req<='0'; … … 356 405 ram_en <='0'; 357 406 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'); 360 409 --address_out_rd <= (others=>'Z'); 361 410 --address_out_wr <= (others=>'Z'); 362 411 --hold_req<='1'; 363 412 when arbiter_ack => --à optimiser pour gagner un cycle 364 ram_en <=' 1';413 ram_en <='0'; 365 414 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'); 368 417 --address_out_rd <= (others=>'Z'); 369 418 --address_out_wr <= (others=>'Z'); … … 371 420 ram_en <='1'; 372 421 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'); 376 425 --address_out_rd <= (others=>'Z'); 377 426 --address_out_wr <= address_wr; … … 381 430 ram_en <='1'; 382 431 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'; 387 436 388 437 --address_out_rd <= address_rd; … … 392 441 ram_en <='1'; 393 442 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'; 397 446 398 447 --address_out_rd <= address_rd; … … 402 451 ram_en <='0'; 403 452 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'); 406 455 --address_out_rd <= (others=>'Z'); 407 456 --address_out_wr <= (others=>'Z');
Note: See TracChangeset
for help on using the changeset viewer.