FIFO Implementation and Testing

Digital Design, VHDL · course

Browse all électronique et automatique documents

Exemple : FIFO (First In First Out)

ACLR

CLOCK

DATA_IN

width

FIFO

RE

WE

EF

DATA_OUT

width

FF

-- *

--

--

--

--

--

--

--

Spécifications de la FIFO :

WE : Ordre d'écriture (actif niveau haut)

RE : Ordre de lecture (actif niveau haut)

ACLR : Ordre de RAZ (actif niveau haut)

CLOCK : Horloge

FF : Sortie FIFO pleine (Actif niveau haut)

EF : Sortie FIFO vide (Actif niveau haut)

WIDTH : Taille des données stockées dans la FIFO

DEPTH : Taille de la FIFO

--

--

-- *

library ieee;

use ieee.std_logic_1164.all;

use IEEE.std_logic_arith.all;

entity fifo is

generic (width : integer := 8;

depth : integer := 8);

port (

Data_in

Aclr

WE

RE

Clock

Advertisement

Data_out

FF

EF

: in std_logic_vector(width-1 downto 0);

: in std_logic;

: in std_logic ;

: in std_logic ;

: in std_logic ;

: out std_logic_vector(width-1 downto 0);

: out std_logic;

: out std_logic);

end fifo;

library ieee;

use ieee.std_logic_1164.all;

use IEEE.std_logic_arith.all;

architecture behavioral of fifo is

type MEM is array (0 to depth-1) of

std_logic_vector(width-1 downto 0);

signal ramTmp : MEM;

signal WAddress : integer range 0 to depth-1;

signal RAddress : integer range 0 to depth-1;

Begin

-- #####################################################

-- # Write Functional Section

-- #####################################################

WRITE_POINTER : process (Aclr,Clock)

begin

if (Aclr = ‘1') then

WAddress <= 0;

elsif rising_edge(Clock) then

if (WE = '1') then

if (WAddress = depth-1) then WAddress <= 0;

else WAddress <= WAddress + 1; end if;

end if;

end if;

end process;

WRITE_RAM : process (Clock)

begin

if rising_edge(Clock) then

if (WE = '1') then

ramTmp(WAddress) <= Data_in;

end if;

end if;

end process;

Advertisement

-- ####################################################

-- # Read Functional Section

-- ####################################################

READ_POINTER : process (Aclr,Clock)

begin

if (Aclr = ‘1') then

RAddress <= 0;

elsif rising_edge(Clock) then

if (RE = '1') then

if (RAddress = depth-1) then

RAddress <= 0;

else

RAddress <= RAddress + 1;

end if;

end if;

end if;

end process;

READ_RAM : process (Clock)

begin

if rising_edge(Clock) then

if (RE = '1') then

Data_out <= ramTmp(RAddress);

end if;

end if;

end process;

-- ######################################################

-- # Full Flag Functional Section : Active high

-- #####################################################

FFLAG : process (Aclr,Clock)

begin

if (Aclr = ‘1’) then

FF <= '0';

elsif rising_edge(Clock) then

if (WE = '1' and RE = '0') then

if ((WAddress = RAddress-1) or

((WAddress = depth-1) and (RAddress = 0))) then FF <= '1';

end if;

elsif (WE = '0' and RE = '1') then

FF <= '0';

end if;

end if;

end process;

-- #####################################################

-- # Empty Flag Functional Section : Active high

Advertisement

-- #####################################################

EFLAG : process (Aclr,Clock)

begin

if (Aclr = ‘1') then

EF <= ‘1';

elsif rising_edge(Clock) then

if (RE = '1' and WE = '0') then

if ((WAddress = RAddress+1) or

((RAddress = depth-1) and (WAddress = 0))) then EF <= ‘1';

end if;

elsif (RE = '0' and WE = '1') then

EF <= ‘0';

end if;

end if;

end process;

end behavioral;

Scénario pour le test de la FIFO

Activation de l’initialisation Aclr = 1

  • Vérification de l’initialisation des pointeurs d’adresses
  • Vérification du FF et EF
  • Vérification de la priorité d’Aclr

Ecriture sans lecture de 0 à depth-1 + 4

  • Vérification du FF
  • Vérification de la réécriture

Lecture sans écriture de 0 à depth-1+4 (après avoir rempli la FIFO)

  • Vérification du EF
  • Vérification de la relecture

Ecriture et lecture successives

  • Vérification du First-In First-Out

Exemple : 3 écritures, 2 lectures, 1 écriture, …

Ecriture et lecture simultanées au même rythme

  • Vérification du First-In First-Out

Ecriture et lecture simultanées à des rythmes différents

  • Vérification du First-In First-Out

Ecriture + rapide que la lecture

  • Vérification du flag FF
  • Vérification de la réécriture

Lecture + rapide que l’écriture

  • Vérification du flag EF
  • Vérification de la relecture

FIFO

FIFO

data_out

q

8

8

sortie_fifo

sortie_fifo

data_in

data

Advertisement

clk

clk

clr

clr

ef

ef

ff

ff

re

re

we

we

reout weout

reout weout

ff

ff

8

data_out

clkout clrout

clkout

clrout

Donnees

8

reset

clk

clrin

data_in

clrin

clkin

clkin

Unite_controle

Unite_controle

wein

rein

ef

ef

rein

wein

lecture

écriture