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_port_processor_search
|
19 |
|
|
-- Last modified : Mon Apr 14 12:49:39 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_esoc_configuration.all;
|
29 |
|
|
|
30 |
|
|
entity esoc_port_processor_search is
|
31 |
|
|
generic(
|
32 |
|
|
esoc_port_nr : integer := 0);
|
33 |
|
|
port(
|
34 |
|
|
clk_search : in std_logic;
|
35 |
|
|
inbound_header : in std_logic_vector(111 downto 0);
|
36 |
|
|
inbound_header_empty : in std_logic;
|
37 |
|
|
inbound_header_read : out std_logic;
|
38 |
|
|
inbound_vlan_member : in STD_LOGIC_VECTOR(0 downto 0);
|
39 |
|
|
reset : in std_logic;
|
40 |
|
|
search_data : out STD_LOGIC_VECTOR(15 downto 0);
|
41 |
|
|
search_done_cnt : out std_logic;
|
42 |
|
|
search_drop_cnt : out std_logic;
|
43 |
|
|
search_eof : out std_logic;
|
44 |
|
|
search_gnt_wr : in std_logic;
|
45 |
|
|
search_key : out std_logic_vector(63 downto 0);
|
46 |
|
|
search_req : out std_logic;
|
47 |
|
|
search_result : in std_logic_vector(esoc_port_count-1 downto 0);
|
48 |
|
|
search_result_av : in std_logic;
|
49 |
|
|
search_sof : out std_logic;
|
50 |
|
|
search_write : out STD_LOGIC);
|
51 |
|
|
end entity esoc_port_processor_search;
|
52 |
|
|
|
53 |
|
|
--------------------------------------------------------------------------------
|
54 |
|
|
-- Object : Architecture work.esoc_port_processor_search.esoc_port_processor_search
|
55 |
|
|
-- Last modified : Mon Apr 14 12:49:39 2014.
|
56 |
|
|
--------------------------------------------------------------------------------
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
architecture esoc_port_processor_search of esoc_port_processor_search is
|
60 |
|
|
|
61 |
|
|
type search_states is (idle, send_key_1, send_key_2, wait_for_result);
|
62 |
|
|
signal search_state: search_states;
|
63 |
|
|
|
64 |
|
|
signal search_sof_o: std_logic;
|
65 |
|
|
signal search_eof_o: std_logic;
|
66 |
|
|
signal search_key_o: std_logic_vector(search_key'high downto 0);
|
67 |
|
|
|
68 |
|
|
signal inbound_header_empty_i: std_logic;
|
69 |
|
|
|
70 |
|
|
begin
|
71 |
|
|
|
72 |
|
|
-- control the shared bus to the search engine
|
73 |
|
|
search_sof <= search_sof_o when search_gnt_wr = '1' else 'Z';
|
74 |
|
|
search_eof <= search_eof_o when search_gnt_wr = '1' else 'Z';
|
75 |
|
|
search_key <= search_key_o when search_gnt_wr = '1' else (others => 'Z');
|
76 |
|
|
|
77 |
|
|
--=============================================================================================================
|
78 |
|
|
-- Process :
|
79 |
|
|
-- Description :
|
80 |
|
|
--=============================================================================================================
|
81 |
|
|
debug: process(clk_search, reset)
|
82 |
|
|
begin
|
83 |
|
|
if reset = '1' then
|
84 |
|
|
inbound_header_read <= '0';
|
85 |
|
|
inbound_header_empty_i <= '0';
|
86 |
|
|
|
87 |
|
|
search_req <= '0';
|
88 |
|
|
search_sof_o <= '0';
|
89 |
|
|
search_eof_o <= '0';
|
90 |
|
|
search_key_o <= (others => '0');
|
91 |
|
|
|
92 |
|
|
search_data <= (others => '0');
|
93 |
|
|
search_write <= '0';
|
94 |
|
|
|
95 |
|
|
search_done_cnt <= '0';
|
96 |
|
|
search_drop_cnt <= '0';
|
97 |
|
|
|
98 |
|
|
search_state <= idle;
|
99 |
|
|
|
100 |
|
|
elsif clk_search'event and clk_search = '1' then
|
101 |
|
|
-- reset one clock active signals
|
102 |
|
|
search_eof_o <= '0';
|
103 |
|
|
search_done_cnt <= '0';
|
104 |
|
|
search_drop_cnt <= '0';
|
105 |
|
|
search_write <= '0';
|
106 |
|
|
inbound_header_read <= '0';
|
107 |
|
|
|
108 |
|
|
-- delay the empty signal to proces the VLAN membership of the first packet correctly. When the header
|
109 |
|
|
-- data of first packet is written in de header FIFO the empty signal deasserts, but in parallel (outside
|
110 |
|
|
-- this entity) the VLAN ID RAM is addressed. This entity detects the deasserted EMTPY signal and expects
|
111 |
|
|
-- the corresponding VLAN membership info from the VLAN ID RAM, which is not available at that time!
|
112 |
|
|
-- This is only applicable if the first header in the FIFO is from a tagged packet and the EMPTY latency of the
|
113 |
|
|
-- FIFO is 0, the latter is not the case for Altera, so you can skip this delay by using the inbound_header_empty
|
114 |
|
|
-- iso. the inbound_header_empty_i signal in the search_state idle .... check simulation!
|
115 |
|
|
inbound_header_empty_i <= inbound_header_empty;
|
116 |
|
|
|
117 |
|
|
case search_state is
|
118 |
|
|
when idle => -- used to insert a clock delay
|
119 |
|
|
search_state <= send_key_1;
|
120 |
|
|
|
121 |
|
|
when send_key_1 => -- check for new header data,new header data means new packet is coming or already available
|
122 |
|
|
if inbound_header_empty = '0' then
|
123 |
|
|
-- Is the inbound port member of the VID of the tagged packet or
|
124 |
|
|
-- is the packet untagged and does the switch use the port default VID?
|
125 |
|
|
if inbound_header(esoc_inbound_header_vlan_flag) = '0' or inbound_vlan_member = "1" then
|
126 |
|
|
-- Request bus to the search engine, prepare to transfer VID and DA
|
127 |
|
|
search_req <= '1';
|
128 |
|
|
search_sof_o <= '1';
|
129 |
|
|
search_key_o(esoc_search_bus_vlan+11 downto esoc_search_bus_vlan) <= inbound_header(esoc_inbound_header_vlan+11 downto esoc_inbound_header_vlan);
|
130 |
|
|
search_key_o(esoc_search_bus_mac+47 downto esoc_search_bus_mac) <= inbound_header(esoc_inbound_header_dmac_lo+47 downto esoc_inbound_header_dmac_lo);
|
131 |
|
|
search_state <= send_key_2;
|
132 |
|
|
|
133 |
|
|
-- Packet is tagged and the inbound port is not member of the packet VID
|
134 |
|
|
else
|
135 |
|
|
-- Write destination port (none) and acknowledge header data
|
136 |
|
|
search_data <= (others => '0');
|
137 |
|
|
search_write <= '1';
|
138 |
|
|
inbound_header_read <= '1';
|
139 |
|
|
search_drop_cnt <= '1';
|
140 |
|
|
search_state <= idle;
|
141 |
|
|
end if;
|
142 |
|
|
end if;
|
143 |
|
|
|
144 |
|
|
when send_key_2 => -- VID and DA Address accepted when granted, provide Port Number and SA Address for learning process
|
145 |
|
|
if search_gnt_wr = '1' then
|
146 |
|
|
search_key_o(esoc_search_bus_sport+15 downto esoc_search_bus_sport) <= (others => '0');
|
147 |
|
|
search_key_o(esoc_search_bus_sport+esoc_port_nr) <= '1';
|
148 |
|
|
search_key_o(esoc_search_bus_mac+47 downto esoc_search_bus_mac) <= inbound_header(esoc_inbound_header_smac_lo+47 downto esoc_inbound_header_smac_lo);
|
149 |
|
|
search_sof_o <= '0';
|
150 |
|
|
inbound_header_read <= '1';
|
151 |
|
|
search_state <= wait_for_result;
|
152 |
|
|
end if;
|
153 |
|
|
|
154 |
|
|
when wait_for_result => -- Wait for result from search engine
|
155 |
|
|
if search_result_av = '1' then
|
156 |
|
|
-- Write destination ports, skip your self, acknowledge header data
|
157 |
|
|
search_data(search_result'high downto 0) <= search_result;
|
158 |
|
|
search_data(esoc_port_nr) <= '0';
|
159 |
|
|
search_write <= '1';
|
160 |
|
|
|
161 |
|
|
search_done_cnt <= '1';
|
162 |
|
|
search_req <= '0';
|
163 |
|
|
search_eof_o <= '1';
|
164 |
|
|
search_state <= send_key_1;
|
165 |
|
|
end if;
|
166 |
|
|
|
167 |
|
|
when others => search_state <= idle;
|
168 |
|
|
end case;
|
169 |
|
|
end if;
|
170 |
|
|
end process;
|
171 |
|
|
end architecture esoc_port_processor_search ; -- of esoc_port_processor_search
|
172 |
|
|
|