1 |
145 |
lanttu |
-------------------------------------------------------------------------------
|
2 |
|
|
-- Title : LUT to transform HIBI address into net addresses
|
3 |
|
|
-- Project :
|
4 |
|
|
-------------------------------------------------------------------------------
|
5 |
|
|
-- File : addr_lut.vhd
|
6 |
|
|
-- Author :
|
7 |
|
|
-- Company :
|
8 |
|
|
-- Created : 2006-08-07
|
9 |
|
|
-- Last update: 2011-12-01
|
10 |
|
|
-- Platform :
|
11 |
|
|
-- Standard : VHDL'87
|
12 |
|
|
-------------------------------------------------------------------------------
|
13 |
|
|
-- Description: Ks Title
|
14 |
|
|
-- Revisions :
|
15 |
|
|
-- Date Version Author Description
|
16 |
|
|
-- 2006-08-07 1.0 rasmusa Created
|
17 |
|
|
-------------------------------------------------------------------------------
|
18 |
|
|
|
19 |
|
|
-------------------------------------------------------------------------------
|
20 |
|
|
-- Funbase IP library Copyright (C) 2011 TUT Department of Computer Systems
|
21 |
|
|
--
|
22 |
|
|
-- This source file may be used and distributed without
|
23 |
|
|
-- restriction provided that this copyright statement is not
|
24 |
|
|
-- removed from the file and that any derivative work contains
|
25 |
|
|
-- the original copyright notice and the associated disclaimer.
|
26 |
|
|
--
|
27 |
|
|
-- This source file is free software; you can redistribute it
|
28 |
|
|
-- and/or modify it under the terms of the GNU Lesser General
|
29 |
|
|
-- Public License as published by the Free Software Foundation;
|
30 |
|
|
-- either version 2.1 of the License, or (at your option) any
|
31 |
|
|
-- later version.
|
32 |
|
|
--
|
33 |
|
|
-- This source is distributed in the hope that it will be
|
34 |
|
|
-- useful, but WITHOUT ANY WARRANTY; without even the implied
|
35 |
|
|
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
36 |
|
|
-- PURPOSE. See the GNU Lesser General Public License for more
|
37 |
|
|
-- details.
|
38 |
|
|
--
|
39 |
|
|
-- You should have received a copy of the GNU Lesser General
|
40 |
|
|
-- Public License along with this source; if not, download it
|
41 |
|
|
-- from http://www.opencores.org/lgpl.shtml
|
42 |
|
|
-------------------------------------------------------------------------------
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
library ieee;
|
46 |
|
|
use ieee.std_logic_1164.all;
|
47 |
|
|
|
48 |
|
|
--use ieee.std_logic_arith.all;
|
49 |
|
|
|
50 |
|
|
-- net_type_g: 0 - HIBI (reserved. does nothing)
|
51 |
|
|
-- 1 - 2D MESH
|
52 |
|
|
-- 2 - Octagon
|
53 |
|
|
-- 3 - Crossbar
|
54 |
|
|
|
55 |
|
|
use work.addr_lut_pkg.all;
|
56 |
|
|
|
57 |
|
|
-------------------------------------------------------------------------------
|
58 |
|
|
entity addr_lut is
|
59 |
|
|
-----------------------------------------------------------------------------
|
60 |
|
|
generic (
|
61 |
|
|
in_addr_w_g : integer := 32;
|
62 |
|
|
out_addr_w_g : integer := 36;
|
63 |
|
|
cmp_high_g : integer := 31;
|
64 |
|
|
cmp_low_g : integer := 0;
|
65 |
|
|
net_type_g : integer := 1;
|
66 |
|
|
lut_en_g : integer := 1 -- if disabled (en=0), out_addr <= in_addr
|
67 |
|
|
);
|
68 |
|
|
port (
|
69 |
|
|
addr_in : in std_logic_vector(in_addr_w_g-1 downto 0);
|
70 |
|
|
addr_out : out std_logic_vector(out_addr_w_g-1 downto 0)
|
71 |
|
|
);
|
72 |
|
|
end addr_lut;
|
73 |
|
|
|
74 |
|
|
-------------------------------------------------------------------------------
|
75 |
|
|
architecture rtl of addr_lut is
|
76 |
|
|
-------------------------------------------------------------------------------
|
77 |
|
|
|
78 |
|
|
constant res_addr_table_c : res_addr_array := gen_result_addresses(num_table_c, net_type_g);
|
79 |
|
|
|
80 |
|
|
begin -- rtl
|
81 |
|
|
|
82 |
|
|
-- cmp_proc : process (addr_in)
|
83 |
|
|
-- variable found_addr_v : integer;
|
84 |
|
|
-- variable zero_vect_v : std_logic_vector( in_addr_w_g-1 downto 0 ) := (others => '0');
|
85 |
|
|
-- begin -- process cmp_proc
|
86 |
|
|
-- addr_out <= (others => '0');
|
87 |
|
|
-- found_addr_v := 0;
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
-- -- if LUT is disabled
|
91 |
|
|
-- if lut_en_g = 0 then
|
92 |
|
|
-- if in_addr_w_g > out_addr_w_g then
|
93 |
|
|
-- addr_out <= addr_in(out_addr_w_g-1 downto 0);
|
94 |
|
|
-- else
|
95 |
|
|
-- addr_out(in_addr_w_g-1 downto 0) <= addr_in;
|
96 |
|
|
-- end if;
|
97 |
|
|
-- found_addr_v := 1;
|
98 |
|
|
|
99 |
|
|
-- else
|
100 |
|
|
-- -- if LUT is enabled
|
101 |
|
|
-- for i in 0 to n_addr_ranges_c-1 loop
|
102 |
|
|
|
103 |
|
|
-- if ((addr_in(cmp_high_g downto cmp_low_g) and
|
104 |
|
|
-- addr_table_c(i).mask(cmp_high_g downto cmp_low_g)) = addr_table_c(i).in_addr(cmp_high_g downto cmp_low_g)) then
|
105 |
|
|
|
106 |
|
|
-- addr_out <= (others => '0');
|
107 |
|
|
-- addr_out(out_addr_w_c-1 downto 0) <= res_addr_table_c(i)(out_addr_w_c - 1 downto 0);
|
108 |
|
|
-- found_addr_v := 1;
|
109 |
|
|
|
110 |
|
|
-- end if;
|
111 |
|
|
-- end loop; -- i
|
112 |
|
|
-- end if;
|
113 |
|
|
---- assert (found_addr_v = 1) or (addr_in = zero_vect_v) report "Address not found: " & hstr(addr_in) severity error;
|
114 |
|
|
-- end process cmp_proc;
|
115 |
|
|
-- Fix: make two processes with if-generate
|
116 |
|
|
in_ad_narrower: if in_addr_w_g <= out_addr_w_g generate
|
117 |
|
|
cmp_proc1 : process (addr_in)
|
118 |
|
|
begin -- process cmp_proc
|
119 |
|
|
addr_out <= (others => '0');
|
120 |
|
|
|
121 |
|
|
-- if LUT is disabled
|
122 |
|
|
if lut_en_g = 0 then
|
123 |
|
|
addr_out (out_addr_w_g-1 downto in_addr_w_g) <= (others => '0');
|
124 |
|
|
addr_out (in_addr_w_g-1 downto 0) <= addr_in(in_addr_w_g-1 downto 0);
|
125 |
|
|
-- The above line was troublesome with regualr if (works with if-generate)
|
126 |
|
|
else
|
127 |
|
|
-- if LUT is enabled
|
128 |
|
|
|
129 |
|
|
for i in 0 to n_addr_ranges_c-1 loop
|
130 |
|
|
if ((addr_in (cmp_high_g downto cmp_low_g)
|
131 |
|
|
and addr_table_c(i).mask (cmp_high_g downto cmp_low_g))
|
132 |
|
|
= addr_table_c (i).in_addr (cmp_high_g downto cmp_low_g))
|
133 |
|
|
then
|
134 |
|
|
addr_out <= res_addr_table_c(i)(out_addr_w_g - 1 downto 0);
|
135 |
|
|
end if;
|
136 |
|
|
end loop; -- i
|
137 |
|
|
|
138 |
|
|
end if;
|
139 |
|
|
|
140 |
|
|
end process cmp_proc1;
|
141 |
|
|
|
142 |
|
|
end generate in_ad_narrower;
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
in_ad_wider: if in_addr_w_g > out_addr_w_g generate
|
147 |
|
|
cmp_proc1 : process (addr_in)
|
148 |
|
|
begin -- process cmp_proc
|
149 |
|
|
addr_out <= (others => '0');
|
150 |
|
|
|
151 |
|
|
-- if LUT is disabled
|
152 |
|
|
if lut_en_g = 0 then
|
153 |
|
|
-- Sisäänmeno leveämpi
|
154 |
|
|
addr_out <= addr_in(out_addr_w_g-1 downto 0);
|
155 |
|
|
|
156 |
|
|
else
|
157 |
|
|
-- if LUT is enabled
|
158 |
|
|
|
159 |
|
|
for i in 0 to n_addr_ranges_c-1 loop
|
160 |
|
|
if ((addr_in (cmp_high_g downto cmp_low_g)
|
161 |
|
|
and addr_table_c(i).mask (cmp_high_g downto cmp_low_g))
|
162 |
|
|
= addr_table_c (i).in_addr (cmp_high_g downto cmp_low_g))
|
163 |
|
|
then
|
164 |
|
|
addr_out <= res_addr_table_c(i)(out_addr_w_g - 1 downto 0);
|
165 |
|
|
end if;
|
166 |
|
|
end loop; -- i
|
167 |
|
|
|
168 |
|
|
end if;
|
169 |
|
|
|
170 |
|
|
end process cmp_proc1;
|
171 |
|
|
|
172 |
|
|
end generate in_ad_wider;
|
173 |
|
|
|
174 |
|
|
end rtl;
|