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

Subversion Repositories esoc

[/] [esoc/] [trunk/] [Sources/] [logixa/] [esoc_port_processor_outbound.vhd] - Blame information for rev 42

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_processor_outbound
43
-- Last modified : Mon Apr 14 12:49:34 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_processor_outbound is
55
  generic(
56
    esoc_port_nr : integer := 0);
57
  port(
58
    clk_data             : in     std_logic;
59
    data                 : in     std_logic_vector(63 downto 0);
60
    data_eof             : in     std_logic;
61
    data_gnt_rd          : in     std_logic;
62
    data_port_sel        : in     std_logic_vector(esoc_port_count-1 downto 0);
63
    data_sof             : in     std_logic;
64
    outbound_data        : out    std_logic_vector(63 downto 0);
65
    outbound_data_full   : in     std_logic;
66
    outbound_data_write  : out    std_logic;
67
    outbound_done_cnt    : out    std_logic;
68
    outbound_drop_cnt    : out    std_logic;
69
    outbound_info        : out    std_logic_vector(15 downto 0);
70
    outbound_info_write  : out    std_logic;
71
    outbound_vlan_id     : out    STD_LOGIC_VECTOR(11 downto 0);
72
    outbound_vlan_member : in     STD_LOGIC_VECTOR(0 downto 0);
73
    reset                : in     std_logic);
74
end entity esoc_port_processor_outbound;
75
 
76
--------------------------------------------------------------------------------
77
-- Object        : Architecture work.esoc_port_processor_outbound.esoc_port_processor_outbound
78
-- Last modified : Mon Apr 14 12:49:34 2014.
79
--------------------------------------------------------------------------------
80
 
81
 
82
architecture esoc_port_processor_outbound of esoc_port_processor_outbound is
83
 
84
type   data_transfer_states is (idle, request, transfer);
85
signal data_transfer_state: data_transfer_states;
86
 
87
signal data_i             : std_logic_vector(data'high downto 0);
88
signal data_sof_i         : std_logic;
89
signal data_eof_i         : std_logic;
90
signal data_port_sel_i    : std_logic_vector(data_port_sel'high downto 0);
91
 
92
signal outbound_info_length: integer range 2**esoc_outbound_info_length_size-1 downto 0;
93
signal outbound_info_counter: integer range 2**esoc_outbound_info_length_size-1 downto 0;
94
 
95
signal outbound_data_write_i: std_logic;
96
 
97
signal outbound_vlan_member_check: std_logic;
98
 
99
begin
100
 
101
-- control the data bus when bus request is granted by arbiter for read access
102
data_i          <= data             when data_gnt_rd = '1'  else (others => '0');
103
data_sof_i      <= data_sof         when data_gnt_rd = '1'  else '0';
104
data_eof_i      <= data_eof         when data_gnt_rd = '1'  else '0';
105
data_port_sel_i <= data_port_sel    when data_gnt_rd = '1'  else (others => '0');
106
 
107
--=============================================================================================================
108
-- Process                : control the data bus and drive the outbound fifo's 
109
-- Description  : 
110
--=============================================================================================================    
111
dbus: process(clk_data, reset)
112
      begin
113
        if reset = '1' then
114
          outbound_data         <= (others => '0');
115
          outbound_data_write_i <= '0';
116
 
117
          outbound_info         <= (others => '0');
118
          outbound_info_write   <= '0';
119
          outbound_info_length  <= 0;
120
          outbound_info_counter <= 0;
121
 
122
          outbound_vlan_id      <= (others => '0');
123
          outbound_vlan_member_check <= '0';
124
 
125
          outbound_done_cnt     <= '0';
126
          outbound_drop_cnt     <= '0';
127
 
128
        elsif clk_data'event and clk_data = '1' then
129
          -- reset one clock active signals
130
          outbound_info_write   <= '0';
131
          outbound_data_write_i <= '0';
132
 
133
          outbound_done_cnt     <= '0';
134
          outbound_drop_cnt     <= '0';
135
 
136
          -- define unused bits to avoid inferred latch warning during analysis & synthesis
137
          outbound_info(esoc_outbound_info_unused3_flag downto esoc_outbound_info_unused2_flag) <= (others => '0');
138
 
139
          case data_transfer_state is
140
            when idle     =>  -- store packet info (VID, LENGTH) when port is selected and SOF is asserted
141
                              if data_port_sel_i(esoc_port_nr) = '1' and data_sof_i = '1' then
142
                                -- store packet if there is still space in the FIFO else increment counters
143
                                if outbound_data_full = '0' then
144
                                  -- get length of packet
145
                                  outbound_info_length        <= to_integer(unsigned(data_i(esoc_dbus_packet_info_length + esoc_dbus_packet_info_length_size-1 downto esoc_dbus_packet_info_length)));
146
 
147
                                  -- get VLAN ID of packet and check whether this port is member of the VLAN or not
148
                                  outbound_vlan_id            <= data_i(esoc_dbus_packet_info_vlan_tci+11 downto esoc_dbus_packet_info_vlan_tci);
149
                                  outbound_vlan_member_check  <= '0';
150
                                  outbound_info_counter       <= 0;
151
                                  outbound_info(esoc_outbound_info_vlan_flag) <= data_i(esoc_dbus_packet_info_vlan_flag);
152
                                  data_transfer_state         <= transfer;
153
 
154
                                else
155
                                  outbound_drop_cnt     <= '1';
156
                                end if;
157
                              end if;
158
 
159
            when transfer =>  -- if outbound data fifo is full or port is selected but not member of VLAN -> drop packet, drop packet is done 
160
                              -- in the esoc_mal_outbound entity, an error and the amount of bytes yet stored are set here and forwarded to that 
161
                              -- entity. Note: a part of the packet is yet stored, so calculate the number of stored bytes and do not use only
162
                              -- the packet length that is sent by the source.
163
                              if outbound_data_full = '1' or (outbound_vlan_member = "0" and outbound_vlan_member_check = '1') then
164
                                outbound_info(esoc_outbound_info_length + esoc_outbound_info_length_size -1 downto esoc_outbound_info_length) <= std_logic_vector(to_unsigned(outbound_info_counter-8,esoc_outbound_info_length_size));
165
                                outbound_info(esoc_outbound_info_error_flag) <= '1';
166
                                outbound_info_write   <= '1';
167
                                outbound_drop_cnt     <= '1';
168
                                data_transfer_state   <= idle;
169
 
170
                              -- no error, write data into data FIFO, update outbound_info_counter, this outbound_info_counter is used to 
171
                              -- calculate stored bytes when packet storage is aborted before packet is complete due to an error (data FIFO 
172
                              -- full or port not member of VLAN)
173
                              else
174
                                outbound_data <= data_i;
175
                                outbound_data_write_i <= '1';
176
                                outbound_info_counter <= outbound_info_counter + 8;
177
 
178
                                -- end of packet, store length and flags in info FIFO
179
                                if data_eof_i = '1' then
180
                                  outbound_info(esoc_outbound_info_length + esoc_outbound_info_length_size -1 downto esoc_outbound_info_length) <= std_logic_vector(to_unsigned(outbound_info_length,esoc_outbound_info_length_size));
181
                                  outbound_info(esoc_outbound_info_error_flag) <= '0';
182
                                  outbound_info_write   <= '1';
183
                                  outbound_done_cnt     <= '1';
184
                                  data_transfer_state   <= idle;
185
                                end if;
186
                              end if;
187
 
188
                              -- next time vlan membership is known, memory requires additional clock cycle, enable checking!
189
                              outbound_vlan_member_check <= '1';
190
 
191
            when others   =>  data_transfer_state <= idle;
192
          end case;
193
        end if;
194
      end process;
195
 
196
      -- write when FIFO is not full!
197
      outbound_data_write <= outbound_data_write_i and not(outbound_data_full);
198
 
199
end architecture esoc_port_processor_outbound ; -- of esoc_port_processor_outbound
200
 

powered by: WebSVN 2.1.0

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