1 |
42 |
lmaarsen |
--------------------------------------------------------------------------------
|
2 |
53 |
lmaarsen |
--
|
3 |
|
|
-- This VHDL file was generated by EASE/HDL 7.4 Revision 4 from HDL Works B.V.
|
4 |
|
|
--
|
5 |
|
|
-- Ease library : work
|
6 |
|
|
-- HDL library : work
|
7 |
|
|
-- Host name : S212065
|
8 |
|
|
-- User name : df768
|
9 |
|
|
-- Time stamp : Tue Aug 19 08:05:18 2014
|
10 |
|
|
--
|
11 |
|
|
-- Designed by : L.Maarsen
|
12 |
|
|
-- Company : LogiXA
|
13 |
|
|
-- Project info : eSoC
|
14 |
|
|
--
|
15 |
42 |
lmaarsen |
--------------------------------------------------------------------------------
|
16 |
53 |
lmaarsen |
|
17 |
42 |
lmaarsen |
--------------------------------------------------------------------------------
|
18 |
|
|
-- Object : Entity work.esoc_search_engine_da
|
19 |
|
|
-- Last modified : Mon Apr 14 12:50:04 2014.
|
20 |
|
|
--------------------------------------------------------------------------------
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
library ieee, std, work;
|
25 |
|
|
use ieee.std_logic_1164.all;
|
26 |
|
|
use std.textio.all;
|
27 |
|
|
use ieee.numeric_std.all;
|
28 |
|
|
use work.package_hash10_24b.all;
|
29 |
|
|
use work.package_esoc_configuration.all;
|
30 |
|
|
|
31 |
|
|
entity esoc_search_engine_da is
|
32 |
|
|
port(
|
33 |
|
|
clk_search : in std_logic;
|
34 |
|
|
reset : in std_logic;
|
35 |
|
|
search_eof : in std_logic;
|
36 |
|
|
search_key : in std_logic_vector(63 downto 0);
|
37 |
|
|
search_port_stalled : in std_logic_vector(esoc_port_count-1 downto 0);
|
38 |
|
|
search_result : out std_logic_vector(esoc_port_count-1 downto 0);
|
39 |
|
|
search_result_av : out std_logic;
|
40 |
|
|
search_sof : in std_logic;
|
41 |
|
|
search_table_address : out STD_LOGIC_VECTOR(12 downto 0);
|
42 |
|
|
search_table_data : out STD_LOGIC_VECTOR(79 downto 0);
|
43 |
|
|
search_table_q : in STD_LOGIC_VECTOR(79 downto 0);
|
44 |
|
|
search_table_rden : out STD_LOGIC;
|
45 |
|
|
search_table_wren : out STD_LOGIC);
|
46 |
|
|
end entity esoc_search_engine_da;
|
47 |
|
|
|
48 |
|
|
--------------------------------------------------------------------------------
|
49 |
|
|
-- Object : Architecture work.esoc_search_engine_da.esoc_search_engine_da
|
50 |
|
|
-- Last modified : Mon Apr 14 12:50:04 2014.
|
51 |
|
|
--------------------------------------------------------------------------------
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
architecture esoc_search_engine_da of esoc_search_engine_da is
|
55 |
|
|
|
56 |
|
|
type search_states is (idle, wait_hash, compare);
|
57 |
|
|
signal search_state: search_states;
|
58 |
|
|
|
59 |
|
|
signal search_table_address_i: std_logic_vector(search_table_address'high downto 0);
|
60 |
|
|
signal search_result_i: std_logic_vector(esoc_port_count-1 downto 0);
|
61 |
|
|
signal search_port_stalled_sync : std_logic_vector(2*esoc_port_count-1 downto 0);
|
62 |
|
|
|
63 |
|
|
signal search_table_coll_cnt: integer range esoc_search_engine_col_depth downto 0 ;
|
64 |
|
|
signal search_hash_delay_cnt: integer range esoc_search_engine_hash_delay downto 0;
|
65 |
|
|
|
66 |
|
|
signal search_key_i: std_logic_vector(59 downto 0);
|
67 |
|
|
|
68 |
|
|
begin
|
69 |
|
|
|
70 |
|
|
--=============================================================================================================
|
71 |
|
|
-- Process : proces search requests for destination MAC address
|
72 |
|
|
-- Description :
|
73 |
|
|
--=============================================================================================================
|
74 |
|
|
search_da: process(clk_search, reset)
|
75 |
|
|
begin
|
76 |
|
|
if reset = '1' then
|
77 |
|
|
search_table_coll_cnt <= 0;
|
78 |
|
|
search_hash_delay_cnt <= 0;
|
79 |
|
|
|
80 |
|
|
search_key_i <= (others => '0');
|
81 |
|
|
search_table_address_i <= (others => '0');
|
82 |
|
|
search_table_rden <= '0';
|
83 |
|
|
search_result_i <= (others => '0');
|
84 |
|
|
search_result_av <= '0';
|
85 |
|
|
|
86 |
|
|
search_port_stalled_sync <= (others => '0');
|
87 |
|
|
|
88 |
|
|
elsif clk_search'event and clk_search = '1' then
|
89 |
|
|
-- clear one-clock active signals
|
90 |
|
|
search_result_av <= '0';
|
91 |
|
|
search_table_rden <= '0';
|
92 |
|
|
|
93 |
|
|
-- synchronise port stalled information with this clock
|
94 |
|
|
search_port_stalled_sync(esoc_port_count-1 downto 0) <= search_port_stalled_sync(2*esoc_port_count-1 downto esoc_port_count);
|
95 |
|
|
search_port_stalled_sync(2*esoc_port_count-1 downto esoc_port_count) <= search_port_stalled;
|
96 |
|
|
|
97 |
|
|
-- process new search requests
|
98 |
|
|
case search_state is
|
99 |
|
|
when idle => -- wait for start of frame, first data is VID + DA, calculate hash pointer (additional delay may be required after synthesis, due to large XOR tree)
|
100 |
|
|
if search_sof = '1' then
|
101 |
|
|
|
102 |
|
|
-- send result (all ports) immediately if destination address is a BC or MC, if UC start search action.
|
103 |
|
|
-- the BC/MC detection is part of the search engine and not part of port because you still need to learn the SA!
|
104 |
|
|
if search_key(esoc_search_bus_mac+esoc_ethernet_uc_mc_bc) = '0'then
|
105 |
|
|
search_key_i(esoc_search_entry_vlan+11 downto esoc_search_entry_vlan) <= search_key(esoc_search_bus_vlan+11 downto esoc_search_bus_vlan);
|
106 |
|
|
search_key_i(esoc_search_entry_mac+47 downto esoc_search_entry_mac) <= search_key(esoc_search_bus_mac+47 downto esoc_search_bus_mac);
|
107 |
|
|
search_table_address_i <= CALC_HASH10_24b(search_key(esoc_search_bus_mac+23 downto esoc_search_bus_mac)) & "000";
|
108 |
|
|
search_table_rden <= '1';
|
109 |
|
|
search_table_coll_cnt <= 0;
|
110 |
|
|
|
111 |
|
|
-- use delay mechanism to give the hash function - large xor tree - time to provide stable result
|
112 |
|
|
-- depends on target speed, use target timing analysis result to optimze this delay! At least one clock
|
113 |
|
|
-- delay due to RAM latency
|
114 |
|
|
search_hash_delay_cnt <= esoc_search_engine_hash_delay-1;
|
115 |
|
|
search_state <= wait_hash;
|
116 |
|
|
|
117 |
|
|
else
|
118 |
|
|
search_result_av <= '1';
|
119 |
|
|
search_result_i <= (others => '1');
|
120 |
|
|
end if;
|
121 |
|
|
end if;
|
122 |
|
|
|
123 |
|
|
when wait_hash => -- hash result stable?
|
124 |
|
|
if search_hash_delay_cnt = 0 then
|
125 |
|
|
search_table_address_i <= std_logic_vector(to_unsigned(to_integer(unsigned(search_table_address_i))+1,search_table_address_i'length));
|
126 |
|
|
search_state <= compare;
|
127 |
|
|
else
|
128 |
|
|
search_hash_delay_cnt <= search_hash_delay_cnt-1;
|
129 |
|
|
end if;
|
130 |
|
|
|
131 |
|
|
search_table_rden <= '1';
|
132 |
|
|
|
133 |
|
|
when compare => -- there is a hit on DA and VID
|
134 |
|
|
if search_table_q(esoc_search_entry_vlan+11 downto esoc_search_entry_vlan) = search_key_i(esoc_search_entry_vlan+11 downto esoc_search_entry_vlan) and
|
135 |
|
|
search_table_q(esoc_search_entry_mac+47 downto esoc_search_entry_mac) = search_key_i(esoc_search_entry_mac+47 downto esoc_search_entry_mac) then
|
136 |
|
|
|
137 |
|
|
-- entry valid, provide destination information else return broadcast as result
|
138 |
|
|
if search_table_q(esoc_search_entry_valid) = '1' then
|
139 |
|
|
search_result_av <= '1';
|
140 |
|
|
search_result_i <= search_table_q(esoc_search_entry_destination+esoc_port_count-1 downto esoc_search_entry_destination);
|
141 |
|
|
search_state <= idle;
|
142 |
|
|
else
|
143 |
|
|
search_result_av <= '1';
|
144 |
|
|
search_result_i <= (others => '1');
|
145 |
|
|
search_state <= idle;
|
146 |
|
|
end if;
|
147 |
|
|
|
148 |
|
|
-- there is no hit on DA and VID
|
149 |
|
|
else
|
150 |
|
|
-- End of collision buffer reached, no increment address for next entry else return result
|
151 |
|
|
if search_table_coll_cnt < esoc_search_engine_col_depth then
|
152 |
|
|
search_table_coll_cnt <= search_table_coll_cnt + 1;
|
153 |
|
|
search_table_address_i <= std_logic_vector(to_unsigned(to_integer(unsigned(search_table_address_i))+1,search_table_address_i'length));
|
154 |
|
|
search_table_rden <= '1';
|
155 |
|
|
|
156 |
|
|
-- end of collission buffer, no hit, return broadcast as result
|
157 |
|
|
else
|
158 |
|
|
search_result_av <= '1';
|
159 |
|
|
search_result_i <= (others => '1');
|
160 |
|
|
search_state <= idle;
|
161 |
|
|
end if;
|
162 |
|
|
end if;
|
163 |
|
|
|
164 |
|
|
when others => search_state <= idle;
|
165 |
|
|
end case;
|
166 |
|
|
end if;
|
167 |
|
|
end process;
|
168 |
|
|
|
169 |
|
|
search_table_wren <= '0';
|
170 |
|
|
search_table_data <= (others => '0');
|
171 |
|
|
search_table_address <= search_table_address_i;
|
172 |
|
|
|
173 |
|
|
-- provide search result, but use port stall info to avoid use of data bus to stalled ports, waste of bus usage
|
174 |
|
|
search_result <= search_result_i and not(search_port_stalled_sync(esoc_port_count-1 downto 0));
|
175 |
|
|
|
176 |
|
|
end architecture esoc_search_engine_da ; -- of esoc_search_engine_da
|
177 |
|
|
|