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 23

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

Line No. Rev Author Line
1 18 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 18 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
use work.arp;
29
use work.arpv2;
30
 
31
entity IP_complete_nomac is
32
  generic (
33
    use_arpv2 : boolean := true;        -- use ARP with multipule entries. for signel entry, set
34
                                        -- to false
35
    no_default_gateway : boolean := false;  -- set to false if communicating with devices accessed
36
                                           -- through a "default gateway or router"
37
    CLOCK_FREQ      : integer := 125000000;  -- freq of data_in_clk -- needed to timout cntr
38
    ARP_TIMEOUT     : integer := 60;    -- ARP response timeout (s)
39
    ARP_MAX_PKT_TMO : integer := 5;     -- # wrong nwk pkts received before set error
40
    MAX_ARP_ENTRIES : integer := 255    -- max entries in the ARP store
41
    );
42
  port (
43
    -- IP Layer signals
44
    ip_tx_start          : in  std_logic;
45
    ip_tx                : in  ipv4_tx_type;                  -- IP tx cxns
46
    ip_tx_result         : out std_logic_vector (1 downto 0);  -- tx status (changes during transmission)
47
    ip_tx_data_out_ready : out std_logic;  -- indicates IP TX is ready to take data
48
    ip_rx_start          : out std_logic;  -- indicates receipt of ip frame.
49
    ip_rx                : out ipv4_rx_type;
50
    -- system signals
51
    rx_clk               : in  std_logic;
52
    tx_clk               : in  std_logic;
53
    reset                : in  std_logic;
54
    our_ip_address       : in  std_logic_vector (31 downto 0);
55
    our_mac_address      : in  std_logic_vector (47 downto 0);
56
    control              : in  ip_control_type;
57
    -- status signals
58
    arp_pkt_count        : out std_logic_vector(7 downto 0);  -- count of arp pkts received
59
    ip_pkt_count         : out std_logic_vector(7 downto 0);  -- number of IP pkts received for us
60
    -- MAC Transmitter
61
    mac_tx_tdata         : out std_logic_vector(7 downto 0);  -- data byte to tx
62
    mac_tx_tvalid        : out std_logic;  -- tdata is valid
63
    mac_tx_tready        : in  std_logic;  -- mac is ready to accept data
64
    mac_tx_tfirst        : out std_logic;  -- indicates first byte of frame
65
    mac_tx_tlast         : out std_logic;  -- indicates last byte of frame
66
    -- MAC Receiver
67
    mac_rx_tdata         : in  std_logic_vector(7 downto 0);  -- data byte received
68
    mac_rx_tvalid        : in  std_logic;  -- indicates tdata is valid
69
    mac_rx_tready        : out std_logic;  -- tells mac that we are ready to take data
70
    mac_rx_tlast         : in  std_logic   -- indicates last byte of the trame
71
    );
72
end IP_complete_nomac;
73
 
74
 
75
architecture structural of IP_complete_nomac is
76
 
77
  component IPv4
78
    port(
79
      -- IP Layer signals
80
      ip_tx_start          : in  std_logic;
81
      ip_tx                : in  ipv4_tx_type;                  -- IP tx cxns
82
      ip_tx_result         : out std_logic_vector (1 downto 0);  -- tx status (changes during transmission)
83
      ip_tx_data_out_ready : out std_logic;  -- indicates IP TX is ready to take data
84
      ip_rx_start          : out std_logic;  -- indicates receipt of ip frame.
85
      ip_rx                : out ipv4_rx_type;
86
      -- system control signals
87
      rx_clk               : in  std_logic;
88
      tx_clk               : in  std_logic;
89
      reset                : in  std_logic;
90
      our_ip_address       : in  std_logic_vector (31 downto 0);
91
      our_mac_address      : in  std_logic_vector (47 downto 0);
92
      -- system status signals
93
      rx_pkt_count         : out std_logic_vector(7 downto 0);  -- number of IP pkts received for us
94
      -- ARP lookup signals
95
      arp_req_req          : out arp_req_req_type;
96
      arp_req_rslt         : in  arp_req_rslt_type;
97
      -- MAC layer RX signals
98
      mac_data_in          : in  std_logic_vector (7 downto 0);  -- ethernet frame (from dst mac addr through to last byte of frame)
99
      mac_data_in_valid    : in  std_logic;  -- indicates data_in valid on clock
100
      mac_data_in_last     : in  std_logic;  -- indicates last data in frame
101
      -- MAC layer TX signals
102
      mac_tx_req           : out std_logic;  -- indicates that ip wants access to channel (stays up for as long as tx)
103
      mac_tx_granted       : in  std_logic;  -- indicates that access to channel has been granted            
104
      mac_data_out_ready   : in  std_logic;  -- indicates system ready to consume data
105
      mac_data_out_valid   : out std_logic;  -- indicates data out is valid
106
      mac_data_out_first   : out std_logic;  -- with data out valid indicates the first byte of a frame
107
      mac_data_out_last    : out std_logic;  -- with data out valid indicates the last byte of a frame
108
      mac_data_out         : out std_logic_vector (7 downto 0)  -- ethernet frame (from dst mac addr through to last byte of frame)      
109
      );
110
  end component;
111
 
112
  component arp
113
    generic (
114
      CLOCK_FREQ      : integer := 125000000;  -- freq of data_in_clk -- needed to timout cntr
115
      ARP_TIMEOUT     : integer := 60;  -- ARP response timeout (s)
116
      ARP_MAX_PKT_TMO : integer := 1;  -- (added for compatibility with arpv2. this value not used in this impl)
117
      MAX_ARP_ENTRIES : integer := 1  -- (added for compatibility with arpv2. this value not used in this impl)
118
      );
119
    port (
120
      -- lookup request signals
121
      arp_req_req     : in  arp_req_req_type;
122
      arp_req_rslt    : out arp_req_rslt_type;
123
      -- MAC layer RX signals
124
      data_in_clk     : in  std_logic;
125
      reset           : in  std_logic;
126
      data_in         : in  std_logic_vector (7 downto 0);  -- ethernet frame (from dst mac addr through to last byte of frame)
127
      data_in_valid   : in  std_logic;  -- indicates data_in valid on clock
128
      data_in_last    : in  std_logic;  -- indicates last data in frame
129
      -- MAC layer TX signals
130
      mac_tx_req      : out std_logic;  -- indicates that ip wants access to channel (stays up for as long as tx)
131
      mac_tx_granted  : in  std_logic;  -- indicates that access to channel has been granted            
132
      data_out_clk    : in  std_logic;
133
      data_out_ready  : in  std_logic;  -- indicates system ready to consume data
134
      data_out_valid  : out std_logic;  -- indicates data out is valid
135
      data_out_first  : out std_logic;  -- with data out valid indicates the first byte of a frame
136
      data_out_last   : out std_logic;  -- with data out valid indicates the last byte of a frame
137
      data_out        : out std_logic_vector (7 downto 0);  -- ethernet frame (from dst mac addr through to last byte of frame)
138
      -- system signals
139
      our_mac_address : in  std_logic_vector (47 downto 0);
140
      our_ip_address  : in  std_logic_vector (31 downto 0);
141
      control         : in  arp_control_type;
142
      req_count       : out std_logic_vector(7 downto 0)    -- count of arp pkts received
143
      );
144
  end component;
145
 
146
  component tx_arbitrator
147
    port(
148
      clk   : in std_logic;
149
      reset : in std_logic;
150
 
151
      req_1   : in  std_logic;
152
      grant_1 : out std_logic;
153
      data_1  : in  std_logic_vector(7 downto 0);  -- data byte to tx
154
      valid_1 : in  std_logic;                     -- tdata is valid
155
      first_1 : in  std_logic;                     -- indicates first byte of frame
156
      last_1  : in  std_logic;                     -- indicates last byte of frame
157
 
158
      req_2   : in  std_logic;
159
      grant_2 : out std_logic;
160
      data_2  : in  std_logic_vector(7 downto 0);  -- data byte to tx
161
      valid_2 : in  std_logic;                     -- tdata is valid
162
      first_2 : in  std_logic;                     -- indicates first byte of frame
163
      last_2  : in  std_logic;                     -- indicates last byte of frame
164
 
165
      data  : out std_logic_vector(7 downto 0);  -- data byte to tx
166
      valid : out std_logic;                     -- tdata is valid
167
      first : out std_logic;                     -- indicates first byte of frame
168
      last  : out std_logic                      -- indicates last byte of frame
169
      );
170
  end component;
171
 
172
 
173
  -------------------
174
  -- Configuration
175
  --
176
  -- Enable one of the following to specify which
177
  -- implementation of the ARP layer to use
178
  -------------------
179
 
180
 
181
--      for arp_layer : arp use entity work.arp;                        -- single slot arbitrator
182
--  for arp_layer : arp use entity work.arpv2;  -- multislot arbitrator
183
 
184
 
185
 
186
  ---------------------------
187
  -- Signals
188
  ---------------------------
189
 
190
  -- ARP REQUEST
191
  signal arp_req_req_int    : arp_req_req_type;
192
  signal arp_req_rslt_int   : arp_req_rslt_type;
193
  -- MAC arbitration busses
194
  signal ip_mac_req         : std_logic;
195
  signal ip_mac_grant       : std_logic;
196
  signal ip_mac_data_out    : std_logic_vector (7 downto 0);
197
  signal ip_mac_valid       : std_logic;
198
  signal ip_mac_first       : std_logic;
199
  signal ip_mac_last        : std_logic;
200
  signal arp_mac_req        : std_logic;
201
  signal arp_mac_grant      : std_logic;
202
  signal arp_mac_data_out   : std_logic_vector (7 downto 0);
203
  signal arp_mac_valid      : std_logic;
204
  signal arp_mac_first      : std_logic;
205
  signal arp_mac_last       : std_logic;
206
  -- MAC RX bus
207
  signal mac_rx_tready_int  : std_logic;
208
  -- MAC TX bus
209
  signal mac_tx_tdata_int   : std_logic_vector (7 downto 0);
210
  signal mac_tx_tvalid_int  : std_logic;
211
  signal mac_tx_tfirst_int  : std_logic;
212
  signal mac_tx_tlast_int   : std_logic;
213
  -- control signals
214
  signal mac_tx_granted_int : std_logic;
215
 
216
begin
217
 
218
  mac_rx_tready_int <= '1';             -- enable the mac receiver
219
 
220
  -- set followers
221
  mac_tx_tdata  <= mac_tx_tdata_int;
222
  mac_tx_tvalid <= mac_tx_tvalid_int;
223
  mac_tx_tfirst <= mac_tx_tfirst_int;
224
  mac_tx_tlast  <= mac_tx_tlast_int;
225
 
226
  mac_rx_tready <= mac_rx_tready_int;
227
 
228
  ------------------------------------------------------------------------------
229
  -- Instantiate the IP layer
230
  ------------------------------------------------------------------------------
231
 
232
  IP_layer : IPv4 port map
233
    (
234
      ip_tx_start          => ip_tx_start,
235
      ip_tx                => ip_tx,
236
      ip_tx_result         => ip_tx_result,
237
      ip_tx_data_out_ready => ip_tx_data_out_ready,
238
      ip_rx_start          => ip_rx_start,
239
      ip_rx                => ip_rx,
240
      rx_clk               => rx_clk,
241
      tx_clk               => tx_clk,
242
      reset                => reset,
243
      our_ip_address       => our_ip_address,
244
      our_mac_address      => our_mac_address,
245
      rx_pkt_count         => ip_pkt_count,
246
      arp_req_req          => arp_req_req_int,
247
      arp_req_rslt         => arp_req_rslt_int,
248
      mac_tx_req           => ip_mac_req,
249
      mac_tx_granted       => ip_mac_grant,
250
      mac_data_out_ready   => mac_tx_tready,
251
      mac_data_out_valid   => ip_mac_valid,
252
      mac_data_out_first   => ip_mac_first,
253
      mac_data_out_last    => ip_mac_last,
254
      mac_data_out         => ip_mac_data_out,
255
      mac_data_in          => mac_rx_tdata,
256
      mac_data_in_valid    => mac_rx_tvalid,
257
      mac_data_in_last     => mac_rx_tlast
258
      );
259
 
260
  ------------------------------------------------------------------------------
261
  -- Instantiate the ARP layer
262
  ------------------------------------------------------------------------------
263
  signle_entry_arp: if (not use_arpv2) generate
264
    arp_layer : entity work.arp
265
      generic map (
266
        CLOCK_FREQ      => CLOCK_FREQ,
267
        ARP_TIMEOUT     => ARP_TIMEOUT,
268
        ARP_MAX_PKT_TMO => ARP_MAX_PKT_TMO,
269
        MAX_ARP_ENTRIES => MAX_ARP_ENTRIES
270
        )
271
      port map(
272
        -- request signals
273
        arp_req_req     => arp_req_req_int,
274
        arp_req_rslt    => arp_req_rslt_int,
275
        -- rx signals
276
        data_in_clk     => rx_clk,
277
        reset           => reset,
278
        data_in         => mac_rx_tdata,
279
        data_in_valid   => mac_rx_tvalid,
280
        data_in_last    => mac_rx_tlast,
281
        -- tx signals
282
        mac_tx_req      => arp_mac_req,
283
        mac_tx_granted  => arp_mac_grant,
284
        data_out_clk    => tx_clk,
285
        data_out_ready  => mac_tx_tready,
286
        data_out_valid  => arp_mac_valid,
287
        data_out_first  => arp_mac_first,
288
        data_out_last   => arp_mac_last,
289
        data_out        => arp_mac_data_out,
290
        -- system signals
291
        our_mac_address => our_mac_address,
292
        our_ip_address  => our_ip_address,
293
        control         => control.arp_controls,
294
        req_count       => arp_pkt_count
295
        );
296
  end generate signle_entry_arp;
297
 
298
  multi_entry_arp: if (use_arpv2) generate
299
    arp_layer : entity work.arpv2
300
      generic map (
301
        no_default_gateway => no_default_gateway,
302
        CLOCK_FREQ      => CLOCK_FREQ,
303
        ARP_TIMEOUT     => ARP_TIMEOUT,
304
        ARP_MAX_PKT_TMO => ARP_MAX_PKT_TMO,
305
        MAX_ARP_ENTRIES => MAX_ARP_ENTRIES
306
        )
307
      port map(
308
        -- request signals
309
        arp_req_req     => arp_req_req_int,
310
        arp_req_rslt    => arp_req_rslt_int,
311
        -- rx signals
312
        data_in_clk     => rx_clk,
313
        reset           => reset,
314
        data_in         => mac_rx_tdata,
315
        data_in_valid   => mac_rx_tvalid,
316
        data_in_last    => mac_rx_tlast,
317
        -- tx signals
318
        mac_tx_req      => arp_mac_req,
319
        mac_tx_granted  => arp_mac_grant,
320
        data_out_clk    => tx_clk,
321
        data_out_ready  => mac_tx_tready,
322
        data_out_valid  => arp_mac_valid,
323
        data_out_first  => arp_mac_first,
324
        data_out_last   => arp_mac_last,
325
        data_out        => arp_mac_data_out,
326
        -- system signals
327
        our_mac_address => our_mac_address,
328
        our_ip_address  => our_ip_address,
329
        control         => control.arp_controls,
330
        req_count       => arp_pkt_count
331
        );
332
  end generate multi_entry_arp;
333
 
334
  ------------------------------------------------------------------------------
335
  -- Instantiate the TX Arbitrator 
336
  ------------------------------------------------------------------------------
337
  mac_tx_arb : tx_arbitrator
338
    port map(
339
      clk   => tx_clk,
340
      reset => reset,
341
 
342
      req_1   => ip_mac_req,
343
      grant_1 => ip_mac_grant,
344
      data_1  => ip_mac_data_out,
345
      valid_1 => ip_mac_valid,
346
      first_1 => ip_mac_first,
347
      last_1  => ip_mac_last,
348
 
349
      req_2   => arp_mac_req,
350
      grant_2 => arp_mac_grant,
351
      data_2  => arp_mac_data_out,
352
      valid_2 => arp_mac_valid,
353
      first_2 => arp_mac_first,
354
      last_2  => arp_mac_last,
355
 
356
      data  => mac_tx_tdata_int,
357
      valid => mac_tx_tvalid_int,
358
      first => mac_tx_tfirst_int,
359
      last  => mac_tx_tlast_int
360
      );
361
 
362
end structural;
363
 
364
 
365
 

powered by: WebSVN 2.1.0

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