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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.storage/] [fifos/] [synchronizer/] [1.0/] [vhd/] [aif_read_out.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      :
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : latch synch
6
-- Author     : kulmala3
7
-- Created    : 01.07.2005
8
-- Last update: 05.01.2006
9
-- Description: OUT: regular fifo IN: output asynchronous ack/nack IF
10
--
11
-------------------------------------------------------------------------------
12
-- Copyright (c) 2005 
13
-------------------------------------------------------------------------------
14
-- Revisions  :
15
-- Date        Version  Author  Description
16
-- 01.07.2005  1.0      AK      Created
17
-------------------------------------------------------------------------------
18
 
19
 
20
library ieee;
21
use ieee.std_logic_1164.all;
22
use ieee.std_logic_arith.all;
23
use ieee.std_logic_unsigned.all;
24
 
25
entity aif_read_out is
26
  generic (
27
    data_width_g : integer := 32
28
    );
29
  port (
30
    clk       : in  std_logic;
31
    rst_n     : in  std_logic;
32
    a_we_in   : in  std_logic;
33
    ack_out   : out std_logic;
34
    empty_out : out std_logic;
35
    re_in     : in  std_logic;
36
    data_in   : in  std_logic_vector(data_width_g-1 downto 0);
37
    data_out  : out std_logic_vector(data_width_g-1 downto 0)
38
 
39
    );
40
end aif_read_out;
41
 
42
architecture rtl of aif_read_out is
43
 
44
  constant stages_c : integer := 3;
45
 
46
  signal ack_r           : std_logic;
47
  signal received_data_r : std_logic;
48
  -- synchronizer, last two are xorred
49
  signal a_we_r          : std_logic_vector(stages_c-1 downto 0);
50
  signal data_r          : std_logic_vector(data_width_g-1 downto 0);
51
begin
52
  data_out <= data_r;
53
--  ack_out <= ack_r;
54
 
55
  process (clk, rst_n)
56
  begin  -- process
57
    if rst_n = '0' then                 -- asynchronous reset (active low)
58
      a_we_r          <= (others => '0');
59
      ack_r           <= '0';
60
      ack_out         <= '0';
61
      received_data_r <= '0';
62
      empty_out       <= '1';
63
 
64
    elsif clk'event and clk = '1' then  -- rising clock edge
65
 
66
      for i in 0 to stages_c-2 loop
67
        a_we_r(i+1) <= a_we_r(i);
68
      end loop;  -- i
69
 
70
      a_we_r(0) <= a_we_in;
71
 
72
      -- now wait until we can write it to fifo
73
 
74
      if (a_we_r(stages_c-1) xor a_we_r(stages_c-2)) = '1' then
75
        ack_r           <= not ack_r;
76
        received_data_r <= '1';
77
        data_r          <= data_in;
78
        empty_out       <= '0';
79
      else
80
        ack_r <= ack_r;
81
      end if;
82
 
83
      if re_in = '1' and received_data_r = '1' then
84
        -- acknowledge, stop writing
85
        ack_out         <= ack_r;
86
        empty_out       <= '1';
87
        received_data_r <= '0';
88
      end if;
89
 
90
 
91
    end if;
92
  end process;
93
 
94
end rtl;

powered by: WebSVN 2.1.0

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