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.communication/] [hibi/] [2.0/] [vhd/] [addr_decoder.vhd] - Blame information for rev 148

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Funbase IP library Copyright (C) 2011 TUT Department of Computer Systems
3
--
4
-- This source file may be used and distributed without
5
-- restriction provided that this copyright statement is not
6
-- removed from the file and that any derivative work contains
7
-- the original copyright notice and the associated disclaimer.
8
--
9
-- This source file is free software; you can redistribute it
10
-- and/or modify it under the terms of the GNU Lesser General
11
-- Public License as published by the Free Software Foundation;
12
-- either version 2.1 of the License, or (at your option) any
13
-- later version.
14
--
15
-- This source is distributed in the hope that it will be
16
-- useful, but WITHOUT ANY WARRANTY; without even the implied
17
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18
-- PURPOSE.  See the GNU Lesser General Public License for more
19
-- details.
20
--
21
-- You should have received a copy of the GNU Lesser General
22
-- Public License along with this source; if not, download it
23
-- from http://www.opencores.org/lgpl.shtml
24
-------------------------------------------------------------------------------
25
-------------------------------------------------------------------------------
26
-- File        : addr_decode.vhdl
27
-- Description : Decodes the incoming address
28
-- Author      : Erno Salminen
29
-- e-mail      : erno.salminen@tut.fi
30
-- Project     : huuhaa
31
-- Design      : Do not use term design when you mean system
32
-- Date        : 29.04.2002
33
-- Modified    : 05.05.2002 Vesa Lahtinen Optimized for synthesis
34
--
35
--
36
-- 03.02.2003   Comparison_type input added, es
37
--              0=normal, 1=negated comparison
38
--              negation = xor comparison_type with addr match signal
39
-- 15.05.2003   Xor with comparison_type added
40
-- 27.07.2004   Clk+Rst removed, ES
41
-- 19.08.2004   ES: Index_Of_Lowest_Compared_Bit removed
42
--
43
--
44
-- 15.12.04     ES  names changes
45
-- 21.01.05     ES: constants for disbaling features
46
-- 07.02.05     ES new generics
47
-- TO DO:
48
-- BASE_ID SHOULD BE ADDED SO THAT HIERARCHICAL SYSTEMS CAN BE CONFIGURED
49
 
50
-------------------------------------------------------------------------------
51
library ieee;
52
use ieee.std_logic_1164.all;
53
use ieee.std_logic_arith.all;
54
use ieee.std_logic_unsigned.all;
55
use work.hibiv2_pkg.all;                -- for commands+comm_width
56
 
57
entity addr_decoder is
58
  generic (
59
    data_width_g      :     integer := 32;
60
    addr_width_g      :     integer := 32;  -- in bits
61
    id_width_g        :     integer := 4;
62
    id_g              :     integer := 5;
63
    base_id_g         :     integer := 5;
64
    addr_g            :     integer := 46;
65
    cfg_re_g          :     integer := 1;   -- 07.02.05
66
    cfg_we_g          :     integer := 1;   -- 07.02.05
67
    multicast_en_g    :     integer := 1;   -- 07.02.05
68
    inv_addr_en_g     :     integer := 0
69
    );
70
  port (
71
    addr_in           : in  std_logic_vector ( addr_width_g -1 downto 0);
72
    comm_in           : in  std_logic_vector ( comm_width_c -1 downto 0);
73
    enable_in         : in  std_logic;
74
    base_id_match_out : out std_logic;
75
    addr_match_out    : out std_logic
76
    );
77
 
78
end addr_decoder;
79
 
80
 
81
architecture rtl of addr_decoder is
82
 
83
  -- added 31,01.05
84
  -- changed to genrics values 07.02.05
85
  -- constant multicast_en_c      : integer range 0 to 1 := 1;
86
  -- constant enable_cfg_write_c  : integer range 0 to 1 := 1;
87
  -- constant enable_cfg_read_c   : integer range 0 to 1 := 1;
88
 
89
 
90
  -- Signals
91
  -- Index_Of_Lowest_Compared_Bitin voisis muuttaa sopivaksi integeriksi!
92
  -- signal Index_Of_Lowest_Compared_Bit : integer range 0 to addr_width_g;
93
  signal addr_in_slice                : std_logic_vector ( addr_width_g-1 downto 0);
94
  signal mask                         : std_logic_vector ( addr_width_g-1 downto 0);
95
 
96
  constant base_addr_c   : std_logic_vector ( addr_width_g -1 downto 0) := conv_std_logic_vector ( addr_g, addr_width_g);
97
  constant inv_addr_en_c : std_logic                                    := conv_std_logic_vector ( inv_addr_en_g, 1)(0);
98
 
99
 
100
  --   -- Debug signals for determining the valid addresses 
101
  --   -- These can be removed in synthesis!
102
  --   signal Top_addr          : std_logic_vector (addr_width_g-1 downto 0);
103
  --   signal multicast_00_addr : std_logic_vector (addr_width_g-1 downto 0);
104
  --   signal multicast_01_addr : std_logic_vector (addr_width_g-1 downto 0);
105
  --   signal multicast_10_addr : std_logic_vector (addr_width_g-1 downto 0);
106
  --   signal multicast_11_addr : std_logic_vector (addr_width_g-1 downto 0);
107
 
108
 
109
 
110
begin  -- rtl
111
 
112
  -- PROCESSES ----------------------------------------------------------------
113
 
114
 
115
 
116
  -- 1) 
117
  -- Count the number of bits needed in address comparison
118
  -- Needed bit range = (highest bits) downto (lowest '1' bit)
119
 
120
  -- !!!!!!!!!!!!!!!!
121
  -- 09.02.2005
122
  -- Muuta funktioksi ja jatkuvaksi sijoitukseksi
123
  -- !!!!!!!!!!!!!!!!
124
 
125
  Count_Compared_Bits          : process (mask) --(addr_in) 
126
  --Count_Compared_Bits          : process
127
 
128
    variable idx_found_var     : integer;
129
    variable mask_internal_var : std_logic_vector ( addr_width_g -1 downto 0);
130
  begin  -- process Count_Compared_Bits
131
 
132
    idx_found_var     := 0;
133
    mask_internal_var := (others => '1');
134
 
135
    perse : for i in 0 to (addr_width_g - 1) loop
136
      if base_addr_c (i) = '0' and idx_found_var = 0 then
137
        mask_internal_var (i) := '0';
138
      else
139
        idx_found_var         := 1;
140
        mask_internal_var (i) := '1';
141
 
142
      end if;
143
    end loop;  -- i
144
 
145
    -- Assign the Index value to signal
146
    mask                        <= mask_internal_var;
147
 
148
    -- NOTE! If base addr= 0, the Index goes to maximum value addr_width_g
149
    -- => mask is all zeros => no bits are used for comparison =>  all addresses match 
150
    -- Must be careful because the biggest valid Index is addr_width_g-1!
151
 
152
    -- 25.02.05 wait;
153
  end process Count_Compared_Bits;
154
 
155
 
156
  -- 2) CONCURRENT ASSIGNMENT
157
  addr_in_slice         <= addr_in and mask;
158
 
159
 
160
 
161
 
162
 
163
 
164
  -- 3) PROC
165
  -- Comparison
166
  -- The compared bits are determines with incoming command
167
  -- Four choices : nornal, multicast, config or idle.
168
 
169
 
170
  compare_addr : process (addr_in,
171
                          addr_in_slice,
172
                          comm_in,
173
                          enable_in
174
                          )
175
 
176
    -- For the part of the address telling the multicast type
177
    variable multicast_Part_var : std_logic_vector(1 downto 0);
178
  begin  -- process
179
 
180
    -- Two lowest bits define the compared bits in multicast
181
    multicast_part_var := addr_in (1 downto 0);
182
 
183
    if enable_in = '1' then
184
 
185
      if comm_in = w_data_c
186
        or comm_in = w_msg_c
187
        or comm_in = r_data_c
188
      then
189
 
190
        -- Direct comparison        
191
        -- inv_addr_en_c
192
        -- 0 = normal
193
        -- 1 = addr ranges inverted (useful in bridges)
194
 
195
        if base_addr_c = addr_in_slice then
196
          addr_match_out <= '1' xor inv_addr_en_c;
197
        else
198
          addr_match_out <= '0' xor inv_addr_en_c;
199
        end if;
200
 
201
 
202
        -- 31.01.05
203
      elsif multicast_en_g = 1
204
        and (comm_in = multicast_data_c
205
             or comm_in = multicast_msg_c)
206
      --elsif comm_in = multicast_data_c
207
      --  or comm_in = multicast_msg_c
208
      then
209
 
210
        -- Compare only part of the address
211
        case multicast_part_var is
212
          when "00" =>
213
            -- Vertaillaan puolta osoitebiteista
214
            if addr_in (addr_width_g-1 downto addr_width_g/2)
215
                 = base_addr_c (addr_width_g-1 downto addr_width_g/2) then
216
              addr_match_out <= '1' xor inv_addr_en_c;
217
            else
218
              addr_match_out <= '0' xor inv_addr_en_c;
219
            end if;
220
 
221
          when "01" =>
222
            -- Vertaillaan neljasosaa osoitebiteista
223
            if addr_in (addr_width_g-1 downto addr_width_g - (addr_width_g/4))
224
                = base_addr_c (addr_width_g-1 downto addr_width_g - (addr_width_g/4)) then
225
              addr_match_out <= '1' xor inv_addr_en_c;
226
            else
227
              addr_match_out <= '0' xor inv_addr_en_c;
228
           end if;
229
 
230
          when "10" =>
231
            -- Vertaillaan kahdeksasosaa osoitebiteista
232
            if addr_in (addr_width_g-1 downto addr_width_g - (addr_width_g/8))
233
                = base_addr_c (addr_width_g-1 downto addr_width_g - (addr_width_g/8)) then
234
              addr_match_out <= '1' xor inv_addr_en_c;
235
            else
236
              addr_match_out <= '0' xor inv_addr_en_c;
237
            end if;
238
 
239
 
240
          when others =>
241
            -- Vertaillaan kahdeksasosaa osoitebiteista
242
            -- With 8b addr, this does no comparison and all addresses (0-255)
243
            -- yield an address match.
244
 
245
            if addr_width_g/16 = 0 then
246
              -- Jos osoite 8b tai vahemman
247
              -- lisatty 11.04
248
              addr_match_out   <= '1' xor inv_addr_en_c;
249
            else
250
              if addr_in (addr_width_g-1 downto addr_width_g - (addr_width_g/16))
251
                 = base_addr_c (addr_width_g-1 downto addr_width_g - (addr_width_g/16)) then
252
                addr_match_out <= '1' xor inv_addr_en_c;
253
              else
254
                addr_match_out <= '0' xor inv_addr_en_c;
255
              end if;  -- addr_in
256
            end if;  -- addr_width_g
257
 
258
        end case;
259
 
260
 
261
        -- Condition modified 2007/04/17
262
      elsif (cfg_re_g = 1
263
             or cfg_we_g = 1)
264
        and (comm_in = w_cfg_c
265
             or comm_in = r_cfg_c)
266
--       elsif cfg_re_g = 1
267
--         and cfg_we_g = 1
268
--         and (comm_in = w_cfg_c
269
--              or comm_in = r_cfg_c)
270
      then
271
 
272
        -- Compare the id-part of the config address 
273
        -- and check if id-part is 0 which means configuration broadcast
274
 
275
        if (addr_in ( addr_width_g-1 downto addr_width_g - id_width_g) = id_g)
276
          or (addr_in ( addr_width_g-1 downto addr_width_g - id_width_g) = conv_std_logic_vector(0, id_width_g))
277
        then
278
 
279
          addr_match_out <= '1';-- xor inv_addr_en_c;  
280
        else
281
          addr_match_out <= '0';-- xor inv_addr_en_c;  
282
        end if;
283
 
284
      else
285
        -- Idle
286
        addr_match_out <= '0';
287
      end if;
288
 
289
 
290
    else
291
      -- enable_in = 0 => do nothing
292
      addr_match_out <= '0';
293
    end if;  -- enable
294
 
295
  end process;
296
 
297
 
298
--   -- 4) PROC  
299
--   -- Assign value for test signals
300
--   -- This can be removed in synthesis!
301
--   testi: process (base_addr_c, Index_Of_Lowest_Compared_Bit)
302
--   begin  -- process testi
303
 
304
--     Top_addr (addr_width_g-1 downto conv_integer (Index_Of_Lowest_Compared_Bit))
305
--       <= base_addr_c (addr_width_g-1 downto conv_integer (Index_Of_Lowest_Compared_Bit));
306
--     Top_addr (conv_integer (Index_Of_Lowest_Compared_Bit)-1 downto 0) <= (others => '1');    
307
 
308
--     multicast_00_addr (addr_width_g-1 downto addr_width_g/2)
309
--       <= base_addr_c (addr_width_g-1 downto addr_width_g/2);
310
--     multicast_00_addr (addr_width_g/2 -1 downto 0) <= (others => '0');
311
 
312
--     multicast_01_addr (addr_width_g-1 downto addr_width_g -addr_width_g/4)
313
--       <= base_addr_c (addr_width_g-1 downto addr_width_g -addr_width_g/4);
314
--     multicast_01_addr (addr_width_g-addr_width_g/4 -1 downto 0) <= (others => '0');      
315
 
316
--     multicast_10_addr (addr_width_g-1 downto addr_width_g -addr_width_g/8)
317
--       <= base_addr_c (addr_width_g-1 downto addr_width_g -addr_width_g/8);
318
--     multicast_10_addr (addr_width_g-addr_width_g/8 -1 downto 0) <= (others => '0');      
319
 
320
--     multicast_11_addr (addr_width_g-1 downto addr_width_g -addr_width_g/16)
321
--       <= base_addr_c (addr_width_g-1 downto addr_width_g -addr_width_g/16);
322
--     multicast_11_addr (addr_width_g-addr_width_g/16 -1 downto 0) <= (others => '0');      
323
--      
324
--  end process;
325
 
326
 
327
 
328
 
329
 
330
 
331
 
332
end rtl;

powered by: WebSVN 2.1.0

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