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_burst.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       : aif_read_out_burst
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_burst is
26
  generic (
27
    parity_g      : integer := 0;       -- do we send parity or no
28
    burst_width_g : integer := 6;       -- length = data_w/burst_w    
29
    data_width_g  : integer := 32
30
    );
31
  port (
32
    clk       : in  std_logic;
33
    rst_n     : in  std_logic;
34
    a_we_in   : in  std_logic;
35
    ack_out   : out std_logic;
36
    nack_out  : out std_logic;
37
    empty_out : out std_logic;
38
    re_in     : in  std_logic;
39
    burst_in  : in  std_logic;
40
    data_in   : in  std_logic_vector(burst_width_g-1 downto 0);
41
    data_out  : out std_logic_vector(data_width_g-1 downto 0)
42
 
43
    );
44
end aif_read_out_burst;
45
 
46
architecture rtl of aif_read_out_burst is
47
 
48
  constant stages_c      : integer := 3;
49
  constant ctrl_stages_c : integer := 2;  -- burst
50
 
51
  constant b_length_c : integer := data_width_g / burst_width_g;
52
 
53
  signal ack_r  : std_logic;
54
  signal nack_r : std_logic;
55
  -- synchronizer, last two are xorred
56
  signal a_we_r : std_logic_vector(stages_c-1 downto 0);
57
 
58
  type   in_data_type is array (0 to stages_c-1) of std_logic_vector(burst_width_g-1 downto 0);
59
  signal in_data_r : in_data_type;
60
 
61
  signal data_r : std_logic_vector(data_width_g-1 downto 0);
62
 
63
  type   data_vec_type is array (0 to b_length_c-1) of std_logic_vector(burst_width_g-1 downto 0);
64
--  signal data_slice  : std_logic_vector(burst_width_g-1 downto 0);
65
--  signal datavec     : data_vec_type;
66
  signal slice_cnt_r : integer range 0 to b_length_c-1;
67
  signal burst_r     : std_logic_vector(stages_c-1 downto 0);
68
  signal empty_r     : std_logic;
69
  signal data_ok_r   : std_logic;
70
 
71
begin
72
  data_out  <= data_r;
73
  ack_out   <= ack_r;
74
  nack_out  <= nack_r;
75
  empty_out <= empty_r;
76
 
77
  process (clk, rst_n)
78
  begin  -- process
79
    if rst_n = '0' then                 -- asynchronous reset (active low)
80
      a_we_r      <= (others => '0');
81
      ack_r       <= '0';
82
      empty_r     <= '1';
83
      slice_cnt_r <= 0;
84
      nack_r      <= '0';
85
      empty_r     <= '1';
86
      for i in 0 to stages_c-1 loop
87
        in_data_r(i) <= (others => '0');
88
      end loop;  -- i
89
      burst_r   <= (others => '0');
90
      data_ok_r <= '0';
91
 
92
    elsif clk'event and clk = '1' then  -- rising clock edge
93
      ack_r <= ack_r;
94
 
95
      for i in 0 to stages_c-2 loop
96
        a_we_r(i+1)    <= a_we_r(i);
97
        in_data_r(i+1) <= in_data_r(i);
98
        burst_r(i+1)   <= burst_r(i);
99
      end loop;  -- i
100
 
101
      burst_r(0)   <= burst_in;
102
      a_we_r(0)    <= a_we_in;
103
      in_data_r(0) <= data_in;
104
 
105
      if (a_we_r(stages_c-1) xor a_we_r(stages_c-2)) = '1' then
106
        -- slice cnt testaus!
107
 
108
        for i in 0 to b_length_c-1 loop
109
          if i = slice_cnt_r then
110
            data_r((i+1)*burst_width_g-1 downto burst_width_g*(i)) <= in_data_r(stages_c-2);
111
          end if;
112
        end loop;  -- i
113
 
114
        if slice_cnt_r = b_length_c-1 then
115
          empty_r     <= '0';
116
          slice_cnt_r <= 0;
117
          data_ok_r   <= '1';
118
        else
119
          empty_r     <= '1';
120
          slice_cnt_r <= slice_cnt_r+1;
121
        end if;
122
 
123
      end if;
124
 
125
      if (burst_r(stages_c-1) xor burst_r(stages_c-2)) = '1' then
126
        if data_ok_r = '0' then
127
          nack_r      <= not nack_r;
128
          empty_r     <= '1';
129
          slice_cnt_r <= 0;
130
        else
131
          data_ok_r <= '0';
132
        end if;
133
      end if;
134
 
135
      if re_in = '1' and empty_r = '0' then
136
        -- acknowledge, stop writing
137
        ack_r   <= not ack_r;
138
        empty_r <= '1';
139
      end if;
140
 
141
 
142
    end if;
143
  end process;
144
 
145
end rtl;

powered by: WebSVN 2.1.0

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