Line 1... |
Line 1... |
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
-- Company: Carnegie Mellon University, Pittsburgh PA
|
-- Company: Eastern Washington University, Cheney, WA
|
-- Engineer: Justin Wagner
|
-- Engineer: Justin Wagner
|
--
|
--
|
-- Create Date: 7/Oct/2011
|
-- Create Date: 7/Oct/2011
|
-- Design Name:
|
-- Design Name:
|
-- Module Name: arp_responder - rtl
|
-- Module Name: arp_responder - rtl
|
-- Project Name:
|
-- Project Name:
|
-- Target Devices: n/a
|
-- Target Devices: n/a
|
-- Tool versions:
|
-- Tool versions:
|
|
-- Description: Project for Job application to XR Trading
|
--
|
--
|
-- Dependencies: arp_package.vhdl (Definitions of various constants)
|
-- Dependencies: arp_package.vhdl (Definitions of various constants)
|
--
|
--
|
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
library IEEE;
|
library IEEE;
|
Line 45... |
Line 46... |
|
|
--the following declares the various states for the machine
|
--the following declares the various states for the machine
|
type state_type is (IDLE,
|
type state_type is (IDLE,
|
CHECK_DA, CHECK_SA, CHECK_E_TYPE, CHECK_H_TYPE, CHECK_P_TYPE,
|
CHECK_DA, CHECK_SA, CHECK_E_TYPE, CHECK_H_TYPE, CHECK_P_TYPE,
|
CHECK_H_LEN, CHECK_P_LEN, CHECK_OPER, CHECK_SHA, CHECK_SPA,
|
CHECK_H_LEN, CHECK_P_LEN, CHECK_OPER, CHECK_SHA, CHECK_SPA,
|
CHECK_THA, CHECK_TPA,
|
IGNORE_THA, CHECK_TPA,
|
GEN_DA, GEN_SA, GEN_E_TYPE, GEN_H_TYPE, GEN_P_TYPE,
|
GEN_DA, GEN_SA, GEN_E_TYPE, GEN_H_TYPE, GEN_P_TYPE,
|
GEN_H_LEN, GEN_P_LEN, GEN_OPER, GEN_SHA, GEN_SPA,
|
GEN_H_LEN, GEN_P_LEN, GEN_OPER, GEN_SHA, GEN_SPA,
|
GEN_THA, GEN_TPA);
|
GEN_THA, GEN_TPA);
|
|
|
signal SA_mem, next_SA_mem : HA_mem_type;
|
signal SA_mem, next_SA_mem : HA_mem_type;
|
signal SPA_mem, next_SPA_mem : PA_mem_type;
|
signal SPA_mem, next_SPA_mem : PA_mem_type;
|
signal next_state, state : state_type;
|
signal next_state, state : state_type;
|
signal next_counter, counter : std_logic_vector(3 downto 0);
|
signal next_counter, counter : std_logic_vector(3 downto 0);
|
signal posedge_DATA_VALID_RX : std_logic;
|
signal posedge_DATA_VALID_RX : std_logic;
|
signal next_DATA_VALID_TX : std_logic;
|
signal next_DATA_VALID_TX, next_2_DATA_VALID_TX : std_logic;
|
signal next_DATA_TX : std_logic_vector(7 downto 0);
|
signal next_DATA_TX, next_2_DATA_TX : std_logic_vector(7 downto 0);
|
|
|
begin
|
begin
|
|
|
-- A positive edge detector for the DATA_VALID_RX signal
|
-- A positive edge detector for the DATA_VALID_RX signal
|
ed_1: edge_detector
|
ed_1: edge_detector
|
Line 214... |
Line 215... |
-- Lets store the SPA so we can respond to it later
|
-- Lets store the SPA so we can respond to it later
|
next_counter <= counter + 1;
|
next_counter <= counter + 1;
|
next_state <= CHECK_SPA;
|
next_state <= CHECK_SPA;
|
next_SPA_mem(conv_integer(counter)) <= DATA_RX;
|
next_SPA_mem(conv_integer(counter)) <= DATA_RX;
|
if (counter >= 3) then
|
if (counter >= 3) then
|
next_state <= CHECK_THA;
|
next_state <= IGNORE_THA;
|
next_counter <= (others => '0');
|
next_counter <= (others => '0');
|
end if;
|
end if;
|
|
|
when CHECK_THA =>
|
when IGNORE_THA =>
|
-- Make sure we are the destination Hardware Address
|
-- Ignore the destination Hardware Address (ARP requests can't fill this out by definition)
|
|
next_state <= IGNORE_THA;
|
next_counter <= counter + 1;
|
next_counter <= counter + 1;
|
if (DATA_RX = MY_MAC((47-(conv_integer(counter)*8)) downto (40-(conv_integer(counter)*8)))) then
|
|
next_state <= CHECK_THA;
|
|
if (counter >= 5) then
|
if (counter >= 5) then
|
next_state <= CHECK_TPA;
|
next_state <= CHECK_TPA;
|
next_counter <= (others => '0');
|
next_counter <= (others => '0');
|
end if;
|
end if;
|
else
|
|
next_state <= IDLE;
|
|
next_counter <= (others => '0');
|
|
end if;
|
|
|
|
when CHECK_TPA =>
|
when CHECK_TPA =>
|
-- Make sure we are the destination Protocol Address
|
-- Make sure we are the destination Protocol Address
|
next_counter <= counter + 1;
|
next_counter <= counter + 1;
|
if (DATA_RX = MY_IPV4((31-(conv_integer(counter)*8)) downto (24-(conv_integer(counter)*8)))) then
|
if (DATA_RX = MY_IPV4((31-(conv_integer(counter)*8)) downto (24-(conv_integer(counter)*8)))) then
|
Line 416... |
Line 412... |
begin
|
begin
|
|
|
if (ARESET='1') then --resetting the board
|
if (ARESET='1') then --resetting the board
|
DATA_VALID_TX <= '0';
|
DATA_VALID_TX <= '0';
|
DATA_TX <= (others => '0');
|
DATA_TX <= (others => '0');
|
|
next_2_DATA_VALID_TX <= '0';
|
|
next_2_DATA_TX <= (others => '0');
|
-- move next state values into registers on clock edge
|
-- move next state values into registers on clock edge
|
elsif (CLK_TX'event and CLK_TX ='1') then
|
elsif (CLK_TX'event and CLK_TX ='1') then
|
DATA_VALID_TX <= next_DATA_VALID_TX;
|
next_2_DATA_VALID_TX <= next_DATA_VALID_TX;
|
DATA_TX <= next_DATA_TX;
|
next_2_DATA_TX <= next_DATA_TX;
|
|
DATA_VALID_TX <= next_2_DATA_VALID_TX;
|
|
DATA_TX <= next_2_DATA_TX;
|
else
|
else
|
NULL;
|
NULL;
|
end if;
|
end if;
|
|
|
end process seq_TX;
|
end process seq_TX;
|