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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [Altera/] [ip.hwp.cpu/] [nios_ii_sram/] [1.0/] [hdl/] [ip/] [hpd_rx_packet.vhd] - Blame information for rev 147

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 147 lanttu
-------------------------------------------------------------------------------
2
-- Title      : HIBI PE DMA - rx packet channel
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : hpd_rx_packet.vhd
6
-- Author     : kulmala3
7
-- Created    : 2012-01-10
8
-- Last update: 2012-02-28
9
-- Description: One channel for HPD
10
-- supports 32 and 64b data widths only due to low cost implemementation :)
11
-------------------------------------------------------------------------------
12
-- Copyright (c) 2005 
13
-------------------------------------------------------------------------------
14
-- Revisions  :
15
-- Date        Version  Author  Description
16
-- 02.06.2005  1.0      AK      Created
17
-- 2011-01-25           LL      Added support for handling incoming address
18
--                              that haven't been configured for reception.
19
-- 2012-02-20           LL      Added words_out port to count how many words
20
--                              this channel has received.
21
-------------------------------------------------------------------------------
22
 
23
library ieee;
24
use ieee.std_logic_1164.all;
25
use ieee.std_logic_arith.all;
26
use ieee.std_logic_unsigned.all;
27
 
28
entity hpd_rx_packet is
29
 
30
  generic (
31
    data_width_g      : integer := 0;
32
    hibi_addr_width_g : integer := 0;
33
    addr_width_g      : integer := 0;
34
    words_width_g     : integer := 0;
35
    addr_cmp_lo_g     : integer := 0;
36
    addr_cmp_hi_g     : integer := 0
37
    );
38
 
39
  port (
40
    clk   : in std_logic;
41
    rst_n : in std_logic;
42
 
43
    -- keep still until a new init
44
    avalon_addr_in : in std_logic_vector(addr_width_g-1 downto 0);
45
    hibi_addr_in   : in std_logic_vector(hibi_addr_width_g-1 downto 0);
46
    irq_words_in   : in std_logic_vector(words_width_g-1 downto 0);
47
 
48
    hibi_data_in      : in std_logic_vector(hibi_addr_width_g-1 downto 0);
49
    hibi_av_in        : in std_logic;
50
    hibi_empty_in     : in std_logic;
51
    init_in           : in std_logic;
52
    irq_ack_in        : in std_logic;
53
    avalon_waitreq_in : in std_logic;
54
    avalon_we_in      : in std_logic;
55
 
56
    avalon_addr_out    : out std_logic_vector(addr_width_g-1 downto 0);
57
    avalon_we_out      : out std_logic;
58
    avalon_be_out      : out std_logic_vector(data_width_g/8-1 downto 0);
59
    addr_match_out     : out std_logic;
60
    addr_match_cmb_out : out std_logic;
61
    irq_out            : out std_logic;
62
    words_out          : out std_logic_vector(words_width_g-1 downto 0)
63
    );
64
 
65
end hpd_rx_packet;
66
 
67
architecture rtl of hpd_rx_packet is
68
  constant dont_care_c   : std_logic := 'X';
69
  constant addr_offset_c : integer   := data_width_g/8;
70
 
71
  constant words_per_hibi_data_c : integer   := data_width_g/32;
72
  constant upper_valid_c         : std_logic := '0';
73
  -- in case of odd data words, is
74
  -- either upper ('1') or lower ('0') half-word valid?
75
 
76
  constant be_width_c       : integer := data_width_g/8;
77
  signal   addr_match_r     : std_logic;
78
  signal   addr_match_cmb_s : std_logic;
79
  signal   avalon_addr_r    : std_logic_vector(addr_width_g-1 downto 0);
80
  signal   enable_r         : std_logic;
81
  signal   ena_av_empty     : std_logic_vector(2 downto 0);
82
  signal   irq_counter_r    : std_logic_vector(words_width_g-1 downto 0);
83
  signal   irq_r            : std_logic;
84
  signal   we_match_waitreq : std_logic_vector(2 downto 0);
85
 
86
 
87
begin  -- rtl
88
 
89
  words_out <= irq_words_in - irq_counter_r;
90
 
91
  we_match_waitreq <= avalon_we_in & addr_match_r & avalon_waitreq_in;
92
  avalon_we_out    <= addr_match_r and enable_r;
93
  irq_out          <= irq_r;
94
 
95
  addr_match_out     <= addr_match_r and enable_r;
96
  addr_match_cmb_out <= addr_match_cmb_s;
97
  avalon_addr_out    <= avalon_addr_r;
98
 
99
  ena_av_empty <= enable_r & hibi_av_in & hibi_empty_in;
100
 
101
  addr_match : process (hibi_data_in, hibi_addr_in, addr_match_r, ena_av_empty)
102
  begin  -- process addr_match
103
 
104
    case ena_av_empty is
105
      when "000" | "010" | "011" | "001" =>
106
        addr_match_cmb_s <= '0';
107
      when "110" =>
108
        if hibi_data_in(addr_cmp_hi_g downto addr_cmp_lo_g) =
109
          hibi_addr_in(addr_cmp_hi_g downto addr_cmp_lo_g) then
110
          addr_match_cmb_s <= '1';
111
        else
112
          addr_match_cmb_s <= '0';
113
        end if;
114
      when others =>
115
        addr_match_cmb_s <= addr_match_r;
116
    end case;
117
 
118
  end process addr_match;
119
 
120
  addr_match_reg : process (clk, rst_n)
121
  begin  -- process addr_matching
122
    if rst_n = '0' then                 -- asynchronous reset (active low)
123
      addr_match_r <= '0';
124
    elsif clk'event and clk = '1' then  -- rising clock edge
125
      addr_match_r <= addr_match_cmb_s;
126
    end if;
127
  end process addr_match_reg;
128
 
129
 
130
  ena : process (clk, rst_n)
131
    variable inter_addr : std_logic_vector(addr_width_g-1 downto 0);
132
  begin  -- process ena
133
    if rst_n = '0' then                 -- asynchronous reset (active low)
134
      enable_r      <= '0';
135
      irq_counter_r <= (others => '1');
136
      avalon_addr_r <= (others => dont_care_c);
137
      irq_r         <= '0';
138
 
139
    elsif clk'event and clk = '1' then  -- rising clock edge
140
 
141
      if init_in = '1' then
142
        enable_r      <= '1';
143
        irq_counter_r <= irq_words_in;
144
        avalon_addr_r <= avalon_addr_in;
145
      else
146
        enable_r      <= enable_r;
147
        irq_counter_r <= irq_counter_r;
148
        avalon_addr_r <= avalon_addr_r;
149
      end if;
150
 
151
      if irq_ack_in = '1' then
152
        irq_r <= '0';
153
      else
154
        irq_r <= irq_r;
155
      end if;
156
 
157
      case we_match_waitreq is
158
        when "110" =>
159
          -- we're writing here
160
          if irq_counter_r <= conv_std_logic_vector(words_per_hibi_data_c,
161
                                                    words_width_g)
162
          then
163
            avalon_addr_r <= avalon_addr_r+addr_offset_c;
164
            enable_r      <= '0';
165
            irq_r         <= '1';
166
            irq_counter_r <= irq_counter_r-words_per_hibi_data_c;
167
          else
168
            avalon_addr_r <= avalon_addr_r +addr_offset_c;
169
            irq_counter_r <= irq_counter_r-words_per_hibi_data_c;
170
            enable_r      <= '1';
171
          end if;
172
 
173
        when others =>
174
      end case;
175
 
176
    end if;
177
  end process ena;
178
 
179
  byteena : process (irq_counter_r)
180
  begin  -- process byteena
181
    if irq_counter_r = conv_std_logic_vector(1, words_width_g)
182
      and words_per_hibi_data_c = 2
183
    then
184
      -- odd number of words wanted, e.g. 64 bit hibi, wanted 5 32-bit
185
      -- words
186
      avalon_be_out(be_width_c-1 downto be_width_c/2) <=
187
        (others => upper_valid_c);
188
      avalon_be_out(be_width_c/2-1 downto 0) <=
189
        (others => (not upper_valid_c));
190
    else
191
      avalon_be_out <= (others => '1');
192
    end if;
193
 
194
  end process byteena;
195
 
196
 
197
 
198
end rtl;

powered by: WebSVN 2.1.0

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