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_in_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_in_burst
6
-- Author     : kulmala3
7
-- Created    : 01.07.2005
8
-- Last update: 28.07.2006
9
-- Description: Input: regular fifo IF: 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_in_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 := 36
30
    );
31
  port (
32
    clk       : in  std_logic;
33
    rst_n     : in  std_logic;
34
    empty_in  : in  std_logic;
35
    re_out    : out std_logic;
36
    data_in   : in  std_logic_vector(data_width_g-1 downto 0);
37
    data_out  : out std_logic_vector(burst_width_g-1 downto 0);
38
    a_we_out  : out std_logic;
39
    burst_out : out std_logic;
40
    nack_in   : in  std_logic;
41
    ack_in    : in  std_logic
42
 
43
    );
44
end aif_read_in_burst;
45
 
46
architecture rtl of aif_read_in_burst is
47
  constant stages_c : integer := 2;     -- only works with 2 now
48
  signal   ack_r    : std_logic_vector(stages_c-1 downto 0);
49
  signal   nack_r   : std_logic_vector(stages_c-1 downto 0);
50
 
51
  constant b_length_c : integer := data_width_g / burst_width_g;
52
 
53
  signal slow_cnt_r   : integer range 0 to 15;  -- slowdown counter
54
  signal slow_value_r : integer range 0 to 15;  -- slowdown counter
55
  signal fail_cnt_r   : integer range 0 to 1;  -- two times we try to send per speed
56
  signal a_we_l       : std_logic;
57
--  signal full_r : std_logic;
58
 
59
  type   data_vec_type is array (0 to b_length_c-1) of std_logic_vector(burst_width_g-1 downto 0);
60
  signal data_slice  : std_logic_vector(burst_width_g-1 downto 0);
61
--  signal datavec     : data_vec_type;
62
  signal slice_cnt_r : integer range 0 to b_length_c-1;
63
 
64
  signal ack_receiveid_r  : std_logic;
65
  signal nack_receiveid_r : std_logic;
66
 
67
  type   send_state is (wait_data, send_burst, wait_ack, read_fifo);
68
  signal ctrl_r : send_state;
69
 
70
  signal burst_r : std_logic;
71
 
72
begin
73
 
74
  a_we_out <= a_we_l;
75
 
76
  data_out <= data_slice;
77
 
78
  burst_out <= burst_r;
79
 
80
  process (clk, rst_n)
81
  begin  -- process
82
    if rst_n = '0' then                 -- asynchronous reset (active low)
83
      a_we_l           <= '0';
84
      re_out           <= '0';
85
      ack_r            <= (others => '0');
86
      nack_r           <= (others => '0');
87
      slow_cnt_r       <= 1;
88
      slice_cnt_r      <= 0;
89
      fail_cnt_r       <= 0;
90
      ctrl_r           <= wait_data;
91
      slow_value_r     <= 1;
92
      ack_receiveid_r  <= '0';
93
      nack_receiveid_r <= '0';
94
      burst_r          <= '0';
95
 
96
    elsif clk'event and clk = '1' then  -- rising clock edge
97
      for i in 0 to stages_c-2 loop
98
        ack_r(i+1)  <= ack_r(i);
99
        nack_r(i+1) <= nack_r(i);
100
      end loop;  -- i
101
      ack_r(0)  <= ack_in;
102
      nack_r(0) <= nack_in;
103
 
104
      ack_receiveid_r  <= ack_receiveid_r or ((ack_r(stages_c-1) xor ack_r(stages_c-2)));
105
      nack_receiveid_r <= nack_receiveid_r or ((nack_r(stages_c-1) xor nack_r(stages_c-2)));
106
 
107
      case ctrl_r is
108
        when wait_data =>
109
          if empty_in = '1' then
110
            ctrl_r <= wait_data;
111
          else
112
            -- data in HIBI FIFO, send it
113
            a_we_l      <= not a_we_l;
114
            slow_cnt_r  <= slow_value_r;
115
            slice_cnt_r <= 0;
116
            ctrl_r      <= send_burst;
117
          end if;
118
 
119
        when send_burst =>
120
--          if slow_cnt_r = 1 then
121
--            slow_cnt_r <= slow_cnt_r-1;
122
--            if slice_cnt_r = b_length_c-1 then
123
--              ctrl_r      <= wait_ack;
124
--              burst_r <= not burst_r;
125
--              slice_cnt_r <= 0;         -- last one
126
--            else
127
--              slice_cnt_r <= slice_cnt_r+1;
128
--            end if;
129
--          elsif slow_cnt_r = 0 then
130
--            a_we_l     <= not a_we_l;
131
--            slow_cnt_r <= slow_value_r;
132
--          else
133
--            slow_cnt_r <= slow_cnt_r-1;
134
--          end if;
135
 
136
          if slow_cnt_r = 0 then
137
            a_we_l     <= not a_we_l;
138
            slow_cnt_r <= slow_value_r;
139
          elsif slow_cnt_r = 1 then --slow_value_r then
140
 
141
            if slice_cnt_r = b_length_c-1 then
142
              ctrl_r      <= wait_ack;
143
              burst_r     <= not burst_r;
144
              slice_cnt_r <= 0;         -- last one
145
            else
146
              slice_cnt_r <= slice_cnt_r+1;
147
            end if;
148
            slow_cnt_r <= slow_cnt_r-1;
149
          else
150
            slow_cnt_r <= slow_cnt_r-1;
151
 
152
          end if;
153
 
154
        when wait_ack =>
155
          if ack_receiveid_r = '1' then
156
            ack_receiveid_r <= '0';
157
            ctrl_r          <= read_fifo;
158
            re_out          <= '1';
159
          end if;
160
 
161
          if nack_receiveid_r = '1' then
162
            nack_receiveid_r <= '0';
163
            slow_value_r <= slow_value_r+1;
164
            slow_cnt_r   <= slow_value_r+1;
165
            a_we_l       <= not a_we_l;
166
            ctrl_r       <= send_burst;
167
            slice_cnt_r  <= 0;          -- ha´s been for a while now
168
          end if;
169
 
170
        when read_fifo =>
171
          re_out <= '0';
172
          ctrl_r <= wait_data;
173
 
174
        when others => null;
175
      end case;
176
 
177
 
178
    end if;
179
  end process;
180
 
181
 
182
  datamux : process (data_in, slice_cnt_r)
183
    variable datavec : data_vec_type;
184
 
185
  begin  -- process datamux
186
    datavec(0) := data_in(burst_width_g-1 downto 0);
187
    for i in 2 to b_length_c loop
188
      datavec(i-1) := data_in(burst_width_g*(i)-1 downto burst_width_g*(i-1));
189
    end loop;  -- i
190
    data_slice <= datavec(slice_cnt_r);
191
  end process datamux;
192
 
193
end rtl;

powered by: WebSVN 2.1.0

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