Code refactoring
This commit is contained in:
parent
35743b6f19
commit
dcd0b51c83
@ -10,6 +10,8 @@ use work.rtps_config_package.all;
|
|||||||
-- TODO: Initialise RAM to zeroes
|
-- TODO: Initialise RAM to zeroes
|
||||||
-- TODO: Skip Packet while we are waiting for memory operation to complete
|
-- TODO: Skip Packet while we are waiting for memory operation to complete
|
||||||
-- FIXME: ACNACK response does not nack, which is necessary to get the missing SNs.
|
-- FIXME: ACNACK response does not nack, which is necessary to get the missing SNs.
|
||||||
|
-- TODO: Could we overwrite the data (pre-GUIDPrefix) while the memory is using them before the first memory guard? (Add test case)
|
||||||
|
-- TODO: Parse inlineQOS HASH_KEY.
|
||||||
|
|
||||||
entity rtps_builtin_endpoint is
|
entity rtps_builtin_endpoint is
|
||||||
port (
|
port (
|
||||||
@ -125,18 +127,20 @@ architecture arch of rtps_builtin_endpoint is
|
|||||||
-- Address pointing to the beginning of the first Participant Data Frame
|
-- Address pointing to the beginning of the first Participant Data Frame
|
||||||
constant FIRST_PARTICIPANT_ADDRESS : unsigned(BUILTIN_BUFFER_ADDR_WIDTH-1 downto 0) := (others => '0');
|
constant FIRST_PARTICIPANT_ADDRESS : unsigned(BUILTIN_BUFFER_ADDR_WIDTH-1 downto 0) := (others => '0');
|
||||||
-- *UPDATE PARTICIPANT FLAG POSITIONS*
|
-- *UPDATE PARTICIPANT FLAG POSITIONS*
|
||||||
|
-- Width of the Update Participant Flag Signal
|
||||||
|
constant UPDATE_PARTICIPANT_FLAG_WIDTH : natural := 6;
|
||||||
-- Signifies that the main Participant Data are updated
|
-- Signifies that the main Participant Data are updated
|
||||||
constant PARTICIPANT_DATA_FLAG : natural := 0;
|
constant PARTICIPANT_DATA_FLAG : natural := 0;
|
||||||
-- Signifies that the Lease Deadline of the Participant Data is updated
|
-- Signifies that the Lease Deadline of the Participant Data is updated
|
||||||
constant LEASE_DEADLINE_FLAG : natural := 1;
|
constant LEASE_DEADLINE_FLAG : natural := 1;
|
||||||
-- Signifies that the Extra Flags of the Participant Data are updated
|
-- Signifies that the Extra Flags of the Participant Data are updated
|
||||||
constant EXTRA_FLAGS_FLAG : natural := 2;
|
constant EXTRA_FLAGS_FLAG : natural := 2;
|
||||||
-- Signifies that the ACKNACK Timeout Time of the Participant Data is updated
|
-- Signifies that the ACKNACK Timeout Time of the Participant Data is updated
|
||||||
constant ACKNACK_RES_TIME_FLAG : natural := 3;
|
constant ACKNACK_RES_TIME_FLAG : natural := 3;
|
||||||
-- Signifies that the HEARTBEAT Timeout Time of the Participant Data is updated
|
-- Signifies that the HEARTBEAT Timeout Time of the Participant Data is updated
|
||||||
constant HEARTBEAT_RES_TIME_FLAG : natural := 4;
|
constant HEARTBEAT_RES_TIME_FLAG : natural := 4;
|
||||||
-- Signifies that the remote Endpoint (Publisher/Subscriber/Message) Sequence Number of the Participant Data is updated
|
-- Signifies that the remote Endpoint (Publisher/Subscriber/Message) Sequence Number of the Participant Data is updated
|
||||||
constant EDP_SEQ_NR_FLAG : natural := 5;
|
constant EDP_SEQ_NR_FLAG : natural := 5;
|
||||||
-- *EXTRA FLAG POSITIONS*
|
-- *EXTRA FLAG POSITIONS*
|
||||||
-- Signifies that the Publisher Data should be sent
|
-- Signifies that the Publisher Data should be sent
|
||||||
constant PUB_DATA_FLAG : natural := 3;
|
constant PUB_DATA_FLAG : natural := 3;
|
||||||
@ -177,19 +181,19 @@ architecture arch of rtps_builtin_endpoint is
|
|||||||
|
|
||||||
-- Constant for zero Participant Data
|
-- Constant for zero Participant Data
|
||||||
constant ZERO_PARTICIPANT_DATA : PARTICIPANT_DATA_TYPE := (
|
constant ZERO_PARTICIPANT_DATA : PARTICIPANT_DATA_TYPE := (
|
||||||
meta_addr => (others => '0'),
|
meta_addr => IPv4_ADDRESS_INVALID,
|
||||||
def_addr => (others => '0'),
|
def_addr => IPv4_ADDRESS_INVALID,
|
||||||
meta_port => (others => '0'),
|
meta_port => UDP_PORT_INVALID,
|
||||||
def_port => (others => '0'),
|
def_port => UDP_PORT_INVALID,
|
||||||
extra_flags => (others => '0'),
|
extra_flags => (others => '0'),
|
||||||
lease_duration => (others => (others => '0')),
|
lease_duration => DURATION_ZERO,
|
||||||
lease_deadline => (others => (others => '0')),
|
lease_deadline => TIME_INVALID,
|
||||||
heartbeat_res_time => (others => (others => '0')),
|
heartbeat_res_time => TIME_INVALID,
|
||||||
acknack_res_time => (others => (others => '0')),
|
acknack_res_time => TIME_INVALID,
|
||||||
spdp_seq_nr => (others => (others => '0')),
|
spdp_seq_nr => SEQUENCENUMBER_UNKNOWN,
|
||||||
pub_seq_nr => (others => (others => '0')),
|
pub_seq_nr => SEQUENCENUMBER_UNKNOWN,
|
||||||
sub_seq_nr => (others => (others => '0')),
|
sub_seq_nr => SEQUENCENUMBER_UNKNOWN,
|
||||||
mes_seq_nr => (others => (others => '0'))
|
mes_seq_nr => SEQUENCENUMBER_UNKNOWN
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -290,7 +294,7 @@ architecture arch of rtps_builtin_endpoint is
|
|||||||
-- Toggle latching the "last_word_in" signal until reset
|
-- Toggle latching the "last_word_in" signal until reset
|
||||||
signal last_word_in_latch, last_word_in_latch_next : std_logic := '0';
|
signal last_word_in_latch, last_word_in_latch_next : std_logic := '0';
|
||||||
-- Flags signifying which parts of the participant Data stored in memory to update
|
-- Flags signifying which parts of the participant Data stored in memory to update
|
||||||
signal update_participant_flags, update_participant_flags_next : std_logic_vector(5 downto 0) := (others => '0');
|
signal update_participant_flags, update_participant_flags_next : std_logic_vector(UPDATE_PARTICIPANT_FLAG_WIDTH-1 downto 0) := (others => '0');
|
||||||
-- Latch for the Participant Data stored in memory
|
-- Latch for the Participant Data stored in memory
|
||||||
signal mem_participant_data, mem_participant_data_next : PARTICIPANT_DATA_TYPE := ZERO_PARTICIPANT_DATA;
|
signal mem_participant_data, mem_participant_data_next : PARTICIPANT_DATA_TYPE := ZERO_PARTICIPANT_DATA;
|
||||||
-- Signifies if the marked Stale Participant had a Hertbeat Response/Suppression Delay Timeout
|
-- Signifies if the marked Stale Participant had a Hertbeat Response/Suppression Delay Timeout
|
||||||
@ -1369,7 +1373,7 @@ begin
|
|||||||
-- Participant Lease Expired
|
-- Participant Lease Expired
|
||||||
-- NOTE: The mem_participant_data is zero initialized on lease expiration, so we check the default address for zero
|
-- NOTE: The mem_participant_data is zero initialized on lease expiration, so we check the default address for zero
|
||||||
-- (since the default address should always be set)
|
-- (since the default address should always be set)
|
||||||
if (mem_participant_data.def_addr = (mem_participant_data.def_addr'reverse_range => '0')) then
|
if (mem_participant_data.def_addr = IPv4_ADDRESS_INVALID) then
|
||||||
-- Remove Participant
|
-- Remove Participant
|
||||||
mem_opcode <= REMOVE_PARTICIPANT;
|
mem_opcode <= REMOVE_PARTICIPANT;
|
||||||
mem_op_start <= '1';
|
mem_op_start <= '1';
|
||||||
@ -2905,12 +2909,13 @@ begin
|
|||||||
end case;
|
end case;
|
||||||
end if;
|
end if;
|
||||||
when SKIP_PARAMETER =>
|
when SKIP_PARAMETER =>
|
||||||
|
-- Consumed last word of Packet
|
||||||
if (last_word_in_latch = '1' and last_word_in = '0') then
|
if (last_word_in_latch = '1' and last_word_in = '0') then
|
||||||
-- Reset Last Word In Latch
|
-- Reset Last Word In Latch
|
||||||
last_word_in_latch_next <= '0';
|
last_word_in_latch_next <= '0';
|
||||||
-- Continue parsing next Packet
|
-- Continue parsing next Packet
|
||||||
stage_next <= IDLE;
|
stage_next <= IDLE;
|
||||||
-- Reset Lengths
|
-- Reset Parameter End
|
||||||
parameter_end_next <= (others => '1');
|
parameter_end_next <= (others => '1');
|
||||||
-- End of Parameter
|
-- End of Parameter
|
||||||
elsif ((read_cnt & "00" ) >= parameter_end) then
|
elsif ((read_cnt & "00" ) >= parameter_end) then
|
||||||
@ -2933,7 +2938,7 @@ begin
|
|||||||
if (stale_check = '1') then
|
if (stale_check = '1') then
|
||||||
-- DONE
|
-- DONE
|
||||||
stage_next <= IDLE;
|
stage_next <= IDLE;
|
||||||
-- End of Packet
|
-- Consumed last word of Packet
|
||||||
elsif (last_word_in_latch = '1' and last_word_in = '0') then
|
elsif (last_word_in_latch = '1' and last_word_in = '0') then
|
||||||
-- Reset Last Word In Latch
|
-- Reset Last Word In Latch
|
||||||
last_word_in_latch_next <= '0';
|
last_word_in_latch_next <= '0';
|
||||||
@ -2957,12 +2962,12 @@ begin
|
|||||||
-- Force rd_sig low
|
-- Force rd_sig low
|
||||||
rd_sig <= '0';
|
rd_sig <= '0';
|
||||||
-- Notify Endpoints of EOP
|
-- Notify Endpoints of EOP
|
||||||
last_word_out <= '1';
|
last_word_out <= '1'; -- TODO: Necessary? (We do not pass through input to output, so a EOP should not leave as "stranded" during a write out)
|
||||||
-- Continue parsing next Packet
|
-- Continue parsing next Packet
|
||||||
stage_next <= IDLE;
|
stage_next <= IDLE;
|
||||||
-- Reset Last Word In Latch
|
-- Reset Last Word In Latch
|
||||||
last_word_in_latch_next <= '0';
|
last_word_in_latch_next <= '0';
|
||||||
-- Reset Lengths
|
-- Reset Parameter End
|
||||||
parameter_end_next <= (others => '1');
|
parameter_end_next <= (others => '1');
|
||||||
-- Read outside of Parameter Length
|
-- Read outside of Parameter Length
|
||||||
-- NOTE: If the Parameter Length is smaller than expected for a particular parameter, there will be a read from input FIFO while
|
-- NOTE: If the Parameter Length is smaller than expected for a particular parameter, there will be a read from input FIFO while
|
||||||
@ -2975,7 +2980,7 @@ begin
|
|||||||
last_word_out <= '1';
|
last_word_out <= '1';
|
||||||
-- Invalid Parameter Length, Skip Packet
|
-- Invalid Parameter Length, Skip Packet
|
||||||
stage_next <= SKIP_PACKET;
|
stage_next <= SKIP_PACKET;
|
||||||
-- Reset Submessage End
|
-- Reset Parameter End
|
||||||
parameter_end_next <= (others => '1');
|
parameter_end_next <= (others => '1');
|
||||||
-- DEFAULT
|
-- DEFAULT
|
||||||
else
|
else
|
||||||
@ -3128,40 +3133,25 @@ begin
|
|||||||
when 2 =>
|
when 2 =>
|
||||||
-- No Match
|
-- No Match
|
||||||
if (mem_read_data /= guid(1)) then
|
if (mem_read_data /= guid(1)) then
|
||||||
-- Reached End of Memory, No Match
|
-- Continue Search
|
||||||
if (mem_addr_base = max_participant_addr) then
|
mem_addr_next <= tmp;
|
||||||
addr_res_next <= MAX_ADDRESS; --No match
|
mem_addr_base_next <= tmp;
|
||||||
-- DONE
|
mem_cnt_next <= 0;
|
||||||
mem_stage_next <= IDLE;
|
|
||||||
else
|
|
||||||
-- Continue Search
|
|
||||||
mem_addr_next <= tmp;
|
|
||||||
mem_addr_base_next <= tmp;
|
|
||||||
mem_cnt_next <= 0;
|
|
||||||
end if;
|
|
||||||
end if;
|
end if;
|
||||||
-- GUID Prefix 3/3
|
-- GUID Prefix 3/3
|
||||||
when 3 =>
|
when 3 =>
|
||||||
-- No Match
|
-- No Match
|
||||||
if (mem_read_data /= guid(2)) then
|
if (mem_read_data /= guid(2)) then
|
||||||
-- Reached End of Memory, No Match
|
-- Continue Search
|
||||||
if (mem_addr_base = max_participant_addr) then
|
mem_addr_next <= tmp;
|
||||||
addr_res_next <= MAX_ADDRESS; --No match
|
mem_addr_base_next <= tmp;
|
||||||
-- DONE
|
mem_cnt_next <= 0;
|
||||||
mem_stage_next <= IDLE;
|
|
||||||
else
|
|
||||||
-- Continue Search
|
|
||||||
mem_addr_next <= tmp;
|
|
||||||
mem_addr_base_next <= tmp;
|
|
||||||
mem_cnt_next <= 0;
|
|
||||||
end if;
|
|
||||||
-- Match
|
-- Match
|
||||||
else
|
else
|
||||||
-- Fetch Participant Data
|
-- Fetch Participant Data
|
||||||
addr_res_next <= mem_addr_base;
|
addr_res_next <= mem_addr_base;
|
||||||
mem_stage_next <= GET_PARTICIPANT_DATA;
|
mem_stage_next <= GET_PARTICIPANT_DATA;
|
||||||
-- No preload needed
|
mem_cnt_next <= 1; -- No preload needed
|
||||||
mem_cnt_next <= 1;
|
|
||||||
end if;
|
end if;
|
||||||
when others =>
|
when others =>
|
||||||
null;
|
null;
|
||||||
@ -3522,7 +3512,6 @@ begin
|
|||||||
when others =>
|
when others =>
|
||||||
null;
|
null;
|
||||||
end case;
|
end case;
|
||||||
-- TODO: Should I set the addr_res?
|
|
||||||
when FIND_PARTICIPANT_SLOT =>
|
when FIND_PARTICIPANT_SLOT =>
|
||||||
mem_rd <= '1';
|
mem_rd <= '1';
|
||||||
mem_addr_next <= mem_addr + 1;
|
mem_addr_next <= mem_addr + 1;
|
||||||
@ -3573,73 +3562,27 @@ begin
|
|||||||
when 2 =>
|
when 2 =>
|
||||||
-- Slot Occupied
|
-- Slot Occupied
|
||||||
if (mem_read_data /= GUIDPREFIX_UNKNOWN(1)) then
|
if (mem_read_data /= GUIDPREFIX_UNKNOWN(1)) then
|
||||||
if (mem_addr_base = max_participant_addr) then
|
-- Latch last occupied Participant Slot
|
||||||
-- We are in the middle of resetting the MAX Participant Pointer
|
last_addr_next <= mem_addr_base;
|
||||||
if (reset_max_pointer = '1') then
|
-- Continue Search
|
||||||
-- No Change
|
mem_addr_next <= tmp;
|
||||||
mem_stage_next <= IDLE;
|
mem_addr_base_next <= tmp;
|
||||||
-- MEMORY FULL
|
mem_cnt_next <= 0;
|
||||||
elsif (max_participant_addr = MAX_PARTICIPANT_ADDRESS) then
|
|
||||||
report "Memory Full, Ignoring Participant Data" severity NOTE;
|
|
||||||
-- Ignore Insertion
|
|
||||||
mem_stage_next <= IDLE;
|
|
||||||
addr_res_next <= MAX_ADDRESS;
|
|
||||||
else
|
|
||||||
-- Extend Participant Memory Area
|
|
||||||
-- NOTE: "max_participant_addr" points to the first address of last participant frame
|
|
||||||
max_participant_addr_next <= tmp;
|
|
||||||
-- Populate Participant Slot
|
|
||||||
mem_stage_next <= INSERT_PARTICIPANT;
|
|
||||||
mem_addr_next <= tmp;
|
|
||||||
addr_res_next <= tmp;
|
|
||||||
mem_cnt_next <= 0;
|
|
||||||
end if;
|
|
||||||
else
|
|
||||||
-- Latch last occupied Participant Slot
|
|
||||||
last_addr_next <= mem_addr_base;
|
|
||||||
-- Continue Search
|
|
||||||
mem_addr_next <= tmp;
|
|
||||||
mem_addr_base_next <= tmp;
|
|
||||||
mem_cnt_next <= 0;
|
|
||||||
end if;
|
|
||||||
end if;
|
end if;
|
||||||
-- GUID Prefix 3/3
|
-- GUID Prefix 3/3
|
||||||
when 3 =>
|
when 3 =>
|
||||||
-- Slot Occupied
|
-- Slot Occupied
|
||||||
if (mem_read_data /= GUIDPREFIX_UNKNOWN(2)) then
|
if (mem_read_data /= GUIDPREFIX_UNKNOWN(2)) then
|
||||||
if (mem_addr_base = max_participant_addr) then
|
-- Latch last occupied Participant Slot
|
||||||
-- We are in the middle of resetting the MAX Participant Pointer
|
last_addr_next <= mem_addr_base;
|
||||||
if (reset_max_pointer = '1') then
|
-- Continue Search
|
||||||
-- No Change
|
mem_addr_next <= tmp;
|
||||||
mem_stage_next <= IDLE;
|
mem_addr_base_next <= tmp;
|
||||||
-- MEMORY FULL
|
mem_cnt_next <= 0;
|
||||||
elsif (max_participant_addr = MAX_PARTICIPANT_ADDRESS) then
|
|
||||||
report "Memory Full, Ignoring Participant Data" severity NOTE;
|
|
||||||
-- Ignore Insertion
|
|
||||||
mem_stage_next <= IDLE;
|
|
||||||
addr_res_next <= MAX_ADDRESS;
|
|
||||||
else
|
|
||||||
-- Extend Participant Memory Area
|
|
||||||
-- NOTE: "max_participant_addr" points to the first address of last participant frame
|
|
||||||
max_participant_addr_next <= tmp;
|
|
||||||
-- Populate Participant Slot
|
|
||||||
mem_stage_next <= INSERT_PARTICIPANT;
|
|
||||||
mem_addr_next <= tmp;
|
|
||||||
addr_res_next <= tmp;
|
|
||||||
mem_cnt_next <= 0;
|
|
||||||
end if;
|
|
||||||
else
|
|
||||||
-- Latch last occupied Participant Slot
|
|
||||||
last_addr_next <= mem_addr_base;
|
|
||||||
-- Continue Search
|
|
||||||
mem_addr_next <= tmp;
|
|
||||||
mem_addr_base_next <= tmp;
|
|
||||||
mem_cnt_next <= 0;
|
|
||||||
end if;
|
|
||||||
-- Slot Empty
|
-- Slot Empty
|
||||||
else
|
else
|
||||||
if (reset_max_pointer = '1') then
|
if (reset_max_pointer = '1') then
|
||||||
-- Mak sure to iterate through complete participant area
|
-- Make sure to iterate through complete participant area
|
||||||
if (mem_addr_base = max_participant_addr) then
|
if (mem_addr_base = max_participant_addr) then
|
||||||
-- Reset Pointer to last occupied participant Slot
|
-- Reset Pointer to last occupied participant Slot
|
||||||
max_participant_addr_next <= last_addr;
|
max_participant_addr_next <= last_addr;
|
||||||
|
|||||||
@ -7,8 +7,6 @@ use work.rtps_package.all;
|
|||||||
use work.user_config.all;
|
use work.user_config.all;
|
||||||
use work.rtps_config_package.all;
|
use work.rtps_config_package.all;
|
||||||
|
|
||||||
-- Checksum has to be checked before
|
|
||||||
|
|
||||||
entity rtps_handler is
|
entity rtps_handler is
|
||||||
port (
|
port (
|
||||||
clk : in std_logic; -- Input Clock
|
clk : in std_logic; -- Input Clock
|
||||||
@ -857,6 +855,7 @@ begin
|
|||||||
cnt2_next <= 0;
|
cnt2_next <= 0;
|
||||||
|
|
||||||
-- VALIDITY CHECK
|
-- VALIDITY CHECK
|
||||||
|
-- TODO: Shouldn't that check the highest bit?
|
||||||
if (data_in_swapped(0) = '1' or unsigned(data_in_swapped) > 256) then
|
if (data_in_swapped(0) = '1' or unsigned(data_in_swapped) > 256) then
|
||||||
-- If numBits is negative or larger than 256, Number Set is invalid (see DDSI-RTPS 2.3 Section 9.4.2.6)
|
-- If numBits is negative or larger than 256, Number Set is invalid (see DDSI-RTPS 2.3 Section 9.4.2.6)
|
||||||
-- If gapList is invalid, skip Packet (see DDSI-RTPS 2.3 Section 8.3.7.4.3 and 8.3.4.1)
|
-- If gapList is invalid, skip Packet (see DDSI-RTPS 2.3 Section 8.3.7.4.3 and 8.3.4.1)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user