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

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [rtl/] [vhdl/] [IP_complete_nomac.vhd] - Blame information for rev 10

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

Line No. Rev Author Line
1 2 pjf
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    12:43:16 06/04/2011 
6
-- Design Name: 
7
-- Module Name:    IP_complete_nomac - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: Implements complete IP stack with ARP (but no MAC)
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Revision 0.02 - separated RX and TX clocks
18 4 pjf
-- Revision 0.03 - Added mac_tx_tfirst
19 2 pjf
-- Additional Comments: 
20
--
21
----------------------------------------------------------------------------------
22
LIBRARY ieee;
23
USE ieee.std_logic_1164.ALL;
24
use IEEE.NUMERIC_STD.ALL;
25
use work.axi.all;
26
use work.ipv4_types.all;
27
use work.arp_types.all;
28 10 pjf
use work.arp;
29
use work.arpv2;
30 2 pjf
 
31
entity IP_complete_nomac is
32 8 pjf
         generic (
33
                        CLOCK_FREQ                      : integer := 125000000;                                                 -- freq of data_in_clk -- needed to timout cntr
34 10 pjf
                        ARP_TIMEOUT                     : integer := 60;                                                                        -- ARP response timeout (s)
35
                        ARP_MAX_PKT_TMO : integer := 5;                                                                 -- # wrong nwk pkts received before set error
36
                        MAX_ARP_ENTRIES         : integer := 255                                                                        -- max entries in the ARP store
37 8 pjf
                        );
38 2 pjf
    Port (
39
                        -- IP Layer signals
40
                        ip_tx_start                             : in std_logic;
41
                        ip_tx                                           : in ipv4_tx_type;                                                              -- IP tx cxns
42
                        ip_tx_result                    : out std_logic_vector (1 downto 0);             -- tx status (changes during transmission)
43
                        ip_tx_data_out_ready    : out std_logic;                                                                        -- indicates IP TX is ready to take data
44
                        ip_rx_start                             : out std_logic;                                                                        -- indicates receipt of ip frame.
45
                        ip_rx                                           : out ipv4_rx_type;
46
                        -- system signals
47
                        rx_clk                                  : in  STD_LOGIC;
48
                        tx_clk                                  : in  STD_LOGIC;
49
                        reset                                   : in  STD_LOGIC;
50
                        our_ip_address          : in STD_LOGIC_VECTOR (31 downto 0);
51
                        our_mac_address                 : in std_logic_vector (47 downto 0);
52 8 pjf
                        control                                 : in ip_control_type;
53 2 pjf
                        -- status signals
54
                        arp_pkt_count                   : out STD_LOGIC_VECTOR(7 downto 0);                      -- count of arp pkts received
55
                        ip_pkt_count                    : out STD_LOGIC_VECTOR(7 downto 0);                      -- number of IP pkts received for us
56
                        -- MAC Transmitter
57
                        mac_tx_tdata         : out  std_logic_vector(7 downto 0);        -- data byte to tx
58
                        mac_tx_tvalid        : out  std_logic;                                                  -- tdata is valid
59
                        mac_tx_tready        : in std_logic;                                                    -- mac is ready to accept data
60 4 pjf
                        mac_tx_tfirst        : out  std_logic;                                                  -- indicates first byte of frame
61 2 pjf
                        mac_tx_tlast         : out  std_logic;                                                  -- indicates last byte of frame
62
                        -- MAC Receiver
63
                        mac_rx_tdata         : in std_logic_vector(7 downto 0);  -- data byte received
64
                        mac_rx_tvalid        : in std_logic;                                                    -- indicates tdata is valid
65
                        mac_rx_tready        : out  std_logic;                                                  -- tells mac that we are ready to take data
66
                        mac_rx_tlast         : in std_logic                                                             -- indicates last byte of the trame
67
                        );
68
end IP_complete_nomac;
69
 
70 10 pjf
 
71 2 pjf
architecture structural of IP_complete_nomac is
72
 
73
    COMPONENT IPv4
74
    PORT(
75
                        -- IP Layer signals
76
                        ip_tx_start                             : in std_logic;
77
                        ip_tx                                           : in ipv4_tx_type;                                                              -- IP tx cxns
78
                        ip_tx_result                    : out std_logic_vector (1 downto 0);             -- tx status (changes during transmission)
79
                        ip_tx_data_out_ready    : out std_logic;                                                                        -- indicates IP TX is ready to take data
80
                        ip_rx_start                             : out std_logic;                                                                        -- indicates receipt of ip frame.
81
                        ip_rx                                           : out ipv4_rx_type;
82
                        -- system control signals
83
                        rx_clk                                  : in  STD_LOGIC;
84
                        tx_clk                                  : in  STD_LOGIC;
85
                        reset                                   : in  STD_LOGIC;
86
                        our_ip_address          : in STD_LOGIC_VECTOR (31 downto 0);
87
                        our_mac_address                 : in std_logic_vector (47 downto 0);
88
                        -- system status signals
89
                        rx_pkt_count                    : out STD_LOGIC_VECTOR(7 downto 0);                      -- number of IP pkts received for us
90
                        -- ARP lookup signals
91
                        arp_req_req                             : out arp_req_req_type;
92
                        arp_req_rslt                    : in arp_req_rslt_type;
93
                        -- MAC layer RX signals
94
                        mac_data_in                     : in  STD_LOGIC_VECTOR (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
95
                        mac_data_in_valid       : in  STD_LOGIC;                                                                        -- indicates data_in valid on clock
96
                        mac_data_in_last                : in  STD_LOGIC;                                                                        -- indicates last data in frame
97
                        -- MAC layer TX signals
98
                        mac_tx_req                              : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
99
                        mac_tx_granted                  : in std_logic;                                                                 -- indicates that access to channel has been granted            
100
                        mac_data_out_ready      : in std_logic;                                                                 -- indicates system ready to consume data
101
                        mac_data_out_valid      : out std_logic;                                                                        -- indicates data out is valid
102 4 pjf
                        mac_data_out_first      : out std_logic;                                                                        -- with data out valid indicates the first byte of a frame
103 2 pjf
                        mac_data_out_last               : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
104
                        mac_data_out                    : out std_logic_vector (7 downto 0)                      -- ethernet frame (from dst mac addr through to last byte of frame)      
105
         );
106
         END COMPONENT;
107
 
108
    COMPONENT arp
109 8 pjf
         generic (
110
                        CLOCK_FREQ                      : integer := 125000000;                                                 -- freq of data_in_clk -- needed to timout cntr
111 10 pjf
                        ARP_TIMEOUT                     : integer := 60;                                                                        -- ARP response timeout (s)
112
                        ARP_MAX_PKT_TMO : integer := 1;                                                                 -- (added for compatibility with arpv2. this value not used in this impl)
113
                        MAX_ARP_ENTRIES         : integer := 1                                                                          -- (added for compatibility with arpv2. this value not used in this impl)
114 8 pjf
                        );
115
    Port (
116 2 pjf
                        -- lookup request signals
117
                        arp_req_req                     : in arp_req_req_type;
118
                        arp_req_rslt            : out arp_req_rslt_type;
119
                        -- MAC layer RX signals
120
                        data_in_clk             : in  STD_LOGIC;
121
                        reset                           : in  STD_LOGIC;
122
                        data_in                                 : in  STD_LOGIC_VECTOR (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
123
                        data_in_valid           : in  STD_LOGIC;                                                                        -- indicates data_in valid on clock
124
                        data_in_last            : in  STD_LOGIC;                                                                        -- indicates last data in frame
125
                        -- MAC layer TX signals
126
                        mac_tx_req                      : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
127
                        mac_tx_granted          : in std_logic;                                                                 -- indicates that access to channel has been granted            
128
                        data_out_clk            : in std_logic;
129
                        data_out_ready          : in std_logic;                                                                 -- indicates system ready to consume data
130
                        data_out_valid          : out std_logic;                                                                        -- indicates data out is valid
131 4 pjf
                        data_out_first          : out std_logic;                                                                        -- with data out valid indicates the first byte of a frame
132 2 pjf
                        data_out_last           : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
133
                        data_out                                : out std_logic_vector (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
134
                        -- system signals
135
                        our_mac_address         : in STD_LOGIC_VECTOR (47 downto 0);
136 8 pjf
                        our_ip_address  : in STD_LOGIC_VECTOR (31 downto 0);
137
                        control                         : in arp_control_type;
138 2 pjf
                        req_count                       : out STD_LOGIC_VECTOR(7 downto 0)                       -- count of arp pkts received
139 8 pjf
                        );
140 2 pjf
         END COMPONENT;
141
 
142
    COMPONENT tx_arbitrator
143
    PORT(
144
                clk                             : in std_logic;
145
                reset                           : in std_logic;
146
 
147
                req_1                           : in  std_logic;
148
                grant_1                 : out std_logic;
149
      data_1         : in  std_logic_vector(7 downto 0); -- data byte to tx
150
      valid_1        : in  std_logic;                                                   -- tdata is valid
151 4 pjf
      first_1        : in  std_logic;                                                   -- indicates first byte of frame
152 2 pjf
      last_1         : in  std_logic;                                                   -- indicates last byte of frame
153
 
154
                req_2                           : in  std_logic;
155
                grant_2                 : out std_logic;
156
      data_2         : in  std_logic_vector(7 downto 0); -- data byte to tx
157
      valid_2        : in  std_logic;                                                   -- tdata is valid
158 4 pjf
      first_2        : in  std_logic;                                                   -- indicates first byte of frame
159 2 pjf
      last_2         : in  std_logic;                                                   -- indicates last byte of frame
160
 
161
      data              : out  std_logic_vector(7 downto 0);     -- data byte to tx
162
      valid             : out  std_logic;                                                       -- tdata is valid
163 4 pjf
      first             : out  std_logic;                                                       -- indicates first byte of frame
164 2 pjf
      last              : out  std_logic                                                        -- indicates last byte of frame
165
         );
166
         END COMPONENT;
167
 
168 10 pjf
 
169
        -------------------
170
        -- Configuration
171
        --
172
        -- Enable one of the following to specify which
173
        -- implementation of the ARP layer to use
174
        -------------------
175
 
176
 
177
--      for arp_layer : arp use entity work.arp;                        -- single slot arbitrator
178
        for arp_layer : arp use entity work.arpv2;                      -- multislot arbitrator
179
 
180
 
181
 
182 2 pjf
        ---------------------------
183
        -- Signals
184
        ---------------------------
185
 
186
        -- ARP REQUEST
187
        signal arp_req_req_int          : arp_req_req_type;
188
        signal arp_req_rslt_int         : arp_req_rslt_type;
189
        -- MAC arbitration busses
190
        signal ip_mac_req                               : std_logic;
191
        signal ip_mac_grant                     : std_logic;
192
        signal ip_mac_data_out          : std_logic_vector (7 downto 0);
193
        signal ip_mac_valid                     : std_logic;
194 4 pjf
        signal ip_mac_first                     : std_logic;
195 2 pjf
        signal ip_mac_last                      : std_logic;
196
        signal arp_mac_req                      : std_logic;
197
        signal arp_mac_grant                    : std_logic;
198
        signal arp_mac_data_out         : std_logic_vector (7 downto 0);
199
        signal arp_mac_valid                    : std_logic;
200 4 pjf
        signal arp_mac_first                    : std_logic;
201 2 pjf
        signal arp_mac_last                     : std_logic;
202
        -- MAC RX bus
203
        signal mac_rx_tready_int        : std_logic;
204
        -- MAC TX bus
205
        signal mac_tx_tdata_int         : std_logic_vector (7 downto 0);
206
        signal mac_tx_tvalid_int        : std_logic;
207 4 pjf
        signal mac_tx_tfirst_int        : std_logic;
208 2 pjf
        signal mac_tx_tlast_int         : std_logic;
209
        -- control signals
210
        signal mac_tx_granted_int       : std_logic;
211
 
212
begin
213
 
214
        mac_rx_tready_int <= '1';               -- enable the mac receiver
215
 
216
        -- set followers
217
        mac_tx_tdata <= mac_tx_tdata_int;
218
        mac_tx_tvalid <= mac_tx_tvalid_int;
219 4 pjf
        mac_tx_tfirst <= mac_tx_tfirst_int;
220 2 pjf
        mac_tx_tlast <= mac_tx_tlast_int;
221
 
222
        mac_rx_tready <= mac_rx_tready_int;
223
 
224
   ------------------------------------------------------------------------------
225
   -- Instantiate the IP layer
226
   ------------------------------------------------------------------------------
227
 
228
    IP_layer : IPv4 PORT MAP
229
                (
230
          ip_tx_start                   => ip_tx_start,
231
          ip_tx                                         => ip_tx,
232
          ip_tx_result                  => ip_tx_result,
233
          ip_tx_data_out_ready=> ip_tx_data_out_ready,
234
          ip_rx_start                   => ip_rx_start,
235
          ip_rx                                         => ip_rx,
236
          rx_clk                                        => rx_clk,
237
          tx_clk                                        => tx_clk,
238
          reset                                         => reset,
239
          our_ip_address                => our_ip_address,
240
          our_mac_address               => our_mac_address,
241
                         rx_pkt_count                   => ip_pkt_count,
242
          arp_req_req                   => arp_req_req_int,
243
          arp_req_rslt                  => arp_req_rslt_int,
244
          mac_tx_req                    => ip_mac_req,
245
          mac_tx_granted                => ip_mac_grant,
246
          mac_data_out_ready    => mac_tx_tready,
247
          mac_data_out_valid    => ip_mac_valid,
248 4 pjf
                         mac_data_out_first     => ip_mac_first,
249 2 pjf
          mac_data_out_last     => ip_mac_last,
250
          mac_data_out                  => ip_mac_data_out,
251
          mac_data_in                   => mac_rx_tdata,
252
          mac_data_in_valid     => mac_rx_tvalid,
253
          mac_data_in_last      => mac_rx_tlast
254
        );
255
 
256
   ------------------------------------------------------------------------------
257
   -- Instantiate the ARP layer
258
   ------------------------------------------------------------------------------
259
        arp_layer : arp
260 8 pjf
                        generic map (
261
                         CLOCK_FREQ                     => CLOCK_FREQ,
262 10 pjf
                         ARP_TIMEOUT            => ARP_TIMEOUT,
263
                         ARP_MAX_PKT_TMO        => ARP_MAX_PKT_TMO,
264
                         MAX_ARP_ENTRIES        => MAX_ARP_ENTRIES
265 8 pjf
                         )
266
                         Port map(
267 2 pjf
                        -- request signals
268
                          arp_req_req                                   => arp_req_req_int,
269
                          arp_req_rslt                                  => arp_req_rslt_int,
270
                          -- rx signals
271
                          data_in_clk                   => rx_clk,
272
                          reset                         => reset,
273
                          data_in                       => mac_rx_tdata,
274
                          data_in_valid                 => mac_rx_tvalid,
275
                          data_in_last                  => mac_rx_tlast,
276
                          -- tx signals
277
                          mac_tx_req                                    => arp_mac_req,
278
                          mac_tx_granted                                => arp_mac_grant,
279
                          data_out_clk                                  => tx_clk,
280
                          data_out_ready                                => mac_tx_tready,
281
                          data_out_valid                                => arp_mac_valid,
282 4 pjf
                          data_out_first                                => arp_mac_first,
283 2 pjf
                          data_out_last                         => arp_mac_last,
284
                          data_out                                              => arp_mac_data_out,
285
                          -- system signals
286
                          our_mac_address                               => our_mac_address,
287
                          our_ip_address                                => our_ip_address,
288 8 pjf
                          control                                               => control.arp_controls,
289 2 pjf
                          req_count                                             => arp_pkt_count
290
                          );
291
 
292
 
293
   ------------------------------------------------------------------------------
294
   -- Instantiate the TX Arbitrator 
295
   ------------------------------------------------------------------------------
296
        mac_tx_arb : tx_arbitrator
297
                 Port map(
298
                                clk                                             => tx_clk,
299
                                reset                           => reset,
300
 
301
                                req_1                                                   => ip_mac_req,
302
                                grant_1                                         => ip_mac_grant,
303
                                data_1                          => ip_mac_data_out,
304
                                valid_1                         => ip_mac_valid,
305 4 pjf
                                first_1                                         => ip_mac_first,
306 2 pjf
                                last_1                                          => ip_mac_last,
307
 
308
                                req_2                                                   => arp_mac_req,
309
                                grant_2                                         => arp_mac_grant,
310
                                data_2                          => arp_mac_data_out,
311
                                valid_2                         => arp_mac_valid,
312 4 pjf
                                first_2                                         => arp_mac_first,
313 2 pjf
                                last_2                                          => arp_mac_last,
314
 
315
                                data                                    => mac_tx_tdata_int,
316
                                valid                                   => mac_tx_tvalid_int,
317 4 pjf
                                first                                   => mac_tx_tfirst_int,
318 2 pjf
                                last                                    => mac_tx_tlast_int
319
                          );
320
 
321
end structural;
322
 
323 10 pjf
 
324
 

powered by: WebSVN 2.1.0

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