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/] [udp_ip/] [1.0/] [vhd/] [udp_arp_data_mux.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : data mux
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : udp_arp_data_mux.vhd
6
-- Author     : Jussi Nieminen  <niemin95@galapagosinkeiju.cs.tut.fi>
7
-- Last update: 2010-08-18
8
-------------------------------------------------------------------------------
9
-- Description: Multiplexer.
10
-------------------------------------------------------------------------------
11
-- Revisions  :
12
-- Date        Version  Author  Description
13
-- 2009/09/15  1.0      niemin95        Created
14
-------------------------------------------------------------------------------
15
 
16
 
17
 
18
 
19
library ieee;
20
use ieee.std_logic_1164.all;
21
use ieee.numeric_std.all;
22
use work.udp_ip_pkg.all;
23
 
24
entity udp_arp_data_mux is
25
 
26
  generic (
27
    data_width_g : integer := 16;
28
    tx_len_w_g   : integer := 11
29
    );
30
 
31
  port (
32
    rx_data_valid_in   : in  std_logic;
33
    new_rx_in          : in  std_logic;
34
    rx_data_in         : in  std_logic_vector( data_width_g-1 downto 0 );
35
    rx_res_in          : in  std_logic_vector( 2 downto 0 );
36
    rx_re_out          : out std_logic;
37
    rx_datas_out       : out std_logic_vector( 3*data_width_g-1 downto 0 );
38
    rx_data_valids_out : out std_logic_vector( 2 downto 0 );
39
    new_rxs_out        : out std_logic_vector( 1 downto 0 );
40
    tx_datas_in        : in  std_logic_vector( 3*data_width_g-1 downto 0 );
41
    tx_data_valids_in  : in  std_logic_vector( 2 downto 0 );
42
    tx_target_MACs_in  : in  std_logic_vector( 2*MAC_addr_w_c-1 downto 0 );
43
    tx_lens_in         : in  std_logic_vector( 2*tx_len_w_g-1 downto 0 );
44
    tx_frame_types_in  : in  std_logic_vector( 2*frame_type_w_c-1 downto 0 );
45
    new_txs_in         : in  std_logic_vector( 1 downto 0 );
46
    tx_re_in           : in  std_logic;
47
    tx_data_out        : out std_logic_vector( data_width_g-1 downto 0 );
48
    tx_data_valid_out  : out std_logic;
49
    tx_target_MAC_out  : out std_logic_vector( MAC_addr_w_c-1 downto 0 );
50
    tx_len_out         : out std_logic_vector( tx_len_w_g-1 downto 0 );
51
    tx_frame_type_out  : out std_logic_vector( frame_type_w_c-1 downto 0 );
52
    new_tx_out         : out std_logic;
53
    tx_res_out         : out std_logic_vector( 2 downto 0 );
54
    input_select_in    : in  std_logic_vector( 1 downto 0 );
55
    output_select_in   : in  std_logic_vector( 1 downto 0 )
56
    );
57
 
58
end udp_arp_data_mux;
59
 
60
 
61
architecture rtl of udp_arp_data_mux is
62
 
63
  signal input_select_int  : integer range 0 to 2;
64
  signal output_select_int : integer range 0 to 2;
65
 
66
  type tx_data_array is array (0 to 2) of std_logic_vector( udp_data_width_c-1 downto 0 );
67
  signal rx_datas_array_r : tx_data_array;
68
  signal tx_datas_array_r : tx_data_array;
69
 
70
  type MAC_array is array (0 to 1) of std_logic_vector( MAC_addr_w_c-1 downto 0 );
71
  signal MAC_addr_array_r : MAC_array;
72
  type frame_type_array is array (0 to 1) of std_logic_vector( frame_type_w_c-1 downto 0 );
73
  signal frame_type_array_r : frame_type_array;
74
  type tx_lens_array is array (0 to 1) of std_logic_vector( tx_len_w_c-1 downto 0 );
75
  signal tx_lens_array_r : tx_lens_array;
76
 
77
  constant udp_selected_c : integer := 0;
78
  constant arp_selected_c : integer := 1;
79
  constant app_selected_c : integer := 2;
80
 
81
-------------------------------------------------------------------------------
82
begin  -- rtl
83
-------------------------------------------------------------------------------
84
 
85
  input_select_int  <= to_integer( unsigned( input_select_in ));
86
  output_select_int <= to_integer( unsigned( output_select_in ));
87
  -- 0: UDP
88
  -- 1: ARP
89
  -- 2: application
90
 
91
 
92
  datas: for n in 0 to 2 generate
93
    rx_datas_out( (n+1)*udp_data_width_c-1 downto n*udp_data_width_c ) <= rx_datas_array_r(n);
94
    tx_datas_array_r(n) <= tx_datas_in( (n+1)*udp_data_width_c-1 downto n*udp_data_width_c );
95
  end generate datas;
96
 
97
  other_arrays: for n in 0 to 1 generate
98
    MAC_addr_array_r(n)   <= tx_target_MACs_in( (n+1)*MAC_addr_w_c-1 downto n*MAC_addr_w_c );
99
    frame_type_array_r(n) <= tx_frame_types_in( (n+1)*frame_type_w_c-1 downto n*frame_type_w_c );
100
    tx_lens_array_r(n)    <= tx_lens_in( (n+1)*tx_len_w_c-1 downto n*tx_len_w_c );
101
  end generate other_arrays;
102
 
103
 
104
 
105
  eth_data_mux : process (rx_data_in, rx_data_valid_in, new_rx_in, input_select_int,
106
                          output_select_int, rx_res_in, tx_datas_array_r, tx_data_valids_in,
107
                          MAC_addr_array_r, tx_lens_array_r, frame_type_array_r, new_txs_in,
108
                          tx_re_in)
109
  begin  -- process eth_data_mux
110
 
111
    -- ** INPUTS **
112
    -- default values. Others than the selected range stay as zero.
113
    rx_datas_array_r   <= (others => (others => '0'));
114
    rx_data_valids_out <= (others => '0');
115
    new_rxs_out        <= (others => '0');
116
 
117
    rx_datas_array_r(input_select_int) <= rx_data_in;
118
    rx_data_valids_out( input_select_int ) <= rx_data_valid_in;
119
 
120
    if input_select_int /= app_selected_c then
121
      new_rxs_out( input_select_int ) <= new_rx_in;
122
    else
123
      -- if data is going to application, also the udp block needs to have the
124
      -- data_valid signal (to know when reading really happens. Plain re from
125
      -- application isn't enough, cause it can be up even if data_valid is down.)
126
      rx_data_valids_out(udp_selected_c) <= rx_data_valid_in;
127
    end if;
128
 
129
 
130
    rx_re_out <= rx_res_in( input_select_int );
131
 
132
    -- ** OUTPUTS **
133
    tx_data_out         <= tx_datas_array_r( output_select_int );
134
    tx_data_valid_out   <= tx_data_valids_in( output_select_int );
135
    -- only data and data_valid can come from application, others come either
136
    -- from arp or udp
137
    if output_select_int /= app_selected_c then
138
      tx_target_MAC_out <= MAC_addr_array_r( output_select_int );
139
      tx_len_out        <= tx_lens_array_r( output_select_int );
140
      tx_frame_type_out <= frame_type_array_r( output_select_int );
141
      new_tx_out        <= new_txs_in( output_select_int );
142
    else
143
      -- if data is coming from the application, these signals have been set by
144
      -- udp block
145
      tx_target_MAC_out <= MAC_addr_array_r( udp_selected_c );
146
      tx_len_out        <= tx_lens_array_r( udp_selected_c );
147
      tx_frame_type_out <= frame_type_array_r( udp_selected_c );
148
      new_tx_out        <= new_txs_in( udp_selected_c );
149
    end if;
150
 
151
    tx_res_out                      <= (others => '0');
152
    tx_res_out( output_select_int ) <= tx_re_in;
153
 
154
  end process eth_data_mux;
155
 
156
end rtl;

powered by: WebSVN 2.1.0

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