fifo_ft232h.vhd


1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.NUMERIC_STD.ALL;
4
5
entity fifo_ft232h is
6
Port (
7
  clk : in std_logic;
8
  rd: in std_logic;
9
  wr: in std_logic;
10
  data_in : in std_logic_vector(175 downto 0);
11
  data_out : out std_logic_vector(175 downto 0);
12
  full: out std_logic;
13
  empty: out std_logic);
14
end fifo_ft232h;
15
16
architecture Behavioral of fifo_ft232h is
17
18
type speicher is array(0 to 2047) of std_logic_vector(175 downto 0);
19
signal memory : speicher;  
20
signal Schreibadresse, Leseadresse : unsigned (10 downto 0) := (others => '0');
21
signal full_buffer : std_logic:='0';
22
signal empty_buffer : std_logic:='1';
23
24
begin
25
empty <= empty_buffer;
26
full <= full_buffer;
27
28
process begin
29
wait until rising_edge(clk);
30
  if wr = '1' and rd = '0' and full_buffer = '0' then
31
    memory(to_integer(Schreibadresse)) <= data_in;
32
    Schreibadresse <= Schreibadresse + 1;
33
    empty_buffer <= '0';
34
    if Leseadresse = Schreibadresse +1 then
35
      full_buffer <= '1';
36
    else
37
      full_buffer <= '0';
38
    end if;
39
  end if;
40
  if rd = '1' and wr = '0' and empty_buffer = '0' then
41
    data_out <= memory(to_integer(Leseadresse));
42
    Leseadresse <= Leseadresse + 1;
43
    full_buffer <= '0';
44
    if Leseadresse +1 = Schreibadresse then
45
      empty_buffer <= '1';
46
    else
47
      empty_buffer <= '0';
48
    end if;
49
  end if;
50
  if rd = '1' and wr = '1' and empty_buffer = '0' then
51
    data_out <= memory(to_integer(Leseadresse));
52
    memory(to_integer(Schreibadresse)) <= data_in;
53
    Leseadresse <= Leseadresse + 1;
54
    Schreibadresse <= Schreibadresse + 1;
55
  end if;
56
end process;
57
58
end Behavioral;