Line 41... |
Line 41... |
ip_tx_data_out_ready : in std_logic -- indicates IP TX is ready to take data
|
ip_tx_data_out_ready : in std_logic -- indicates IP TX is ready to take data
|
);
|
);
|
end UDP_TX;
|
end UDP_TX;
|
|
|
architecture Behavioral of UDP_TX is
|
architecture Behavioral of UDP_TX is
|
type tx_state_type is (IDLE, SEND_UDP_HDR, SEND_USER_DATA);
|
type tx_state_type is (IDLE, PAUSE, SEND_UDP_HDR, SEND_USER_DATA);
|
|
|
type count_mode_type is (RST, INCR, HOLD);
|
type count_mode_type is (RST, INCR, HOLD);
|
type settable_cnt_type is (RST, SET, INCR, HOLD);
|
type settable_cnt_type is (RST, SET, INCR, HOLD);
|
type set_clr_type is (SET, CLR, HOLD);
|
type set_clr_type is (SET, CLR, HOLD);
|
|
|
Line 108... |
Line 108... |
-- set output followers
|
-- set output followers
|
ip_tx_start <= ip_tx_start_reg;
|
ip_tx_start <= ip_tx_start_reg;
|
ip_tx.hdr.protocol <= x"11"; -- UDP protocol
|
ip_tx.hdr.protocol <= x"11"; -- UDP protocol
|
ip_tx.hdr.data_length <= total_length;
|
ip_tx.hdr.data_length <= total_length;
|
ip_tx.hdr.dst_ip_addr <= udp_txi.hdr.dst_ip_addr;
|
ip_tx.hdr.dst_ip_addr <= udp_txi.hdr.dst_ip_addr;
|
|
if udp_tx_start = '1' and ip_tx_start_reg = '0' then
|
|
udp_tx_result <= UDPTX_RESULT_NONE; -- kill the result until have started the IP layer
|
|
else
|
udp_tx_result <= tx_result_reg;
|
udp_tx_result <= tx_result_reg;
|
|
end if;
|
|
|
case udp_tx_state is
|
case udp_tx_state is
|
when SEND_USER_DATA =>
|
when SEND_USER_DATA =>
|
ip_tx.data.data_out <= udp_txi.data.data_out;
|
ip_tx.data.data_out <= udp_txi.data.data_out;
|
tx_data_valid <= udp_txi.data.data_out_valid;
|
tx_data_valid <= udp_txi.data.data_out_valid;
|
Line 139... |
Line 143... |
set_last <= '0';
|
set_last <= '0';
|
next_tx_result <= UDPTX_RESULT_NONE;
|
next_tx_result <= UDPTX_RESULT_NONE;
|
set_tx_result <= '0';
|
set_tx_result <= '0';
|
set_ip_tx_start <= HOLD;
|
set_ip_tx_start <= HOLD;
|
tx_count_val <= (others => '0');
|
tx_count_val <= (others => '0');
|
|
udp_tx_data_out_ready <= '0';
|
|
|
-- set temp signals
|
-- set temp signals
|
total_length <= std_logic_vector(unsigned(udp_txi.hdr.data_length) + 8); -- total length = user data length + header length (bytes)
|
total_length <= std_logic_vector(unsigned(udp_txi.hdr.data_length) + 8); -- total length = user data length + header length (bytes)
|
|
|
-- TX FSM
|
-- TX FSM
|
Line 159... |
Line 164... |
-- start to send UDP header
|
-- start to send UDP header
|
tx_count_mode <= RST;
|
tx_count_mode <= RST;
|
next_tx_result <= UDPTX_RESULT_SENDING;
|
next_tx_result <= UDPTX_RESULT_SENDING;
|
set_ip_tx_start <= SET;
|
set_ip_tx_start <= SET;
|
set_tx_result <= '1';
|
set_tx_result <= '1';
|
next_tx_state <= SEND_UDP_HDR;
|
next_tx_state <= PAUSE;
|
set_tx_state <= '1';
|
set_tx_state <= '1';
|
end if;
|
end if;
|
end if;
|
end if;
|
|
|
|
when PAUSE =>
|
|
-- delay one clock for IP layer to respond to ip_tx_start and remove any tx error result
|
|
next_tx_state <= SEND_UDP_HDR;
|
|
set_tx_state <= '1';
|
|
|
when SEND_UDP_HDR =>
|
when SEND_UDP_HDR =>
|
udp_tx_data_out_ready <= '0'; -- in this state, we are unable to accept user data for tx
|
udp_tx_data_out_ready <= '0'; -- in this state, we are unable to accept user data for tx
|
if ip_tx_data_out_ready = '1' then
|
if ip_tx_result = IPTX_RESULT_ERR then
|
|
set_ip_tx_start <= CLR;
|
|
next_tx_result <= UDPTX_RESULT_ERR;
|
|
set_tx_result <= '1';
|
|
next_tx_state <= IDLE;
|
|
set_tx_state <= '1';
|
|
elsif ip_tx_data_out_ready = '1' then
|
if tx_count = x"0007" then
|
if tx_count = x"0007" then
|
tx_count_val <= x"0001";
|
tx_count_val <= x"0001";
|
tx_count_mode <= SET;
|
tx_count_mode <= SET;
|
next_tx_state <= SEND_USER_DATA;
|
next_tx_state <= SEND_USER_DATA;
|
set_tx_state <= '1';
|
set_tx_state <= '1';
|