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

Subversion Repositories esoc

[/] [esoc/] [trunk/] [Sources/] [logixa/] [esoc_port_processor_inbound.vhd] - Blame information for rev 48

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_inbound
43
-- Last modified : Mon Apr 14 12:49:30 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_inbound is
55
  generic(
56
    esoc_port_nr : integer := 0);
57
  port(
58
    clk_data           : in     std_logic;
59
    data               : inout  std_logic_vector(63 downto 0);
60
    data_eof           : inout  std_logic;
61
    data_gnt_wr        : in     std_logic;
62
    data_port_sel      : inout  std_logic_vector(esoc_port_count-1 downto 0);
63
    data_req           : out    std_logic;
64
    data_sof           : inout  std_logic;
65
    inbound_data       : in     std_logic_vector(63 downto 0);
66
    inbound_data_full  : in     std_logic;
67
    inbound_data_read  : out    std_logic;
68
    inbound_done_cnt   : out    std_logic;
69
    inbound_drop_cnt   : out    std_logic;
70
    inbound_info       : in     std_logic_vector(31 downto 0);
71
    inbound_info_empty : in     std_logic;
72
    inbound_info_read  : out    std_logic;
73
    reset              : in     std_logic;
74
    search_data        : in     STD_LOGIC_VECTOR(15 downto 0);
75
    search_empty       : in     STD_LOGIC;
76
    search_read        : out    STD_LOGIC);
77
end entity esoc_port_processor_inbound;
78
 
79
--------------------------------------------------------------------------------
80
-- Object        : Architecture work.esoc_port_processor_inbound.esoc_port_processor_inbound
81
-- Last modified : Mon Apr 14 12:49:30 2014.
82
--------------------------------------------------------------------------------
83
 
84
 
85
architecture esoc_port_processor_inbound of esoc_port_processor_inbound is
86
 
87
type   data_transfer_states is (idle, granted, transfer, wait_gnt, wait_no_gnt);
88
signal data_transfer_state: data_transfer_states;
89
 
90
signal data_o             : std_logic_vector(data'high downto 0);
91
signal data_sof_o         : std_logic;
92
signal data_eof_o         : std_logic;
93
signal data_port_sel_o    : std_logic_vector(data_port_sel'high downto 0);
94
 
95
signal clear_data_req     : std_logic;
96
 
97
signal inbound_drop       : std_logic;
98
signal inbound_data_full_i: std_logic;
99
signal inbound_data_read_o: std_logic;
100
signal inbound_info_length: integer range 2**esoc_inbound_info_length_size-1 downto 0;
101
 
102
begin
103
 
104
-- control the data bus when bus request is granted by arbiter for write access
105
data            <= data_o           when data_gnt_wr = '1' else (others => 'Z');
106
data_sof        <= data_sof_o       when data_gnt_wr = '1' else 'Z';
107
data_eof        <= data_eof_o       when data_gnt_wr = '1' else 'Z';
108
data_port_sel   <= data_port_sel_o  when data_gnt_wr = '1' else (others => 'Z');
109
 
110
--=============================================================================================================
111
-- Process                : read the inbound fifo's and control the data bus
112
-- Description  : 
113
--=============================================================================================================    
114
dbus:      process(clk_data, reset)
115
            begin
116
              if reset = '1' then
117
                data_o            <= (others => '0');
118
                data_sof_o        <= '0';
119
                data_eof_o        <= '0';
120
                data_port_sel_o   <= (others => '0');
121
                data_req          <= '0';
122
                clear_data_req    <= '0';
123
 
124
                inbound_info_read   <= '0';
125
                inbound_data_read_o <= '0';
126
                search_read         <= '0';
127
 
128
                inbound_info_length <= 0;
129
                inbound_done_cnt    <= '0';
130
                inbound_drop_cnt    <= '0';
131
                inbound_drop        <= '0';
132
                inbound_data_full_i <= '0';
133
 
134
              elsif clk_data'event and clk_data = '1' then
135
                -- reset one clock active signals
136
                inbound_info_read   <= '0';
137
                search_read         <= '0';
138
                data_eof_o          <= '0';
139
                clear_data_req      <= '0';
140
                inbound_done_cnt    <= '0';
141
                inbound_drop_cnt    <= '0';
142
 
143
                -- detect rising edges of the inbound_data_full input and count!
144
                inbound_data_full_i <= inbound_data_full;
145
 
146
                if inbound_data_full_i = '0' and inbound_data_full = '1'  then
147
                  inbound_drop_cnt <= '1';
148
                end if;
149
 
150
                -- request for data bus as long as there are new packets ready to transfer with a destination, de-assert one clock between
151
                -- two request to acknowledge the grant to the arbiter.
152
                if inbound_info_empty = '0' and search_empty = '0' and to_integer(unsigned(search_data)) /=0 and clear_data_req = '0' then
153
                  data_req <= '1';
154
                elsif clear_data_req = '1' then
155
                  data_req <= '0';
156
                end if;
157
 
158
                case data_transfer_state is
159
                  when idle     =>      -- new info and search data present? Ready to transfer packet, prepare and wait for bus grant!
160
                                        if inbound_info_empty = '0' and search_empty = '0' then
161
                                          -- INFO FIFO -> store packet length from fifo for further processing
162
                                          inbound_info_length <= to_integer(unsigned(inbound_info(esoc_inbound_info_length+esoc_inbound_info_length_size-1 downto esoc_inbound_info_length)));
163
 
164
                                          -- INFO FIFO -> drive the data bus signals with packet info like eSOC source port, length. VLAN and flags
165
                                          data_o(esoc_dbus_packet_info_sport+3 downto esoc_dbus_packet_info_sport)                                     <= std_logic_vector(to_unsigned(esoc_port_nr,4));
166
                                          data_o(esoc_dbus_packet_info_length+esoc_dbus_packet_info_length_size-1 downto esoc_dbus_packet_info_length) <= inbound_info(esoc_inbound_info_length+esoc_inbound_info_length_size-1 downto esoc_inbound_info_length);
167
                                          data_o(esoc_dbus_packet_info_unused3_flag downto esoc_dbus_packet_info_vlan_flag)                            <= inbound_info(esoc_inbound_info_unused3_flag downto esoc_inbound_info_vlan_flag);
168
                                          data_o(esoc_dbus_packet_info_vlan_tci+15 downto esoc_dbus_packet_info_vlan_tci)                              <= inbound_info(esoc_inbound_info_vlan_tci+15 downto esoc_inbound_info_vlan_tci);
169
 
170
                                          -- SEARCH FIFO -> drive data bus port select signals with data from SEARCH FIFO, only valid destinations will be enabled
171
                                          data_port_sel_o <= search_data(data_port_sel_o'high downto 0);
172
 
173
                                          -- DATA FIFO -> start acknowledging data from the DATA FIFO, real acknowledge depends on outcome of if-then-else statement below!
174
                                          -- No drop -> real acknowledges when bus grant is detectt, drop -> acknowledges immediately
175
                                          inbound_data_read_o <= '1';
176
 
177
                                          -- if there are no ports selected then packet must be dropped else request data bus and acknowledge data from search and info FIFO
178
                                          if to_integer(unsigned(search_data)) = 0 then
179
                                            inbound_drop        <= '1';
180
                                            search_read         <= '1';
181
                                            inbound_info_read   <= '1';
182
                                            data_transfer_state <= transfer;
183
                                          else
184
                                            data_sof_o <= '1';
185
                                            inbound_drop <= '0';
186
                                            data_transfer_state <= wait_gnt;
187
                                          end if;
188
                                        end if;
189
 
190
                  when wait_gnt =>      -- Wait for bus grant from arbiter before acknowledge data from the INFO and SEARCH FIFO when granted
191
                                        -- If data_gnt_wr is sampled high the first word is already transferred, remove SOF, provide next word.
192
                                        if data_gnt_wr = '1' then
193
                                          -- Bus grant received, clear request and acknowledge data from search and info FIFO
194
                                          clear_data_req      <= '1';
195
                                          search_read         <= '1';
196
                                          inbound_info_read   <= '1';
197
 
198
                                          -- First word (packet info) send, remove Start of Frame and provide the first data of packet
199
                                          data_sof_o          <= '0';
200
                                          data_o              <= inbound_data;
201
                                          inbound_info_length <= inbound_info_length - 8;
202
                                          data_transfer_state <= transfer;
203
                                        end if;
204
 
205
                  when transfer     =>  -- Keep on reading data FIFO until last word is read, terminate bus (End of Frame) if the packet isn't dropped
206
                                        if inbound_info_length > 8 then
207
                                          inbound_info_length <= inbound_info_length - 8;
208
                                          data_o <= inbound_data;
209
 
210
                                        else
211
                                          -- Provide last data, stop accessing data FIFO
212
                                          data_o <= inbound_data;
213
                                          inbound_data_read_o <= '0';
214
 
215
                                          -- Termination of bus access and increment of drop counter depends on the drop status
216
                                          data_eof_o <= not(inbound_drop);
217
                                          inbound_drop_cnt <= inbound_drop;
218
                                          inbound_done_cnt <= not(inbound_drop);
219
                                          data_transfer_state <= wait_no_gnt;
220
                                        end if;
221
 
222
                  when  wait_no_gnt =>  -- Wait for no bus grant from bus arbiter , bus arbiter must proces the EOF of this module, wait one clock cycle before next packet can be processed.
223
                                        data_transfer_state <= idle;
224
 
225
                  when others       =>  data_transfer_state <= idle;
226
                end case;
227
              end if;
228
            end process;
229
 
230
            -- Read from fifo is under control of the data bus grant signal or drop decision
231
            inbound_data_read <= inbound_data_read_o when data_gnt_wr = '1' or inbound_drop = '1' else '0';
232
 
233
end architecture esoc_port_processor_inbound ; -- of esoc_port_processor_inbound
234
 

powered by: WebSVN 2.1.0

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