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

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [contrib/] [from_tim/] [udp_ip_stack/] [tags/] [v1.1/] [rtl/] [vhdl/] [IP_complete_nomac.vhd] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 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
-- Revision 0.03 - Added mac_tx_tfirst
19
-- 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
 
29
entity IP_complete_nomac is
30
    Port (
31
                        -- IP Layer signals
32
                        ip_tx_start                             : in std_logic;
33
                        ip_tx                                           : in ipv4_tx_type;                                                              -- IP tx cxns
34
                        ip_tx_result                    : out std_logic_vector (1 downto 0);             -- tx status (changes during transmission)
35
                        ip_tx_data_out_ready    : out std_logic;                                                                        -- indicates IP TX is ready to take data
36
                        ip_rx_start                             : out std_logic;                                                                        -- indicates receipt of ip frame.
37
                        ip_rx                                           : out ipv4_rx_type;
38
                        -- system signals
39
                        rx_clk                                  : in  STD_LOGIC;
40
                        tx_clk                                  : in  STD_LOGIC;
41
                        reset                                   : in  STD_LOGIC;
42
                        our_ip_address          : in STD_LOGIC_VECTOR (31 downto 0);
43
                        our_mac_address                 : in std_logic_vector (47 downto 0);
44
                        -- status signals
45
                        arp_pkt_count                   : out STD_LOGIC_VECTOR(7 downto 0);                      -- count of arp pkts received
46
                        ip_pkt_count                    : out STD_LOGIC_VECTOR(7 downto 0);                      -- number of IP pkts received for us
47
                        -- MAC Transmitter
48
                        mac_tx_tdata         : out  std_logic_vector(7 downto 0);        -- data byte to tx
49
                        mac_tx_tvalid        : out  std_logic;                                                  -- tdata is valid
50
                        mac_tx_tready        : in std_logic;                                                    -- mac is ready to accept data
51
                        mac_tx_tfirst        : out  std_logic;                                                  -- indicates first byte of frame
52
                        mac_tx_tlast         : out  std_logic;                                                  -- indicates last byte of frame
53
                        -- MAC Receiver
54
                        mac_rx_tdata         : in std_logic_vector(7 downto 0);  -- data byte received
55
                        mac_rx_tvalid        : in std_logic;                                                    -- indicates tdata is valid
56
                        mac_rx_tready        : out  std_logic;                                                  -- tells mac that we are ready to take data
57
                        mac_rx_tlast         : in std_logic                                                             -- indicates last byte of the trame
58
                        );
59
end IP_complete_nomac;
60
 
61
architecture structural of IP_complete_nomac is
62
 
63
    COMPONENT IPv4
64
    PORT(
65
                        -- IP Layer signals
66
                        ip_tx_start                             : in std_logic;
67
                        ip_tx                                           : in ipv4_tx_type;                                                              -- IP tx cxns
68
                        ip_tx_result                    : out std_logic_vector (1 downto 0);             -- tx status (changes during transmission)
69
                        ip_tx_data_out_ready    : out std_logic;                                                                        -- indicates IP TX is ready to take data
70
                        ip_rx_start                             : out std_logic;                                                                        -- indicates receipt of ip frame.
71
                        ip_rx                                           : out ipv4_rx_type;
72
                        -- system control signals
73
                        rx_clk                                  : in  STD_LOGIC;
74
                        tx_clk                                  : in  STD_LOGIC;
75
                        reset                                   : in  STD_LOGIC;
76
                        our_ip_address          : in STD_LOGIC_VECTOR (31 downto 0);
77
                        our_mac_address                 : in std_logic_vector (47 downto 0);
78
                        -- system status signals
79
                        rx_pkt_count                    : out STD_LOGIC_VECTOR(7 downto 0);                      -- number of IP pkts received for us
80
                        -- ARP lookup signals
81
                        arp_req_req                             : out arp_req_req_type;
82
                        arp_req_rslt                    : in arp_req_rslt_type;
83
                        -- MAC layer RX signals
84
                        mac_data_in                     : in  STD_LOGIC_VECTOR (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
85
                        mac_data_in_valid       : in  STD_LOGIC;                                                                        -- indicates data_in valid on clock
86
                        mac_data_in_last                : in  STD_LOGIC;                                                                        -- indicates last data in frame
87
                        -- MAC layer TX signals
88
                        mac_tx_req                              : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
89
                        mac_tx_granted                  : in std_logic;                                                                 -- indicates that access to channel has been granted            
90
                        mac_data_out_ready      : in std_logic;                                                                 -- indicates system ready to consume data
91
                        mac_data_out_valid      : out std_logic;                                                                        -- indicates data out is valid
92
                        mac_data_out_first      : out std_logic;                                                                        -- with data out valid indicates the first byte of a frame
93
                        mac_data_out_last               : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
94
                        mac_data_out                    : out std_logic_vector (7 downto 0)                      -- ethernet frame (from dst mac addr through to last byte of frame)      
95
         );
96
         END COMPONENT;
97
 
98
    COMPONENT arp
99
    PORT(
100
                        -- lookup request signals
101
                        arp_req_req                     : in arp_req_req_type;
102
                        arp_req_rslt            : out arp_req_rslt_type;
103
                        -- MAC layer RX signals
104
                        data_in_clk             : in  STD_LOGIC;
105
                        reset                           : in  STD_LOGIC;
106
                        data_in                                 : in  STD_LOGIC_VECTOR (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
107
                        data_in_valid           : in  STD_LOGIC;                                                                        -- indicates data_in valid on clock
108
                        data_in_last            : in  STD_LOGIC;                                                                        -- indicates last data in frame
109
                        -- MAC layer TX signals
110
                        mac_tx_req                      : out std_logic;                                                                        -- indicates that ip wants access to channel (stays up for as long as tx)
111
                        mac_tx_granted          : in std_logic;                                                                 -- indicates that access to channel has been granted            
112
                        data_out_clk            : in std_logic;
113
                        data_out_ready          : in std_logic;                                                                 -- indicates system ready to consume data
114
                        data_out_valid          : out std_logic;                                                                        -- indicates data out is valid
115
                        data_out_first          : out std_logic;                                                                        -- with data out valid indicates the first byte of a frame
116
                        data_out_last           : out std_logic;                                                                        -- with data out valid indicates the last byte of a frame
117
                        data_out                                : out std_logic_vector (7 downto 0);             -- ethernet frame (from dst mac addr through to last byte of frame)
118
                        -- system signals
119
                        our_mac_address         : in STD_LOGIC_VECTOR (47 downto 0);
120
                        our_ip_address  : in STD_LOGIC_VECTOR (31 downto 0);
121
                        req_count                       : out STD_LOGIC_VECTOR(7 downto 0)                       -- count of arp pkts received
122
         );
123
         END COMPONENT;
124
 
125
    COMPONENT tx_arbitrator
126
    PORT(
127
                clk                             : in std_logic;
128
                reset                           : in std_logic;
129
 
130
                req_1                           : in  std_logic;
131
                grant_1                 : out std_logic;
132
      data_1         : in  std_logic_vector(7 downto 0); -- data byte to tx
133
      valid_1        : in  std_logic;                                                   -- tdata is valid
134
      first_1        : in  std_logic;                                                   -- indicates first byte of frame
135
      last_1         : in  std_logic;                                                   -- indicates last byte of frame
136
 
137
                req_2                           : in  std_logic;
138
                grant_2                 : out std_logic;
139
      data_2         : in  std_logic_vector(7 downto 0); -- data byte to tx
140
      valid_2        : in  std_logic;                                                   -- tdata is valid
141
      first_2        : in  std_logic;                                                   -- indicates first byte of frame
142
      last_2         : in  std_logic;                                                   -- indicates last byte of frame
143
 
144
      data              : out  std_logic_vector(7 downto 0);     -- data byte to tx
145
      valid             : out  std_logic;                                                       -- tdata is valid
146
      first             : out  std_logic;                                                       -- indicates first byte of frame
147
      last              : out  std_logic                                                        -- indicates last byte of frame
148
         );
149
         END COMPONENT;
150
 
151
        ---------------------------
152
        -- Signals
153
        ---------------------------
154
 
155
        -- ARP REQUEST
156
        signal arp_req_req_int          : arp_req_req_type;
157
        signal arp_req_rslt_int         : arp_req_rslt_type;
158
        -- MAC arbitration busses
159
        signal ip_mac_req                               : std_logic;
160
        signal ip_mac_grant                     : std_logic;
161
        signal ip_mac_data_out          : std_logic_vector (7 downto 0);
162
        signal ip_mac_valid                     : std_logic;
163
        signal ip_mac_first                     : std_logic;
164
        signal ip_mac_last                      : std_logic;
165
        signal arp_mac_req                      : std_logic;
166
        signal arp_mac_grant                    : std_logic;
167
        signal arp_mac_data_out         : std_logic_vector (7 downto 0);
168
        signal arp_mac_valid                    : std_logic;
169
        signal arp_mac_first                    : std_logic;
170
        signal arp_mac_last                     : std_logic;
171
        -- MAC RX bus
172
        signal mac_rx_tready_int        : std_logic;
173
        -- MAC TX bus
174
        signal mac_tx_tdata_int         : std_logic_vector (7 downto 0);
175
        signal mac_tx_tvalid_int        : std_logic;
176
        signal mac_tx_tfirst_int        : std_logic;
177
        signal mac_tx_tlast_int         : std_logic;
178
        -- control signals
179
        signal mac_tx_granted_int       : std_logic;
180
 
181
begin
182
 
183
        mac_rx_tready_int <= '1';               -- enable the mac receiver
184
 
185
        -- set followers
186
        mac_tx_tdata <= mac_tx_tdata_int;
187
        mac_tx_tvalid <= mac_tx_tvalid_int;
188
        mac_tx_tfirst <= mac_tx_tfirst_int;
189
        mac_tx_tlast <= mac_tx_tlast_int;
190
 
191
        mac_rx_tready <= mac_rx_tready_int;
192
 
193
   ------------------------------------------------------------------------------
194
   -- Instantiate the IP layer
195
   ------------------------------------------------------------------------------
196
 
197
    IP_layer : IPv4 PORT MAP
198
                (
199
          ip_tx_start                   => ip_tx_start,
200
          ip_tx                                         => ip_tx,
201
          ip_tx_result                  => ip_tx_result,
202
          ip_tx_data_out_ready=> ip_tx_data_out_ready,
203
          ip_rx_start                   => ip_rx_start,
204
          ip_rx                                         => ip_rx,
205
          rx_clk                                        => rx_clk,
206
          tx_clk                                        => tx_clk,
207
          reset                                         => reset,
208
          our_ip_address                => our_ip_address,
209
          our_mac_address               => our_mac_address,
210
                         rx_pkt_count                   => ip_pkt_count,
211
          arp_req_req                   => arp_req_req_int,
212
          arp_req_rslt                  => arp_req_rslt_int,
213
          mac_tx_req                    => ip_mac_req,
214
          mac_tx_granted                => ip_mac_grant,
215
          mac_data_out_ready    => mac_tx_tready,
216
          mac_data_out_valid    => ip_mac_valid,
217
                         mac_data_out_first     => ip_mac_first,
218
          mac_data_out_last     => ip_mac_last,
219
          mac_data_out                  => ip_mac_data_out,
220
          mac_data_in                   => mac_rx_tdata,
221
          mac_data_in_valid     => mac_rx_tvalid,
222
          mac_data_in_last      => mac_rx_tlast
223
        );
224
 
225
   ------------------------------------------------------------------------------
226
   -- Instantiate the ARP layer
227
   ------------------------------------------------------------------------------
228
        arp_layer : arp
229
                 Port map(
230
                        -- request signals
231
                          arp_req_req                                   => arp_req_req_int,
232
                          arp_req_rslt                                  => arp_req_rslt_int,
233
                          -- rx signals
234
                          data_in_clk                   => rx_clk,
235
                          reset                         => reset,
236
                          data_in                       => mac_rx_tdata,
237
                          data_in_valid                 => mac_rx_tvalid,
238
                          data_in_last                  => mac_rx_tlast,
239
                          -- tx signals
240
                          mac_tx_req                                    => arp_mac_req,
241
                          mac_tx_granted                                => arp_mac_grant,
242
                          data_out_clk                                  => tx_clk,
243
                          data_out_ready                                => mac_tx_tready,
244
                          data_out_valid                                => arp_mac_valid,
245
                          data_out_first                                => arp_mac_first,
246
                          data_out_last                         => arp_mac_last,
247
                          data_out                                              => arp_mac_data_out,
248
                          -- system signals
249
                          our_mac_address                               => our_mac_address,
250
                          our_ip_address                                => our_ip_address,
251
                          req_count                                             => arp_pkt_count
252
                          );
253
 
254
 
255
   ------------------------------------------------------------------------------
256
   -- Instantiate the TX Arbitrator 
257
   ------------------------------------------------------------------------------
258
        mac_tx_arb : tx_arbitrator
259
                 Port map(
260
                                clk                                             => tx_clk,
261
                                reset                           => reset,
262
 
263
                                req_1                                                   => ip_mac_req,
264
                                grant_1                                         => ip_mac_grant,
265
                                data_1                          => ip_mac_data_out,
266
                                valid_1                         => ip_mac_valid,
267
                                first_1                                         => ip_mac_first,
268
                                last_1                                          => ip_mac_last,
269
 
270
                                req_2                                                   => arp_mac_req,
271
                                grant_2                                         => arp_mac_grant,
272
                                data_2                          => arp_mac_data_out,
273
                                valid_2                         => arp_mac_valid,
274
                                first_2                                         => arp_mac_first,
275
                                last_2                                          => arp_mac_last,
276
 
277
                                data                                    => mac_tx_tdata_int,
278
                                valid                                   => mac_tx_tvalid_int,
279
                                first                                   => mac_tx_tfirst_int,
280
                                last                                    => mac_tx_tlast_int
281
                          );
282
 
283
end structural;
284
 

powered by: WebSVN 2.1.0

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