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

Subversion Repositories esoc

[/] [esoc/] [trunk/] [Sources/] [logixa/] [esoc_port_mal_inbound.vhd] - Blame information for rev 45

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

Line No. Rev Author Line
1 42 lmaarsen
--------------------------------------------------------------------------------
2
----                                                                        ----
3
---- Ethernet Switch on Configurable Logic IP Core                          ----
4
----                                                                        ----
5
---- This file is part of the ESoCL project                                 ----
6
---- http://www.opencores.org/cores/esoc/                                   ----
7
----                                                                        ----
8
---- Description: see design description ESoCL_dd_71022001.pdf              ----
9
----                                                                        ----
10
---- To Do: see roadmap description ESoCL_dd_71022001.pdf                   ----
11
----        and/or release bulleting ESoCL_rb_71022001.pdf                  ----
12
----                                                                        ----
13
---- Author(s): L.Maarsen                                                   ----
14
---- Bert Maarsen, lmaarsen@opencores.org                                   ----
15
----                                                                        ----
16
--------------------------------------------------------------------------------
17
----                                                                        ----
18
---- Copyright (C) 2009 Authors and OPENCORES.ORG                           ----
19
----                                                                        ----
20
---- This source file may be used and distributed without                   ----
21
---- restriction provided that this copyright statement is not              ----
22
---- removed from the file and that any derivative work contains            ----
23
---- the original copyright notice and the associated disclaimer.           ----
24
----                                                                        ----
25
---- This source file is free software; you can redistribute it             ----
26
---- and/or modify it under the terms of the GNU Lesser General             ----
27
---- Public License as published by the Free Software Foundation;           ----
28
---- either version 2.1 of the License, or (at your option) any             ----
29
---- later version.                                                         ----
30
----                                                                        ----
31
---- This source is distributed in the hope that it will be                 ----
32
---- useful, but WITHOUT ANY WARRANTY; without even the implied             ----
33
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR                ----
34
---- PURPOSE. See the GNU Lesser General Public License for more            ----
35
---- details.                                                               ----
36
----                                                                        ----
37
---- You should have received a copy of the GNU Lesser General              ----
38
---- Public License along with this source; if not, download it             ----
39
---- from http://www.opencores.org/lgpl.shtml                               ----
40
----                                                                        ----
41
--------------------------------------------------------------------------------
42
-- Object        : Entity work.esoc_port_mal_inbound
43
-- Last modified : Mon Apr 14 12:49:11 2014.
44
--------------------------------------------------------------------------------
45
 
46
 
47
 
48
library ieee, std, work;
49
use ieee.std_logic_1164.all;
50
use std.textio.all;
51
use ieee.numeric_std.all;
52
use work.package_esoc_configuration.all;
53
 
54
entity esoc_port_mal_inbound is
55
  port(
56
    clk_control           : in     STD_LOGIC;
57
    ff_rx_a_empty         : in     STD_LOGIC;
58
    ff_rx_a_full          : in     STD_LOGIC;
59
    ff_rx_data            : in     STD_LOGIC_VECTOR(31 downto 0);
60
    ff_rx_dsav            : in     STD_LOGIC;
61
    ff_rx_dval            : in     STD_LOGIC;
62
    ff_rx_eop             : in     STD_LOGIC;
63
    ff_rx_mod             : in     STD_LOGIC_VECTOR(1 downto 0);
64
    ff_rx_rdy             : out    STD_LOGIC;
65
    ff_rx_sop             : in     STD_LOGIC;
66
    force_vlan_default_in : in     std_logic;
67
    inbound_data          : out    std_logic_vector(31 downto 0);
68
    inbound_data_full     : in     std_logic;
69
    inbound_data_write    : out    std_logic;
70
    inbound_header        : out    std_logic_vector(111 downto 0);
71
    inbound_header_write  : out    std_logic;
72
    inbound_info          : out    std_logic_vector(31 downto 0);
73
    inbound_info_write    : out    std_logic;
74
    port_vlan_default     : in     std_logic_vector(15 downto 0);
75
    reset                 : in     STD_LOGIC;
76
    rx_err_stat           : in     STD_LOGIC_VECTOR(17 downto 0);
77
    rx_frm_type           : in     STD_LOGIC_VECTOR(3 downto 0));
78
end entity esoc_port_mal_inbound;
79
 
80
--------------------------------------------------------------------------------
81
-- Object        : Architecture work.esoc_port_mal_inbound.esoc_port_mal_inbound
82
-- Last modified : Mon Apr 14 12:49:11 2014.
83
--------------------------------------------------------------------------------
84
 
85
 
86
---------------------------------------------------------------------------------------------------------------
87
-- architecture and declarations
88
---------------------------------------------------------------------------------------------------------------
89
architecture esoc_port_mal_inbound of esoc_port_mal_inbound is
90
 
91
---------------------------------------------------------------------------------------------------------------
92
-- registers
93
---------------------------------------------------------------------------------------------------------------
94
 
95
---------------------------------------------------------------------------------------------------------------
96
-- signals
97
---------------------------------------------------------------------------------------------------------------
98
signal ff_rx_counter: integer range 2**esoc_inbound_info_length_size-1 downto 0;
99
 
100
signal boundary64: std_logic;
101
signal boundary64_write: std_logic;
102
 
103
begin
104
 
105
--=============================================================================================================
106
-- Process                : write header and information - DMAC, SMAC, VLAN ID, LENGTH, FLAGS  - into HEADER and INFO FIFO
107
-- Description  : header information is used by the search process in the esoc_port_processor
108
--                info information is used by the data process in the esoc_port_processor
109
--=============================================================================================================    
110
infoheader: process(clk_control, reset)
111
            begin
112
              if reset = '1' then
113
                inbound_header          <= (others => '0');
114
                inbound_info            <= (others => '0');
115
                inbound_data            <= (others => '0');
116
 
117
                inbound_header_write    <= '0';
118
                inbound_info_write      <= '0';
119
                inbound_data_write      <= '0';
120
 
121
                ff_rx_counter           <= 0;
122
                boundary64              <= '0';
123
                boundary64_write        <= '0';
124
 
125
              elsif clk_control'event and clk_control = '1' then
126
                -- clear one-clock active signals
127
                inbound_header_write  <= '0';
128
                inbound_info_write    <= '0';
129
                inbound_data_write    <= '0';
130
                boundary64_write      <= '0';
131
 
132
                -- define unused bits to avoid inferred latch warning during analysis & synthesis
133
                inbound_header(esoc_inbound_header_unused3_flag downto esoc_inbound_header_unused1_flag) <= (others => '0');
134
                inbound_info(esoc_inbound_info_unused3_flag downto esoc_inbound_info_unused1_flag) <= (others => '0');
135
 
136
                --
137
                -- MONITOR THE ST INTERFACE TO MAC
138
                --
139
                -- finalise packet storage, always write at 64b boundaries, because the other side of the FIFO has a width of 64 bit!
140
                -- create dummy write if the packet at completion does not end on a 64 bit boundary.  
141
                inbound_data_write <= boundary64_write;
142
 
143
                if ff_rx_dval = '1' then
144
                  -- store data in FIFO
145
                  if ff_rx_sop = '1' or ff_rx_counter > 0 then
146
                    inbound_data_write    <= '1';
147
                    inbound_data          <= ff_rx_data;
148
                    ff_rx_counter         <= ff_rx_counter + 4;
149
 
150
                    -- init boundary64 signal at start of new packet
151
                    if ff_rx_sop = '1' then
152
                      boundary64 <= '1';
153
                    else
154
                      boundary64 <= not(boundary64);
155
                    end if;
156
                  end if;
157
 
158
                  --
159
                  -- MANIPULATE DATA
160
                  --
161
                  case ff_rx_counter is
162
                    when 0  =>      -- store DMAC (4 MSbs) in data FIFO and prepare header FIFO input
163
                                    if ff_rx_sop = '1' then
164
                                      inbound_header(esoc_inbound_header_dmac_hi+31 downto esoc_inbound_header_dmac_hi) <= ff_rx_data;
165
                                    end if;
166
 
167
                    when 4  =>      -- store DMAC (2LSBs), SMAC (2MSBs) in data FIFO and prepare header FIFO input
168
                                    inbound_header(esoc_inbound_header_dmac_lo+15 downto esoc_inbound_header_smac_hi) <= ff_rx_data;
169
 
170
                    when 8  =>      -- store SMAC (4 LSBs) in data FIFO and prepare header FIFO input
171
                                    inbound_header(esoc_inbound_header_smac_lo+31 downto esoc_inbound_header_smac_lo) <= ff_rx_data;
172
 
173
                    when 12 =>      -- tagged packet? store VLAN ID/TCI in data FIFO and prepare header FIFO input
174
                                    if ff_rx_data(31 downto 16) = esoc_ethernet_vlan_type then
175
                                      -- tagged with VLAN ID 0 is a QoS Packet only - or force default VLAN ID - replace VLAN ID with port default VLAN ID
176
                                      if ff_rx_data(11 downto 0) = esoc_ethernet_vlan_qos or force_vlan_default_in = '1' then
177
                                        inbound_data(15 downto 0) <= port_vlan_default;
178
 
179
                                        -- store default port VLAN ID in the header FIFO for the search operation
180
                                        inbound_header(esoc_inbound_header_vlan+11 downto esoc_inbound_header_vlan) <= port_vlan_default(11 downto 0);
181
                                        inbound_header(esoc_inbound_header_vlan_flag) <= '1';
182
 
183
                                        -- store  default port VLAN tag in the info FIFO for the data transfer operation
184
                                        inbound_info(esoc_inbound_info_vlan_tci+15 downto esoc_inbound_info_vlan_tci) <= port_vlan_default;
185
                                        inbound_info(esoc_inbound_info_vlan_flag) <= '1';
186
 
187
                                      -- tagged with VLAN ID > 0
188
                                      else
189
                                        -- store only VLAN ID in the header FIFO for the search operation
190
                                        inbound_header(esoc_inbound_header_vlan+11 downto esoc_inbound_header_vlan) <= ff_rx_data(11 downto 0);
191
                                        inbound_header(esoc_inbound_header_vlan_flag) <= '1';
192
 
193
                                        -- store comlete VLAN tag in the info FIFO for the data transfer operation
194
                                        inbound_info(esoc_inbound_info_vlan_tci+15 downto esoc_inbound_info_vlan_tci) <= ff_rx_data(15 downto 0);
195
                                        inbound_info(esoc_inbound_info_vlan_flag) <= '1';
196
                                      end if;
197
 
198
                                    -- untagged packet
199
                                    else
200
                                      -- store default port VLAN ID in the header FIFO for the search operation
201
                                      inbound_header(esoc_inbound_header_vlan+11 downto esoc_inbound_header_vlan) <= port_vlan_default(11 downto 0);
202
                                      inbound_header(esoc_inbound_header_vlan_flag) <= '0';
203
 
204
                                      -- store  default port VLAN tag in the info FIFO for the data transfer operation
205
                                      inbound_info(esoc_inbound_info_vlan_tci+15 downto esoc_inbound_info_vlan_tci) <= port_vlan_default;
206
                                      inbound_info(esoc_inbound_info_vlan_flag) <= '0';
207
                                    end if;
208
 
209
                                    -- write header when complete, search operation can start!
210
                                    inbound_header_write <= '1';
211
 
212
                    when others =>  -- Write information in to fifo when packet is complete, data operation can start!
213
                                    if ff_rx_eop = '1' then
214
                                      ff_rx_counter    <= 0;
215
                                      inbound_info(esoc_inbound_info_length+esoc_inbound_info_length_size-1 downto esoc_inbound_info_length) <= std_logic_vector(to_unsigned(ff_rx_counter + 4 - to_integer(unsigned(ff_rx_mod)),esoc_inbound_info_length_size));
216
                                      inbound_info_write <= '1';
217
                                      boundary64_write <= not(boundary64);
218
                                    end if;
219
                  end case;
220
                end if;
221
              end if;
222
            end process;
223
 
224
--=============================================================================================================
225
-- Process                : write packet into DATA FIFO
226
-- Description  : 
227
--=============================================================================================================                
228
            -- FULL signal of FIFO is used to drive READY of ST Sink interface
229
            ff_rx_rdy <= not(inbound_data_full);
230
 
231
end architecture esoc_port_mal_inbound ; -- of esoc_port_mal_inbound

powered by: WebSVN 2.1.0

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