OpenCores
URL https://opencores.org/ocsvn/uart16750/uart16750/trunk

Subversion Repositories uart16750

[/] [uart16750/] [trunk/] [rtl/] [vhdl/] [slib_fifo.vhd] - Diff between revs 8 and 10

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 8 Rev 10
Line 21... Line 21...
-- Boston, MA  02111-1307  USA
-- Boston, MA  02111-1307  USA
--
--
 
 
LIBRARY IEEE;
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_unsigned.all;
 
USE IEEE.numeric_std.all;
USE IEEE.numeric_std.all;
 
 
 
 
entity slib_fifo is
entity slib_fifo is
    generic (
    generic (
Line 48... Line 47...
 
 
architecture rtl of slib_fifo is
architecture rtl of slib_fifo is
    -- Signals
    -- Signals
    signal iEMPTY   : std_logic;                                -- Internal EMPTY
    signal iEMPTY   : std_logic;                                -- Internal EMPTY
    signal iFULL    : std_logic;                                -- Internal FULL
    signal iFULL    : std_logic;                                -- Internal FULL
    signal iWRAddr  : std_logic_vector(SIZE_E downto 0);        -- FIFO write address
    signal iWRAddr  : unsigned(SIZE_E downto 0);                -- FIFO write address
    signal iRDAddr  : std_logic_vector(SIZE_E downto 0);        -- FIFO read address
    signal iRDAddr  : unsigned(SIZE_E downto 0);                -- FIFO read address
    signal iUSAGE   : std_logic_vector(SIZE_E-1 downto 0);      -- FIFO usage
    signal iUSAGE   : unsigned(SIZE_E-1 downto 0);              -- FIFO usage
    -- FIFO memory
    -- FIFO memory
    type FIFO_Mem_Type is array (2**SIZE_E-1 downto 0) of std_logic_vector(WIDTH-1 downto 0);
    type FIFO_Mem_Type is array (2**SIZE_E-1 downto 0) of std_logic_vector(WIDTH-1 downto 0);
    signal iFIFOMem : FIFO_Mem_Type := (others => (others => '0'));
    signal iFIFOMem : FIFO_Mem_Type := (others => (others => '0'));
 
 
begin
begin
Line 69... Line 68...
            iWRAddr <= (others => '0');
            iWRAddr <= (others => '0');
            iRDAddr <= (others => '0');
            iRDAddr <= (others => '0');
            iEMPTY  <= '1';
            iEMPTY  <= '1';
        elsif (CLK'event and CLK='1') then
        elsif (CLK'event and CLK='1') then
            if (WRITE = '1' and iFULL = '0') then       -- Write to FIFO
            if (WRITE = '1' and iFULL = '0') then       -- Write to FIFO
                iWRAddr <= iWRAddr + '1';
                iWRAddr <= iWRAddr + 1;
            end if;
            end if;
 
 
            if (READ = '1' and iEMPTY = '0') then       -- Read from FIFO
            if (READ = '1' and iEMPTY = '0') then       -- Read from FIFO
                iRDAddr <= iRDAddr + '1';
                iRDAddr <= iRDAddr + 1;
            end if;
            end if;
 
 
            if (CLEAR = '1') then                       -- Reset FIFO
            if (CLEAR = '1') then                       -- Reset FIFO
                iWRAddr <= (others => '0');
                iWRAddr <= (others => '0');
                iRDAddr <= (others => '0');
                iRDAddr <= (others => '0');
Line 96... Line 95...
    begin
    begin
        if (RST = '1') then
        if (RST = '1') then
            --iFIFOMem(2**SIZE_E-1 downto 0) <= (others => (others => '0'));
            --iFIFOMem(2**SIZE_E-1 downto 0) <= (others => (others => '0'));
        elsif (CLK'event and CLK = '1') then
        elsif (CLK'event and CLK = '1') then
            if (WRITE = '1' and iFULL = '0') then
            if (WRITE = '1' and iFULL = '0') then
                iFIFOMem(CONV_INTEGER(iWRAddr(SIZE_E-1 downto 0))) <= D;
                iFIFOMem(to_integer(iWRAddr(SIZE_E-1 downto 0))) <= D;
            end if;
            end if;
            Q <= iFIFOMem(CONV_INTEGER(iRDAddr(SIZE_E-1 downto 0)));
            Q <= iFIFOMem(to_integer(iRDAddr(SIZE_E-1 downto 0)));
        end if;
        end if;
    end process;
    end process;
 
 
    -- Usage counter
    -- Usage counter
    FF_USAGE: process (RST, CLK)
    FF_USAGE: process (RST, CLK)
Line 112... Line 111...
        elsif (CLK'event and CLK = '1') then
        elsif (CLK'event and CLK = '1') then
            if (CLEAR = '1') then
            if (CLEAR = '1') then
                iUSAGE <= (others => '0');
                iUSAGE <= (others => '0');
            else
            else
                if (READ = '0' and WRITE = '1' and iFULL = '0') then
                if (READ = '0' and WRITE = '1' and iFULL = '0') then
                    iUSAGE <= iUSAGE + '1';
                    iUSAGE <= iUSAGE + 1;
                end if;
                end if;
                if (WRITE = '0' and READ = '1' and iEMPTY = '0') then
                if (WRITE = '0' and READ = '1' and iEMPTY = '0') then
                    iUSAGE <= iUSAGE - '1';
                    iUSAGE <= iUSAGE - 1;
                end if;
                end if;
            end if;
            end if;
        end if;
        end if;
    end process;
    end process;
 
 
    -- Output signals
    -- Output signals
    EMPTY <= iEMPTY;
    EMPTY <= iEMPTY;
    FULL  <= iFULL;
    FULL  <= iFULL;
    USAGE <= iUSAGE;
    USAGE <= std_logic_vector(iUSAGE);
 
 
end rtl;
end rtl;
 
 
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.