Professional Documents
Culture Documents
Until next read operation it would be set, data sent during this
period will be lost.
Fig 4
Reset = 1 both read and write pointer points to 0th location of
ram until reset is cleared.
FIFO is a First-In-First-Out memory queue with control logic that manages the read and
write operations, generates status flags like fifo empty fifo full. It is often used to Control
the flow of data between source and destination.
Introduction
FIFO full and FIFO empty flags are of great concern as no data should be
written in full condition and no data should be read in empty condition, as it
can lead to loss of data or generation of non relevant data. The full and
empty conditions of FIFO are controlled using read and write pointers.
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
Entity Rams is
END Rams;
Begin
Process(clk)
Begin
if ( wr = '1') then
a <= conv_integer(waddr);
end if;
if ( rd = '1') then
b <= conv_integer(raddr);
End if;
End if;
end process;
End Behave;
Design of 7 bit counter
VHDL program
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity wcounter is
end wcounter;
begin
process(clk)
begin
if(reset='1') then
qw := "0000000";
elsif(qw = "1111111")then
qw :="0000000";
else
qw := qw+1;
end if;
end if;
end process;
end wrb;
Design of control logic
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity emf is
dr,rw : in std_logic;
fu : inout STD_LOGIC;
em : inout STD_LOGIC;
end emf;
begin
b1 <= (wrad(0) xnor rrad(0)) and(wrad(1) xnor rrad(1)) and(wrad(2) xnor rrad(2))
and(wrad(3) xnor rrad(3)) and(wrad(4) xnor rrad(4)) and(wrad(5) xnor rrad(5));
2) Two7 bit counters are used to provide write and read address to
Ram, only 6 bits are sufficient to address 64 byte of memory but to
differentiate between fifo full and fifo empty condition we are using
another bit
3) Control logic
a) It gets the read counter, write counter, read enable and write
enable of FIFO as input.
VHDL Program
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity fifo is
end fifo;
component Rams
Port (
wr,rd : in std_logic;
clk : in std_logic;
end component;
component emf
dr,rw : in std_logic;
fu : inout STD_LOGIC;
em : inout STD_LOGIC;
end component;
component wcounter
end component;
begin
end fifob;
1) Frequency divider is a 17 bit counter msb of counter is used as clock for FIFO
Library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity freq is
end freq;
architecture Behavioral of freq is
begin
process(clk1)
begin
if (mw="11111111111111111") then
mw := "00000000000000000";
else
mw := mw+1;
end if;
end if;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity conversion is
end conversion;
begin
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mux is
end mux;
begin
i2 when '1',
i1 when others;
end Behavioral;
c) 1 to 2 decoder
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity decoder is
end decoder;
begin
end Behaviora
VHDL Program
entity final is
end final;
component fifo is
end component;
component decoder is
end component;
component freq is
end freq;
component mux is
end component;
component conversion is
end component;
begin
end Behavioral