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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.interface/] [eth_lan91c111_ctrl/] [1.0/] [vhd/] [lan91c111_controller.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : LAN91C111 controller
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : Originally: DM9kA_controller.vhd
6
-- Author     : Antti Alhonen
7
-- Company    : 
8
-- Last update: 2011-11-08
9
-- Platform   : 
10
-------------------------------------------------------------------------------
11
-- Description: Top level
12
-------------------------------------------------------------------------------
13
-- Revisions  :
14
-- Date        Version  Author  Description
15
-- 2009/08/24  1.0      niemin95        Created
16
-------------------------------------------------------------------------------
17
 
18
library ieee;
19
use ieee.std_logic_1164.all;
20
use work.lan91c111_ctrl_pkg.all;
21
 
22
 
23
entity lan91c111_controller is
24
  generic (
25
    enable_tx_g  : std_logic := '1';
26
    enable_rx_g  : std_logic := '1';
27
    interface_width_g : integer := 16   -- 16 or 32.
28
    );
29
 
30
  port (
31
    clk               : in    std_logic;
32
    rst_n             : in    std_logic;
33
 
34
    -- interface to LAN91C111
35
    eth_data_inout    : inout std_logic_vector( lan91_data_width_c-1 downto 0 );
36
    eth_addr_out      : out   std_logic_vector( lan91_addr_width_c-1 downto 0 );
37
    eth_interrupt_in  : in    std_logic;
38
    eth_read_out      : out   std_logic;
39
    eth_write_out     : out   std_logic;
40
    eth_nADS_out      : out   std_logic;
41
    eth_nAEN_out      : out   std_logic;
42
    eth_nBE_out       : out   std_logic_vector(3 downto 0);
43
 
44
    tx_data_in        : in    std_logic_vector( interface_width_g-1 downto 0 );
45
    tx_data_valid_in  : in    std_logic;
46
    tx_re_out         : out   std_logic;
47
    rx_re_in          : in    std_logic;
48
    rx_data_out       : out   std_logic_vector( interface_width_g-1 downto 0 );
49
    rx_data_valid_out : out   std_logic;
50
    target_MAC_in     : in    std_logic_vector( 47 downto 0 );
51
    new_tx_in         : in    std_logic;
52
    tx_len_in         : in    std_logic_vector( tx_len_w_c-1 downto 0 );
53
    tx_frame_type_in  : in    std_logic_vector( 15 downto 0 );
54
    new_rx_out        : out   std_logic;
55
    rx_len_out        : out   std_logic_vector( tx_len_w_c-1 downto 0 );
56
    rx_frame_type_out : out   std_logic_vector( 15 downto 0 );
57
    rx_erroneous_out  : out   std_logic;
58
    ready_out         : out   std_logic;
59
    fatal_error_out   : out   std_logic
60
    );
61
 
62
end lan91c111_controller;
63
 
64
 
65
architecture structural of lan91c111_controller is
66
 
67
  signal register_addrs : std_logic_vector( (submodules_c+1) * real_addr_width_c - 1 downto 0 );
68
  signal config_datas : std_logic_vector( (submodules_c+1) * lan91_data_width_c - 1 downto 0 );
69
  signal config_nBEs : std_logic_vector( (submodules_c+1) * 4 - 1 downto 0);
70
  signal read_not_writes : std_logic_vector( submodules_c downto 0 );
71
  signal configs_valid : std_logic_vector( submodules_c downto 0 );
72
  signal data_to_submodules : std_logic_vector( lan91_data_width_c-1 downto 0 );
73
  signal data_to_sb_valid : std_logic;
74
  signal busy_to_submodules : std_logic;
75
 
76
  signal comm_reqs : std_logic_vector( submodules_c-1 downto 0 );
77
  signal comm_grants : std_logic_vector( submodules_c-1 downto 0 );
78
 
79
  signal init_ready : std_logic;
80
  signal interrupt : std_logic;
81
 
82
  signal tx_data_send_comm : std_logic_vector( lan91_data_width_c-1 downto 0 );
83
  signal tx_data_valid_send_comm : std_logic;
84
  signal tx_re_comm_send : std_logic;
85
 
86
  signal rx_data_comm_read : std_logic_vector( lan91_data_width_c-1 downto 0 );
87
  signal rx_data_valid_comm_read : std_logic;
88
  signal rx_re_read_comm : std_logic;
89
  signal tx_ready_int_send : std_logic;
90
  signal rx_waiting_int_read : std_logic;
91
 
92
  signal rx_data_tmp : std_logic_vector(lan91_data_width_c-1 downto 0);
93
 
94
 
95
-------------------------------------------------------------------------------
96
begin  -- structural
97
-------------------------------------------------------------------------------
98
 
99
  assert enable_rx_g = '1' or enable_tx_g = '1' report "You probably want to enable at least either tx or rx..." severity failure;
100
  assert interface_width_g = 32 or interface_width_g = 16 report "Data interface width has to be 32 or 16" severity failure;
101
 
102
  comm_module: entity work.lan91c111_comm_module
103
    port map (
104
        clk                    => clk,
105
        rst_n                  => rst_n,
106
        comm_requests_in       => comm_reqs,
107
        comm_grants_out        => comm_grants,
108
        interrupt_out          => interrupt,
109
        init_ready_in          => init_ready,
110
        register_addrs_in      => register_addrs,
111
        config_datas_in        => config_datas,
112
        config_nBEs_in         => config_nBEs,
113
        read_not_write_in      => read_not_writes,
114
        configs_valid_in       => configs_valid,
115
        data_to_submodules_out => data_to_submodules,
116
        data_to_sb_valid_out   => data_to_sb_valid,
117
        busy_to_submodules_out => busy_to_submodules,
118
        eth_data_inout         => eth_data_inout,
119
        eth_addr_out           => eth_addr_out,
120
        eth_interrupt_in       => eth_interrupt_in,
121
        eth_read_out           => eth_read_out,
122
        eth_write_out          => eth_write_out,
123
        eth_nADS_out           => eth_nADS_out,
124
        eth_nAEN_out           => eth_nAEN_out,
125
        eth_nBE_out            => eth_nBE_out
126
        );
127
 
128
  init_module: entity work.lan91c111_init_module
129
    generic map (
130
      enable_tx_g => enable_tx_g,
131
      enable_rx_g => enable_rx_g)
132
    port map (
133
        clk                     => clk,
134
        rst_n                   => rst_n,
135
        ready_out               => init_ready,
136
        reg_addr_out            => register_addrs( (submodules_c+1)*real_addr_width_c - 1 downto submodules_c*real_addr_width_c ),
137
        config_data_out         => config_datas( (submodules_c+1)*lan91_data_width_c - 1 downto submodules_c*lan91_data_width_c ),
138
        nBE_out                 => config_nBEs( (submodules_c+1)*4 - 1 downto submodules_c*4 ),
139
        read_not_write_out      => read_not_writes( submodules_c ),
140
        config_valid_out        => configs_valid( submodules_c ),
141
        data_from_comm_in       => data_to_submodules,
142
        data_from_comm_valid_in => data_to_sb_valid,
143
        comm_busy_in            => busy_to_submodules
144
        );
145
 
146
  ready_out <= init_ready;
147
 
148
 
149
  enable_tx: if enable_tx_g = '1' generate
150
 
151
    tx_if_32bit: if interface_width_g = 32 generate
152
      send_module: entity work.lan91c111_send_module
153
        generic map (
154
          mode_16bit_g => 0)
155
        port map (
156
          clk                     => clk,
157
          rst_n                   => rst_n,
158
          tx_completed_in         => tx_ready_int_send,
159
          comm_req_out            => comm_reqs(2),
160
          comm_grant_in           => comm_grants(2),
161
          reg_addr_out            => register_addrs( 3*real_addr_width_c-1 downto 2*real_addr_width_c ),
162
          config_data_out         => config_datas( 3*lan91_data_width_c-1 downto 2*lan91_data_width_c ),
163
          config_nBE_out          => config_nBEs( 3*4-1 downto 2*4 ),
164
          read_not_write_out      => read_not_writes(2),
165
          config_valid_out        => configs_valid(2),
166
          data_from_comm_in       => data_to_submodules,
167
          data_from_comm_valid_in => data_to_sb_valid,
168
          comm_busy_in            => busy_to_submodules,
169
          tx_data_in              => tx_data_in,
170
          tx_data_valid_in        => tx_data_valid_in,
171
          tx_re_out               => tx_re_out,
172
          tx_MAC_addr_in          => target_MAC_in,
173
          new_tx_in               => new_tx_in,
174
          tx_len_in               => tx_len_in,
175
          tx_frame_type_in        => tx_frame_type_in
176
          );
177
    end generate tx_if_32bit;
178
 
179
    tx_if_16bit: if interface_width_g = 16 generate
180
      send_module: entity work.lan91c111_send_module
181
        generic map (
182
          mode_16bit_g => 1)
183
        port map (
184
          clk                     => clk,
185
          rst_n                   => rst_n,
186
          tx_completed_in         => tx_ready_int_send,
187
          comm_req_out            => comm_reqs(2),
188
          comm_grant_in           => comm_grants(2),
189
          reg_addr_out            => register_addrs( 3*real_addr_width_c-1 downto 2*real_addr_width_c ),
190
          config_data_out         => config_datas( 3*lan91_data_width_c-1 downto 2*lan91_data_width_c ),
191
          config_nBE_out          => config_nBEs( 3*4-1 downto 2*4 ),
192
          read_not_write_out      => read_not_writes(2),
193
          config_valid_out        => configs_valid(2),
194
          data_from_comm_in       => data_to_submodules,
195
          data_from_comm_valid_in => data_to_sb_valid,
196
          comm_busy_in            => busy_to_submodules,
197
          tx_data_in              => x"0000" & tx_data_in,
198
          tx_data_valid_in        => tx_data_valid_in,
199
          tx_re_out               => tx_re_out,
200
          tx_MAC_addr_in          => target_MAC_in,
201
          new_tx_in               => new_tx_in,
202
          tx_len_in               => tx_len_in,
203
          tx_frame_type_in        => tx_frame_type_in
204
          );
205
    end generate tx_if_16bit;
206
 
207
 
208
  end generate enable_tx;
209
 
210
  disable_tx: if enable_tx_g = '0' generate
211
    comm_reqs(2) <= '0';
212
  end generate disable_tx;
213
 
214
  int_handler_module: entity work.lan91c111_interrupt_handler
215
    port map (
216
        clk                     => clk,
217
        rst_n                   => rst_n,
218
        interrupt_in            => eth_interrupt_in,
219
        comm_req_out            => comm_reqs(0),
220
        comm_grant_in           => comm_grants(0),
221
        rx_waiting_out          => rx_waiting_int_read,
222
        tx_ready_out            => tx_ready_int_send,
223
        reg_addr_out            => register_addrs( real_addr_width_c-1 downto 0 ),
224
        config_data_out         => config_datas( lan91_data_width_c-1 downto 0 ),
225
        config_nBE_out          => config_nBEs( 3 downto 0 ),
226
        read_not_write_out      => read_not_writes(0),
227
        config_valid_out        => configs_valid(0),
228
        data_from_comm_in       => data_to_submodules,
229
        data_from_comm_valid_in => data_to_sb_valid,
230
        comm_busy_in            => busy_to_submodules
231
        );
232
 
233
  enable_rx: if enable_rx_g = '1' generate
234
 
235
    rx_if_32bit: if interface_width_g = 32 generate
236
      read_module: entity work.lan91c111_read_module
237
        generic map (
238
          mode_16bit_g => 0)
239
        port map (
240
          clk                     => clk,
241
          rst_n                   => rst_n,
242
          rx_waiting_in           => rx_waiting_int_read,
243
          reg_addr_out            => register_addrs( 2*real_addr_width_c-1 downto real_addr_width_c ),
244
          config_data_out         => config_datas( 2*lan91_data_width_c-1 downto lan91_data_width_c ),
245
          nBE_out                 => config_nBEs( 2*4-1 downto 4),
246
          read_not_write_out      => read_not_writes(1),
247
          config_valid_out        => configs_valid(1),
248
          data_from_comm_in       => data_to_submodules,
249
          data_from_comm_valid_in => data_to_sb_valid,
250
          comm_busy_in            => busy_to_submodules,
251
          comm_req_out            => comm_reqs(1),
252
          comm_grant_in           => comm_grants(1),
253
          rx_data_out             => rx_data_out,
254
          rx_data_valid_out       => rx_data_valid_out,
255
          rx_re_in                => rx_re_in,
256
          new_rx_out              => new_rx_out,
257
          rx_len_out              => rx_len_out,
258
          frame_type_out          => rx_frame_type_out,
259
          rx_erroneous_out        => rx_erroneous_out,
260
          fatal_error_out         => fatal_error_out
261
          );
262
    end generate rx_if_32bit;
263
 
264
    rx_if_16bit: if interface_width_g = 16 generate
265
      read_module: entity work.lan91c111_read_module
266
        generic map (
267
          mode_16bit_g => 1)
268
        port map (
269
          clk                     => clk,
270
          rst_n                   => rst_n,
271
          rx_waiting_in           => rx_waiting_int_read,
272
          reg_addr_out            => register_addrs( 2*real_addr_width_c-1 downto real_addr_width_c ),
273
          config_data_out         => config_datas( 2*lan91_data_width_c-1 downto lan91_data_width_c ),
274
          nBE_out                 => config_nBEs( 2*4-1 downto 4),
275
          read_not_write_out      => read_not_writes(1),
276
          config_valid_out        => configs_valid(1),
277
          data_from_comm_in       => data_to_submodules,
278
          data_from_comm_valid_in => data_to_sb_valid,
279
          comm_busy_in            => busy_to_submodules,
280
          comm_req_out            => comm_reqs(1),
281
          comm_grant_in           => comm_grants(1),
282
          rx_data_out             => rx_data_tmp,
283
          rx_data_valid_out       => rx_data_valid_out,
284
          rx_re_in                => rx_re_in,
285
          new_rx_out              => new_rx_out,
286
          rx_len_out              => rx_len_out,
287
          frame_type_out          => rx_frame_type_out,
288
          rx_erroneous_out        => rx_erroneous_out,
289
          fatal_error_out         => fatal_error_out
290
          );
291
          rx_data_out <= rx_data_tmp(15 downto 0);
292
    end generate rx_if_16bit;
293
 
294
  end generate enable_rx;
295
 
296
  disable_rx: if enable_rx_g = '0' generate
297
    comm_reqs(1) <= '0';
298
  end generate disable_rx;
299
 
300
end structural;

powered by: WebSVN 2.1.0

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