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

Subversion Repositories marca

[/] [marca/] [tags/] [INITIAL/] [vhdl/] [fifo.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jeunes2
--
2
--      fifo.vhd
3
--
4
--      simple fifo
5
--
6
--      uses FF and every rd or wr has to 'bubble' through the hole fifo.
7
--      
8
--      Author: Martin Schoeberl        martin.schoeberl@chello.at
9
--
10
--
11
--      resources on ACEX1K
12
--
13
--              (width+2)*depth-1 LCs
14
--
15
--
16
--      2002-01-06      first working version
17
--      2002-11-03      a signal for reaching threshold
18
--      2005-02-20      change entity order for modelsim vcom
19
--
20
 
21
library ieee;
22
use ieee.std_logic_1164.all;
23
 
24
use work.marca_pkg.all;
25
 
26
entity fifo_elem is
27
 
28
  generic (width : integer);
29
  port (
30
    clk         : in std_logic;
31
    reset       : in std_logic;
32
 
33
    din         : in std_logic_vector(width-1 downto 0);
34
    dout        : out std_logic_vector(width-1 downto 0);
35
 
36
    rd          : in std_logic;
37
    wr          : in std_logic;
38
 
39
    rd_prev     : out std_logic;
40
    full        : out std_logic
41
    );
42
end fifo_elem;
43
 
44
architecture rtl of fifo_elem is
45
 
46
  signal buf            : std_logic_vector(width-1 downto 0);
47
  signal f              : std_logic;
48
 
49
begin
50
 
51
  dout <= buf;
52
 
53
  process(clk, reset, f)
54
 
55
  begin
56
 
57
    full <= f;
58
 
59
    if reset = RESET_ACTIVE then
60
 
61
      buf <= (others => '0');
62
      f <= '0';
63
      rd_prev <= '0';
64
 
65
    elsif rising_edge(clk) then
66
 
67
      rd_prev <= '0';
68
      if f='0' then
69
        if wr='1' then
70
          rd_prev <= '1';
71
          buf <= din;
72
          f <= '1';
73
        end if;
74
      else
75
        if rd='1' then
76
          f <= '0';
77
        end if;
78
      end if;
79
 
80
    end if;
81
 
82
  end process;
83
 
84
end rtl;
85
 
86
library ieee;
87
use ieee.std_logic_1164.all;
88
 
89
entity fifo is
90
 
91
  generic (width : integer := 8; depth : integer := 4; thres : integer := 2);
92
  port (
93
    clk : in std_logic;
94
    reset       : in std_logic;
95
 
96
    din : in std_logic_vector(width-1 downto 0);
97
    dout        : out std_logic_vector(width-1 downto 0);
98
 
99
    rd  : in std_logic;
100
    wr  : in std_logic;
101
 
102
    empty       : out std_logic;
103
    full        : out std_logic;
104
    half        : out std_logic
105
    );
106
end fifo ;
107
 
108
architecture rtl of fifo is
109
 
110
  component fifo_elem is
111
    generic (width : integer);
112
    port (
113
      clk       : in std_logic;
114
      reset     : in std_logic;
115
 
116
      din       : in std_logic_vector(width-1 downto 0);
117
      dout      : out std_logic_vector(width-1 downto 0);
118
 
119
      rd        : in std_logic;
120
      wr        : in std_logic;
121
 
122
      rd_prev   : out std_logic;
123
      full      : out std_logic);
124
  end component;
125
 
126
  signal r, w, rp, f    : std_logic_vector(depth-1 downto 0);
127
  type d_array is array (0 to depth-1) of std_logic_vector(width-1 downto 0);
128
  signal di, do         : d_array;
129
 
130
begin
131
 
132
  g1: for i in 0 to depth-1 generate
133
 
134
    f1: fifo_elem generic map (width)
135
      port map (clk, reset, di(i), do(i), r(i), w(i), rp(i), f(i));
136
 
137
    x: if i<depth-1 generate
138
      r(i) <= rp(i+1);
139
      w(i+1) <= f(i);
140
      di(i+1) <= do(i);
141
    end generate;
142
 
143
  end generate;
144
 
145
  di(0) <= din;
146
  dout <= do(depth-1);
147
  w(0) <= wr;
148
  r(depth-1) <= rd;
149
 
150
  full <= f(0);
151
  half <= f(depth-thres);
152
  empty <= not f(depth-1);
153
 
154
end rtl;
155
 

powered by: WebSVN 2.1.0

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