From 0ae131189bef9f5f426447bf948d9926bbb5d21c Mon Sep 17 00:00:00 2001 From: Greek Date: Wed, 2 Dec 2020 20:04:01 +0100 Subject: [PATCH] * partly revert commit ec4d44c - Re-add max_participant_addr to prevent iterating through the whole memory area unnecessarily - Pointer points to last occuoied participant frame --- src/Tests/testbench.pro | 4 +- src/rtps_builtin_endpoint.vhd | 147 +++++++++++++++++++++++++++------- 2 files changed, 121 insertions(+), 30 deletions(-) diff --git a/src/Tests/testbench.pro b/src/Tests/testbench.pro index 408b48f..b3a7238 100644 --- a/src/Tests/testbench.pro +++ b/src/Tests/testbench.pro @@ -25,9 +25,9 @@ analyze Level_0/rtps_out_test1.vhd #simulate rtps_handler_test1 #simulate rtps_handler_test2 -simulate rtps_builtin_endpoint_test1 +#simulate rtps_builtin_endpoint_test1 #simulate rtps_builtin_endpoint_test2 #simulate rtps_builtin_endpoint_test3 #simulate rtps_builtin_endpoint_test4 -#simulate rtps_builtin_endpoint_test5 +simulate rtps_builtin_endpoint_test5 #simulate rtps_out_test1 \ No newline at end of file diff --git a/src/rtps_builtin_endpoint.vhd b/src/rtps_builtin_endpoint.vhd index f9e447e..52f1b5c 100644 --- a/src/rtps_builtin_endpoint.vhd +++ b/src/rtps_builtin_endpoint.vhd @@ -264,6 +264,10 @@ architecture arch of rtps_builtin_endpoint is signal mem_addr_base, mem_addr_base_next : unsigned(BUILTIN_BUFFER_ADDR_WIDTH-1 downto 0) := (others => '0'); -- Result Base Memory Address of Memory Operation signal addr_res, addr_res_next : unsigned(BUILTIN_BUFFER_ADDR_WIDTH-1 downto 0) := (others => '0'); + -- Help signal used to reset the MAX Participant/Endpoint Memory Pointers + signal last_addr, last_addr_next : unsigned(BUILTIN_BUFFER_ADDR_WIDTH-1 downto 0) := (others => '0'); + -- Highest Participant Memory Address (Points to first Word of last occupied Participant Frame) + signal max_participant_addr, max_participant_addr_next : unsigned(BUILTIN_BUFFER_ADDR_WIDTH-1 downto 0) := (others => '0'); -- Memory Data Read and Write Signals signal mem_read_data, mem_write_data : std_logic_vector(WORD_WIDTH-1 downto 0) := (others => '0'); -- Memory Read and Write Enable Signals @@ -280,6 +284,8 @@ architecture arch of rtps_builtin_endpoint is signal last_seq_nr, last_seq_nr_next : SEQUENCENUMBER_TYPE := (others => (others => '0')); -- Intermediate write enable signal. signal wr_sig : std_logic := '0'; + -- Signifies if we currently are resetting the MAX Participant/Endpoint Pointer + signal reset_max_pointer, reset_max_pointer_next : std_logic := '0'; -- Signifies if we currently are doing a Participant Stale Entry Check (Used to start Stale Checks between packet handling) signal stale_check, stale_check_next : std_logic := '0'; -- Latch containing the GUID Prefix of the removed Participant from the memory, and the Enity ID of the last Orphan Endpoint found @@ -3038,9 +3044,12 @@ begin mem_addr_next <= mem_addr; addr_res_next <= addr_res; mem_cnt_next <= mem_cnt; + last_addr_next <= last_addr; mem_participant_data_next <= mem_participant_data; is_heartbeat_res_next <= is_heartbeat_res; mem_guidprefix_next <= mem_guidprefix; + max_participant_addr_next <= max_participant_addr; + reset_max_pointer_next <= reset_max_pointer; -- DEFAULT Unregistered mem_write_data <= (others => '0'); mem_op_done <= '0'; @@ -3051,6 +3060,7 @@ begin case (mem_stage) is when IDLE => mem_op_done <= '1'; + reset_max_pointer_next <= '0'; if (mem_op_start = '1') then case(mem_opcode) is @@ -3133,7 +3143,7 @@ begin -- No Match if (mem_read_data /= guid(0)) then -- Reached End of Memory, No Match - if (mem_addr_base = MAX_PARTICIPANT_ADDRESS) then + if (mem_addr_base = max_participant_addr) then addr_res_next <= MAX_ADDRESS; --No match -- DONE mem_stage_next <= IDLE; @@ -3149,7 +3159,7 @@ begin -- No Match if (mem_read_data /= guid(1)) then -- Reached End of Memory, No Match - if (mem_addr_base = MAX_PARTICIPANT_ADDRESS) then + if (mem_addr_base = max_participant_addr) then addr_res_next <= MAX_ADDRESS; --No match -- DONE mem_stage_next <= IDLE; @@ -3165,7 +3175,7 @@ begin -- No Match if (mem_read_data /= guid(2)) then -- Reached End of Memory, No Match - if (mem_addr_base = MAX_PARTICIPANT_ADDRESS) then + if (mem_addr_base = max_participant_addr) then addr_res_next <= MAX_ADDRESS; --No match -- DONE mem_stage_next <= IDLE; @@ -3532,12 +3542,17 @@ begin when 6 => mem_wr <= '1'; mem_write_data <= GUIDPREFIX_UNKNOWN(2); - - -- DONE - mem_stage_next <= IDLE; + -- Reset MAX Participant Pointer + mem_addr_base_next <= FIRST_PARTICIPANT_ADDRESS; + mem_addr_next <= FIRST_PARTICIPANT_ADDRESS; + reset_max_pointer_next <= '1'; + last_addr_next <= (others => '0'); + mem_stage_next <= FIND_PARTICIPANT_SLOT; + mem_cnt_next <= 0; when others => null; end case; + -- TODO: Should I set the addr_res? when FIND_PARTICIPANT_SLOT => mem_rd <= '1'; mem_addr_next <= mem_addr + 1; @@ -3554,12 +3569,30 @@ begin when 1 => -- Slot Occupied if (mem_read_data /= GUIDPREFIX_UNKNOWN(0)) then - if (mem_addr_base = MAX_PARTICIPANT_ADDRESS) then - report "Memory Full, ignoring Participant Data" severity WARNING; - addr_res_next <= MAX_ADDRESS; --No match - -- DONE - mem_stage_next <= IDLE; + if (mem_addr_base = max_participant_addr) then + -- We are in the middle of resetting the MAX Participant Pointer + if (reset_max_pointer = '1') then + -- No Change + mem_stage_next <= IDLE; + -- MEMORY FULL + 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; @@ -3570,12 +3603,30 @@ begin when 2 => -- Slot Occupied if (mem_read_data /= GUIDPREFIX_UNKNOWN(1)) then - if (mem_addr_base = MAX_PARTICIPANT_ADDRESS) then - report "Memory Full, ignoring Participant Data" severity WARNING; - addr_res_next <= MAX_ADDRESS; --No match - -- DONE - mem_stage_next <= IDLE; + if (mem_addr_base = max_participant_addr) then + -- We are in the middle of resetting the MAX Participant Pointer + if (reset_max_pointer = '1') then + -- No Change + mem_stage_next <= IDLE; + -- MEMORY FULL + 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; @@ -3586,12 +3637,30 @@ begin when 3 => -- Slot Occupied if (mem_read_data /= GUIDPREFIX_UNKNOWN(2)) then - if (mem_addr_base = MAX_PARTICIPANT_ADDRESS) then - report "Memory Full, ignoring Participant Data" severity WARNING; - addr_res_next <= MAX_ADDRESS; --No match - -- DONE - mem_stage_next <= IDLE; + if (mem_addr_base = max_participant_addr) then + -- We are in the middle of resetting the MAX Participant Pointer + if (reset_max_pointer = '1') then + -- No Change + mem_stage_next <= IDLE; + -- MEMORY FULL + 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; @@ -3599,10 +3668,26 @@ begin end if; -- Slot Empty else - -- Populate Participant Slot - mem_stage_next <= INSERT_PARTICIPANT; - mem_addr_next <= mem_addr_base; - mem_cnt_next <= 0; + if (reset_max_pointer = '1') then + -- Mak sure to iterate through complete participant area + if (mem_addr_base = max_participant_addr) then + -- Reset Pointer to last occupied participant Slot + max_participant_addr_next <= last_addr; + -- DONE + mem_stage_next <= IDLE; + else + -- Continue Search + mem_addr_next <= tmp; + mem_addr_base_next <= tmp; + mem_cnt_next <= 0; + end if; + else + -- Populate Participant Slot + mem_stage_next <= INSERT_PARTICIPANT; + mem_addr_next <= mem_addr_base; + addr_res_next <= mem_addr_base; + mem_cnt_next <= 0; + end if; end if; when others => null; @@ -3651,7 +3736,7 @@ begin -- Slot Empty else -- Reached End of Memory, No Match - if (mem_addr_base = MAX_PARTICIPANT_ADDRESS) then + if (mem_addr_base = max_participant_addr) then addr_res_next <= MAX_ADDRESS; --No match -- DONE mem_stage_next <= IDLE; @@ -3707,7 +3792,7 @@ begin -- Slot Empty else -- Reached End of Memory, No Match - if (mem_addr_base = MAX_PARTICIPANT_ADDRESS) then + if (mem_addr_base = max_participant_addr) then addr_res_next <= MAX_ADDRESS; --No match -- DONE mem_stage_next <= IDLE; @@ -3794,7 +3879,7 @@ begin -- Participant not Stale else -- Reached End of Memory, No Match - if (mem_addr_base = MAX_PARTICIPANT_ADDRESS) then + if (mem_addr_base = max_participant_addr) then addr_res_next <= MAX_ADDRESS; --No match -- DONE mem_stage_next <= IDLE; @@ -3857,8 +3942,10 @@ begin mem_addr_base <= (others => '0'); mem_addr <= (others => '0'); addr_res <= (others => '0'); + last_addr <= (others => '0'); long_latch <= (others => '0'); rcvd <= (others => '0'); + max_participant_addr <= FIRST_PARTICIPANT_ADDRESS; guid <= (others => (others => '0')); mem_guidprefix <= (others => (others => '0')); lease_duration <= (others => (others => '0')); @@ -3888,6 +3975,7 @@ begin stale_check <= '0'; is_live_assert <= '0'; is_heartbeat_res <= '0'; + reset_max_pointer <= '0'; last_word_in_latch <= '0'; else stage <= stage_next; @@ -3915,8 +4003,10 @@ begin mem_addr_base <= mem_addr_base_next; mem_addr <= mem_addr_next; addr_res <= addr_res_next; + last_addr <= last_addr_next; long_latch <= long_latch_next; rcvd <= rcvd_next; + max_participant_addr <= max_participant_addr_next; guid <= guid_next; mem_guidprefix <= mem_guidprefix_next; lease_duration <= lease_duration_next; @@ -3946,6 +4036,7 @@ begin stale_check <= stale_check_next; is_live_assert <= is_live_assert_next; is_heartbeat_res <= is_heartbeat_res_next; + reset_max_pointer <= reset_max_pointer_next; last_word_in_latch <= last_word_in_latch_next; end if; end if;