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

Subversion Repositories dirac

[/] [dirac/] [trunk/] [src/] [common/] [FIFO.vhd] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 petebleack
-- ***** BEGIN LICENSE BLOCK *****
2
-- 
3 5 petebleack
-- $Id: FIFO.vhd,v 1.2 2005-05-27 16:00:28 petebleackley Exp $ $Name: not supported by cvs2svn $
4 2 petebleack
-- *
5
-- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
-- *
7
-- * The contents of this file are subject to the Mozilla Public License
8
-- * Version 1.1 (the "License"); you may not use this file except in compliance
9
-- * with the License. You may obtain a copy of the License at
10
-- * http://www.mozilla.org/MPL/
11
-- *
12
-- * Software distributed under the License is distributed on an "AS IS" basis,
13
-- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14
-- * the specific language governing rights and limitations under the License.
15
-- *
16
-- * The Original Code is BBC Research and Development code.
17
-- *
18
-- * The Initial Developer of the Original Code is the British Broadcasting
19
-- * Corporation.
20
-- * Portions created by the Initial Developer are Copyright (C) 2004.
21
-- * All Rights Reserved.
22
-- *
23
-- * Contributor(s): Peter Bleackley (Original author)
24
-- *
25
-- * Alternatively, the contents of this file may be used under the terms of
26
-- * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
27
-- * Public License Version 2.1 (the "LGPL"), in which case the provisions of
28
-- * the GPL or the LGPL are applicable instead of those above. If you wish to
29
-- * allow use of your version of this file only under the terms of the either
30
-- * the GPL or LGPL and not to allow others to use your version of this file
31
-- * under the MPL, indicate your decision by deleting the provisions above
32
-- * and replace them with the notice and other provisions required by the GPL
33
-- * or LGPL. If you do not delete the provisions above, a recipient may use
34
-- * your version of this file under the terms of any one of the MPL, the GPL
35
-- * or the LGPL.
36
-- * ***** END LICENSE BLOCK ***** */
37
 
38
 
39
library IEEE;
40
use IEEE.STD_LOGIC_1164.ALL;
41
use IEEE.STD_LOGIC_ARITH.ALL;
42
use IEEE.STD_LOGIC_UNSIGNED.ALL;
43
 
44
--  Uncomment the following lines to use the declarations that are
45
--  provided for instantiating Xilinx primitive components.
46
--library UNISIM;
47
--use UNISIM.VComponents.all;
48
 
49 5 petebleack
  entity FIFO is
50
        generic (RANK : integer range 0 to 16 :=8;
51
        WIDTH : integer range 1 to 16);
52 2 petebleack
    Port ( WRITE_ENABLE : in std_logic;
53 5 petebleack
           DATA_IN : in std_logic_vector(WIDTH - 1 downto 0);
54 2 petebleack
           READ_ENABLE : in std_logic;
55
           RESET : in std_logic;
56
           CLOCK : in std_logic;
57 5 petebleack
           DATA_OUT : out std_logic_vector(WIDTH - 1 downto 0);
58
           EMPTY : out std_logic);
59 2 petebleack
end FIFO;
60
 
61
architecture RTL of FIFO is
62 5 petebleack
 
63
 
64 2 petebleack
        function TWO_TO_N(N:    integer) return integer is
65
        variable A:     integer;
66
        begin
67
        A := 1;
68
        for Z in 0 to N - 1 loop
69
        A := 2*A;
70
        end loop;
71
        return A;
72
        end function TWO_TO_N;
73 5 petebleack
        signal WRITE_ADDRESS :  std_logic_vector (RANK - 1 downto 0);
74 2 petebleack
        signal READ_ADDRESS :   std_logic_vector (RANK - 1 downto 0);
75
        type MATRIX is
76 5 petebleack
        array (TWO_TO_N(RANK) - 1 downto 0) of std_logic_vector(WIDTH - 1 downto 0);
77 2 petebleack
        signal GET_OUTPUT: MATRIX;
78 5 petebleack
 
79 2 petebleack
        signal EMPTY_OUT :      std_logic;
80
 
81
 
82 5 petebleack
begin
83
-- Counters
84 2 petebleack
 
85 5 petebleack
COUNT: process (CLOCK)
86
        begin
87
        if (CLOCK'event and CLOCK = '1') then
88
                if (RESET = '1') then
89
                        READ_ADDRESS <= (others => '0');
90
                        WRITE_ADDRESS <= (others => '0');
91
                else
92
                        if WRITE_ENABLE = '1' then
93
                                WRITE_ADDRESS <= WRITE_ADDRESS + "1";
94
                        end if;
95
                        if READ_ENABLE = '1' and EMPTY_OUT = '0' then
96
                                READ_ADDRESS <= READ_ADDRESS + "1";
97
                        end if;
98
                end if;
99 2 petebleack
        end if;
100 5 petebleack
end process COUNT;
101 2 petebleack
 
102
 
103
 
104
 
105 5 petebleack
ZEROVALUE : process (READ_ADDRESS, WRITE_ADDRESS)
106 2 petebleack
begin
107 5 petebleack
        if READ_ADDRESS = WRITE_ADDRESS then
108
        EMPTY_OUT <= '1';
109 2 petebleack
        else
110 5 petebleack
        EMPTY_OUT <= '0';
111 2 petebleack
        end if;
112 5 petebleack
end process ZEROVALUE;
113 2 petebleack
 
114 5 petebleack
EMPTY <= EMPTY_OUT;
115 2 petebleack
 
116 5 petebleack
SETDATA: process (CLOCK)
117
        begin
118
        if CLOCK'event and CLOCK = '1' then
119
        if WRITE_ENABLE = '1' then
120
                GET_OUTPUT(conv_integer(WRITE_ADDRESS)) <= DATA_IN;
121
        end if;
122
        end if;
123
        end process SETDATA;
124 2 petebleack
 
125
 
126 5 petebleack
        DATA_OUT <= GET_OUTPUT(conv_integer(READ_ADDRESS));
127 2 petebleack
 
128
 
129 5 petebleack
end RTL;
130 2 petebleack
 

powered by: WebSVN 2.1.0

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