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

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [rtl/] [vhdl/] [ml605/] [IP_complete.vhd] - Blame information for rev 29

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

Line No. Rev Author Line
1 2 pjf
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:            Peter Fall
4
-- 
5
-- Create Date:    20:25:56 06/03/2011 
6
-- Design Name: 
7
-- Module Name:    IP_complete - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: Implements complete IP stack with ARP and MAC
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
LIBRARY ieee;
21
USE ieee.std_logic_1164.ALL;
22
use IEEE.NUMERIC_STD.ALL;
23
use work.axi.all;
24
use work.ipv4_types.all;
25
use work.arp_types.all;
26
 
27
entity IP_complete is
28 8 pjf
         generic (
29
                        CLOCK_FREQ                      : integer := 125000000;                                                 -- freq of data_in_clk -- needed to timout cntr
30 10 pjf
                        ARP_TIMEOUT                     : integer := 60;                                                                        -- ARP response timeout (s)
31
                        ARP_MAX_PKT_TMO : integer := 5;                                                                 -- # wrong nwk pkts received before set error
32
                        MAX_ARP_ENTRIES         : integer := 255                                                                        -- max entries in the ARP store
33 8 pjf
                        );
34 2 pjf
    Port (
35
                        -- IP Layer signals
36
                        ip_tx_start                             : in std_logic;
37
                        ip_tx                                           : in ipv4_tx_type;                                                              -- IP tx cxns
38
                        ip_tx_result                    : out std_logic_vector (1 downto 0);             -- tx status (changes during transmission)
39
                        ip_tx_data_out_ready    : out std_logic;                                                                        -- indicates IP TX is ready to take data
40
                        ip_rx_start                             : out std_logic;                                                                        -- indicates receipt of ip frame.
41
                        ip_rx                                           : out ipv4_rx_type;
42
                        -- system signals
43
                        clk_in_p             : in  std_logic;                                           -- 200MHz clock input from board
44
                        clk_in_n             : in  std_logic;
45
                        clk_out                                 : out std_logic;
46
                        reset                                   : in  STD_LOGIC;
47
                        our_ip_address          : in STD_LOGIC_VECTOR (31 downto 0);
48
                        our_mac_address                 : in std_logic_vector (47 downto 0);
49 8 pjf
                        control                                 : in ip_control_type;
50 2 pjf
                        -- status signals
51
                        arp_pkt_count                   : out STD_LOGIC_VECTOR(7 downto 0);                      -- count of arp pkts received
52
                        ip_pkt_count                    : out STD_LOGIC_VECTOR(7 downto 0);                      -- number of IP pkts received for us
53
                        -- GMII Interface
54
                        phy_resetn           : out std_logic;
55
                        gmii_txd             : out std_logic_vector(7 downto 0);
56
                        gmii_tx_en           : out std_logic;
57
                        gmii_tx_er           : out std_logic;
58
                        gmii_tx_clk          : out std_logic;
59
                        gmii_rxd             : in  std_logic_vector(7 downto 0);
60
                        gmii_rx_dv           : in  std_logic;
61
                        gmii_rx_er           : in  std_logic;
62
                        gmii_rx_clk          : in  std_logic;
63
                        gmii_col             : in  std_logic;
64
                        gmii_crs             : in  std_logic;
65
                        mii_tx_clk           : in  std_logic
66
                        );
67
end IP_complete;
68
 
69
architecture structural of IP_complete is
70
 
71
  ------------------------------------------------------------------------------
72
  -- Component Declaration for the IP layer
73
  ------------------------------------------------------------------------------
74
 
75
    COMPONENT IP_complete_nomac
76 8 pjf
         generic (
77
                        CLOCK_FREQ                      : integer := 125000000;                                                 -- freq of data_in_clk -- needed to timout cntr
78 10 pjf
                        ARP_TIMEOUT                     : integer := 60;                                                                        -- ARP response timeout (s)
79
                        ARP_MAX_PKT_TMO : integer := 5;                                                                 -- # wrong nwk pkts received before set error
80
                        MAX_ARP_ENTRIES         : integer := 255                                                                        -- max entries in the ARP store
81 8 pjf
                        );
82
    Port (
83 2 pjf
                        -- IP Layer signals
84
                        ip_tx_start                             : in std_logic;
85
                        ip_tx                                           : in ipv4_tx_type;                                                              -- IP tx cxns
86
                        ip_tx_result                    : out std_logic_vector (1 downto 0);             -- tx status (changes during transmission)
87
                        ip_tx_data_out_ready    : out std_logic;                                                                        -- indicates IP TX is ready to take data
88
                        ip_rx_start                             : out std_logic;                                                                        -- indicates receipt of ip frame.
89
                        ip_rx                                           : out ipv4_rx_type;
90
                        -- system signals
91 4 pjf
                        rx_clk                                  : in  STD_LOGIC;
92
                        tx_clk                                  : in  STD_LOGIC;
93 2 pjf
                        reset                                   : in  STD_LOGIC;
94
                        our_ip_address          : in STD_LOGIC_VECTOR (31 downto 0);
95
                        our_mac_address                 : in std_logic_vector (47 downto 0);
96 8 pjf
                        control                                 : in ip_control_type;
97 2 pjf
                        -- status signals
98
                        arp_pkt_count                   : out STD_LOGIC_VECTOR(7 downto 0);                      -- count of arp pkts received
99
                        ip_pkt_count                    : out STD_LOGIC_VECTOR(7 downto 0);                      -- number of IP pkts received for us
100
                        -- MAC Transmitter
101
                        mac_tx_tdata         : out  std_logic_vector(7 downto 0);        -- data byte to tx
102
                        mac_tx_tvalid        : out  std_logic;                                                  -- tdata is valid
103
                        mac_tx_tready        : in std_logic;                                                    -- mac is ready to accept data
104 4 pjf
                        mac_tx_tfirst        : out  std_logic;                                                  -- indicates first byte of frame
105 2 pjf
                        mac_tx_tlast         : out  std_logic;                                                  -- indicates last byte of frame
106
                        -- MAC Receiver
107
                        mac_rx_tdata         : in std_logic_vector(7 downto 0);  -- data byte received
108
                        mac_rx_tvalid        : in std_logic;                                                    -- indicates tdata is valid
109
                        mac_rx_tready        : out  std_logic;                                                  -- tells mac that we are ready to take data
110 4 pjf
                        mac_rx_tlast         : in std_logic                                                             -- indicates last byte of the trame
111 8 pjf
                        );
112 2 pjf
    END COMPONENT;
113
 
114
 
115
  ------------------------------------------------------------------------------
116
  -- Component Declaration for the MAC layer
117
  ------------------------------------------------------------------------------
118 10 pjf
component mac_layer_v2_1
119 2 pjf
         port (
120
                        -- System controls
121
                        ------------------
122
                        glbl_rst                      : in  std_logic;                                  -- asynchronous reset
123
                        mac_reset                       : in  std_logic;                                                        -- reset mac layer
124
                        clk_in_p                                : in  std_logic;                                        -- 200MHz clock input from board
125
                        clk_in_n                                : in  std_logic;
126
 
127
                        -- MAC Transmitter (AXI-S) Interface
128
                        ---------------------------------------------
129
                        mac_tx_clock                            : out  std_logic;                                                       -- data sampled on rising edge
130
                        mac_tx_tdata                            : in  std_logic_vector(7 downto 0);      -- data byte to tx
131
                        mac_tx_tvalid                           : in  std_logic;                                                        -- tdata is valid
132
                        mac_tx_tready                           : out std_logic;                                                        -- mac is ready to accept data
133
                        mac_tx_tlast                            : in  std_logic;                                                        -- indicates last byte of frame
134
 
135
                        -- MAC Receiver (AXI-S) Interface
136
                        ------------------------------------------
137
                        mac_rx_clock                            : out  std_logic;                                                       -- data valid on rising edge
138
                        mac_rx_tdata                            : out std_logic_vector(7 downto 0);      -- data byte received
139
                        mac_rx_tvalid                           : out std_logic;                                                        -- indicates tdata is valid
140
                        mac_rx_tready                           : in  std_logic;                                                        -- tells mac that we are ready to take data
141
                        mac_rx_tlast                            : out std_logic;                                                        -- indicates last byte of the trame
142
 
143
                        -- GMII Interface
144
                        -----------------     
145
                        phy_resetn                              : out std_logic;
146
                        gmii_txd                      : out std_logic_vector(7 downto 0);
147
                        gmii_tx_en                    : out std_logic;
148
                        gmii_tx_er                    : out std_logic;
149
                        gmii_tx_clk                   : out std_logic;
150
                        gmii_rxd                      : in  std_logic_vector(7 downto 0);
151
                        gmii_rx_dv                    : in  std_logic;
152
                        gmii_rx_er                    : in  std_logic;
153
                        gmii_rx_clk                   : in  std_logic;
154
                        gmii_col                      : in  std_logic;
155
                        gmii_crs                      : in  std_logic;
156
                        mii_tx_clk                    : in  std_logic
157
         );
158
end component;
159
 
160
        ---------------------------
161
        -- Signals
162
        ---------------------------
163
 
164
        -- MAC RX bus
165
        signal mac_rx_clock                     : std_logic;
166
        signal mac_rx_tdata                     : std_logic_vector (7 downto 0);
167
        signal mac_rx_tvalid                    : std_logic;
168
        signal mac_rx_tready                    : std_logic;
169
        signal mac_rx_tlast                     : std_logic;
170
        -- MAC TX bus
171
        signal mac_tx_clock                     : std_logic;
172
        signal mac_tx_tdata                     : std_logic_vector (7 downto 0);
173
        signal mac_tx_tvalid                    : std_logic;
174
        signal mac_tx_tready                    : std_logic;
175
        signal mac_tx_tlast                     : std_logic;
176
        -- control signals
177
        signal mac_tx_tready_int        : std_logic;
178
        signal mac_tx_granted_int       : std_logic;
179
 
180
begin
181
 
182
        clk_out <= mac_rx_clock;
183
 
184
   ------------------------------------------------------------------------------
185
   -- Instantiate the IP layer
186
   ------------------------------------------------------------------------------
187
 
188 8 pjf
    IP_layer : IP_complete_nomac
189
                generic map (
190
                         CLOCK_FREQ                     => CLOCK_FREQ,
191 10 pjf
                         ARP_TIMEOUT            => ARP_TIMEOUT,
192
                         ARP_MAX_PKT_TMO        => ARP_MAX_PKT_TMO,
193
                         MAX_ARP_ENTRIES        => MAX_ARP_ENTRIES
194
                )
195 8 pjf
                PORT MAP (
196 2 pjf
                         -- IP Layer signals
197
          ip_tx_start                   => ip_tx_start,
198
          ip_tx                                         => ip_tx,
199
          ip_tx_result                  => ip_tx_result,
200
          ip_tx_data_out_ready => ip_tx_data_out_ready,
201
          ip_rx_start                   => ip_rx_start,
202
          ip_rx                                         => ip_rx,
203
                         -- system signals
204 4 pjf
          rx_clk                                        => mac_rx_clock,
205
          tx_clk                                        => mac_rx_clock,
206 2 pjf
          reset                                         => reset,
207
          our_ip_address                => our_ip_address,
208
          our_mac_address               => our_mac_address,
209 8 pjf
                         control                                        => control,
210 2 pjf
                         -- status signals
211
          arp_pkt_count                 => arp_pkt_count,
212
                         ip_pkt_count                   => ip_pkt_count,
213
                         -- MAC Transmitter
214
          mac_tx_tready                 => mac_tx_tready_int,
215
          mac_tx_tvalid                 => mac_tx_tvalid,
216 4 pjf
                         mac_tx_tfirst                  => open,
217 2 pjf
          mac_tx_tlast                  => mac_tx_tlast,
218
          mac_tx_tdata                  => mac_tx_tdata,
219
                    -- MAC Receiver
220
          mac_rx_tdata                  => mac_rx_tdata,
221
          mac_rx_tvalid                 => mac_rx_tvalid,
222
                         mac_rx_tready                  => mac_rx_tready,
223
          mac_rx_tlast                  => mac_rx_tlast
224
        );
225
 
226
 
227
   ------------------------------------------------------------------------------
228
   -- Instantiate the MAC layer
229
   ------------------------------------------------------------------------------
230 10 pjf
        mac_block : mac_layer_v2_1
231 2 pjf
                 Port map(
232
                                -- System controls
233
                                ------------------
234
                                glbl_rst                                => reset,
235
                                mac_reset         => '0',
236
                                clk_in_p          => clk_in_p,
237
                                clk_in_n          => clk_in_n,
238
 
239
                                -- MAC Transmitter (AXI-S) Interface
240
                                ---------------------------------------------
241
                                mac_tx_clock      => mac_tx_clock,
242
                                mac_tx_tdata      => mac_tx_tdata,
243
                                mac_tx_tvalid     => mac_tx_tvalid,
244
                                mac_tx_tready     => mac_tx_tready_int,
245
                                mac_tx_tlast      => mac_tx_tlast,
246
 
247
                                -- MAC Receiver (AXI-S) Interface
248
                                ------------------------------------------
249
                                mac_rx_clock      => mac_rx_clock,
250
                                mac_rx_tdata      => mac_rx_tdata,
251
                                mac_rx_tvalid     => mac_rx_tvalid,
252
                                mac_rx_tready     => mac_rx_tready,
253
                                mac_rx_tlast      => mac_rx_tlast,
254
 
255
                                -- GMII Interface
256
                                -----------------     
257
                                phy_resetn        => phy_resetn,
258
                                gmii_txd                => gmii_txd,
259
                                gmii_tx_en        => gmii_tx_en,
260
                                gmii_tx_er        => gmii_tx_er,
261
                                gmii_tx_clk       => gmii_tx_clk,
262
                                gmii_rxd                => gmii_rxd,
263
                                gmii_rx_dv        => gmii_rx_dv,
264
                                gmii_rx_er        => gmii_rx_er,
265
                                gmii_rx_clk       => gmii_rx_clk,
266
                                gmii_col        => gmii_col,
267
                                gmii_crs                => gmii_crs,
268
                                mii_tx_clk        => mii_tx_clk
269
                          );
270
 
271
end structural;
272
 

powered by: WebSVN 2.1.0

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