Line 139... |
Line 139... |
signal set_tx_start : set_clr_type;
|
signal set_tx_start : set_clr_type;
|
signal set_last : std_logic;
|
signal set_last : std_logic;
|
signal set_tx_started : set_clr_type;
|
signal set_tx_started : set_clr_type;
|
signal set_tx_fin : set_clr_type;
|
signal set_tx_fin : set_clr_type;
|
signal set_udp_rx_start_reg : set_clr_type;
|
signal set_udp_rx_start_reg : set_clr_type;
|
|
signal first_byte_rx : STD_LOGIC_VECTOR(7 downto 0);
|
|
|
begin
|
begin
|
|
|
process (
|
process (
|
our_ip, our_mac, udp_rx_int, udp_tx_start_int, udp_rx_start_int, ip_rx_hdr_int, udp_rx_start_reg,
|
our_ip, our_mac, udp_rx_int, udp_tx_start_int, udp_rx_start_int, ip_rx_hdr_int, udp_rx_start_reg,
|
Line 169... |
Line 170... |
display (7 downto 4) <= ip_pkt_count_int (3 downto 0);
|
display (7 downto 4) <= ip_pkt_count_int (3 downto 0);
|
display (3 downto 0) <= arp_pkt_count_int (3 downto 0);
|
display (3 downto 0) <= arp_pkt_count_int (3 downto 0);
|
|
|
end process;
|
end process;
|
|
|
-- AUTO TX process - on receipt of any UDP pkt, send a response
|
-- AUTO TX process - on receipt of any UDP pkt, send a response,
|
|
|
-- TX response process - COMB
|
-- TX response process - COMB
|
tx_proc_combinatorial: process(
|
tx_proc_combinatorial: process(
|
-- inputs
|
-- inputs
|
udp_rx_start_int, udp_tx_data_out_ready_int, udp_tx_int.data.data_out_valid, PBTX, reset_leds,
|
udp_rx_start_int, udp_tx_data_out_ready_int, udp_tx_int.data.data_out_valid,
|
|
udp_rx_int, PBTX, reset_leds,
|
-- state
|
-- state
|
state, count, tx_hdr, tx_start_reg, tx_started_reg, tx_fin_reg, udp_rx_start_reg,
|
state, count, tx_hdr, tx_start_reg, tx_started_reg, tx_fin_reg, udp_rx_start_reg,
|
-- controls
|
-- controls
|
next_state, set_state, set_count, set_hdr, set_tx_start, set_last,
|
next_state, set_state, set_count, set_hdr, set_tx_start, set_last,
|
set_tx_started, set_tx_fin, set_udp_rx_start_reg
|
set_tx_started, set_tx_fin, set_udp_rx_start_reg, first_byte_rx
|
)
|
)
|
begin
|
begin
|
-- set output_followers
|
-- set output_followers
|
udp_tx_int.hdr <= tx_hdr;
|
udp_tx_int.hdr <= tx_hdr;
|
udp_tx_int.data.data_out_last <= set_last;
|
udp_tx_int.data.data_out_last <= set_last;
|
Line 197... |
Line 199... |
set_tx_start <= HOLD;
|
set_tx_start <= HOLD;
|
set_last <= '0';
|
set_last <= '0';
|
set_tx_started <= HOLD;
|
set_tx_started <= HOLD;
|
set_tx_fin <= HOLD;
|
set_tx_fin <= HOLD;
|
set_udp_rx_start_reg <= HOLD;
|
set_udp_rx_start_reg <= HOLD;
|
|
first_byte_rx <= (others => '0');
|
|
|
-- FSM
|
-- FSM
|
case state is
|
case state is
|
|
|
when IDLE =>
|
when IDLE =>
|
udp_tx_int.data.data_out <= (others => '0');
|
udp_tx_int.data.data_out <= (others => '0');
|
udp_tx_int.data.data_out_valid <= '0';
|
udp_tx_int.data.data_out_valid <= '0';
|
if udp_rx_start_int = '1' or PBTX = '1' then
|
if udp_rx_start_int = '1' or PBTX = '1' then
|
|
if udp_rx_start_int = '1' then
|
|
first_byte_rx <= udp_rx_int.data.data_in;
|
|
else
|
|
first_byte_rx <= x"00";
|
|
end if;
|
set_udp_rx_start_reg <= SET;
|
set_udp_rx_start_reg <= SET;
|
set_tx_started <= SET;
|
set_tx_started <= SET;
|
set_hdr <= '1';
|
set_hdr <= '1';
|
set_tx_start <= SET;
|
set_tx_start <= SET;
|
set_tx_fin <= CLR;
|
set_tx_fin <= CLR;
|
Line 276... |
Line 284... |
when HOLD => count <= count;
|
when HOLD => count <= count;
|
end case;
|
end case;
|
|
|
-- set tx hdr
|
-- set tx hdr
|
if set_hdr = '1' then
|
if set_hdr = '1' then
|
|
-- if the first byte of the rx pkt is 'B' then send to broadcast, otherwise send to reply IP
|
|
if first_byte_rx = x"42" then
|
|
tx_hdr.dst_ip_addr <= IP_BC_ADDR;
|
|
else
|
tx_hdr.dst_ip_addr <= udp_rx_int.hdr.src_ip_addr;
|
tx_hdr.dst_ip_addr <= udp_rx_int.hdr.src_ip_addr;
|
|
end if;
|
tx_hdr.dst_port <= udp_rx_int.hdr.src_port;
|
tx_hdr.dst_port <= udp_rx_int.hdr.src_port;
|
tx_hdr.src_port <= udp_rx_int.hdr.dst_port;
|
tx_hdr.src_port <= udp_rx_int.hdr.dst_port;
|
tx_hdr.data_length <= x"0004";
|
tx_hdr.data_length <= x"0004";
|
tx_hdr.checksum <= x"0000";
|
tx_hdr.checksum <= x"0000";
|
else
|
else
|