Fix on-demand Instance/Sample removal code

This commit is contained in:
Greek 2021-01-26 20:45:59 +01:00
parent 728a6964d3
commit 8433006fb8

View File

@ -825,7 +825,8 @@ begin
-- Wait for Instance Search to finish
if (inst_op_done = '1') then
sample_addr_next <= cur_sample + SMF_DISPOSED_GEN_CNT_OFFSET;
sample_addr_next <= cur_sample + SMF_DISPOSED_GEN_CNT_OFFSET;
cur_inst_next <= inst_addr_base;
-- Instance Found
if (inst_addr_base /= INSTANCE_MEMORY_MAX_ADDRESS) then
@ -1234,6 +1235,8 @@ begin
newest_sample_next <= empty_sample_list_head;
end if;
-- NOTE: added_new_instance and remove_oldest_sample are NOT mutual exclusive, but Instance Removal takes precedence.
-- New Instance was added, and Instance Memory is Full
if (added_new_instance = '1' and inst_empty_head = INSTANCE_MEMORY_MAX_ADDRESS) then
-- Memory Operation Guard
@ -1242,12 +1245,19 @@ begin
inst_opcode <= GET_FIRST_INSTANCE;
inst_data_variant <= '0';
-- NOTE: Instances are only removed in two occasions:
-- * A new instance is added, and the instance memory gets full
-- * A Sample is removed, making an instance eligible for deletion, while the
-- instance memory is full.
-- The combination of both cases allows to search and remove instances only when needed.
stage_next <= REMOVE_STALE_INSTANCE;
else
cnt_next <= cnt; -- Keep State
end if;
elsif (remove_oldest_inst_sample = '1') then
sample_addr_next <= cur_sample + SMF_INSTANCE_ADDR_OFFSET;
cur_sample <= oldest_sample;
sample_addr_next <= oldest_sample + SMF_INSTANCE_ADDR_OFFSET;
stage_next <= FIND_OLDEST_INST_SAMPLE;
elsif (remove_oldest_sample = '1') then
stage_next <= GET_OLDEST_SAMPLE_INSTANCE;
@ -1290,19 +1300,19 @@ begin
-- Preload
when 0 =>
sample_ren <= '1';
sample_addr_next <= cur_sample + SMF_NEXT_ADDR_OFFSET; -- Next Addr
sample_addr_next <= cur_sample + SMF_NEXT_ADDR_OFFSET;
-- Instance Address
when 1 =>
sample_ren <= '1';
-- Oldest Instance Sample Found
if (sample_read_data = inst_addr_base) then
if (sample_read_data = cur_inst) then
stage_next <= REMOVE_SAMPLE;
sample_addr_next <= cur_sample + SMF_PREV_ADDR_OFFSET;
end if;
-- Next Address
when 2 =>
cur_sample_next <= sample_read_data;
sample_addr_next <= sample_read_data + SMF_INSTANCE_ADDR_OFFSET; -- Instance Addr
sample_addr_next <= sample_read_data + SMF_INSTANCE_ADDR_OFFSET;
cnt_next <= 0;
when others =>
null;
@ -1558,8 +1568,14 @@ begin
if (inst_op_done = '1') then
-- Iterated through all Instances
if (inst_addr_base = INSTANCE_MEMORY_MAX_ADDRESS) then
-- DONE
stage_next <= IDLE;
if (remove_oldest_inst_sample = '1') then
cur_sample <= oldest_sample;
sample_addr_next <= oldest_sample + SMF_INSTANCE_ADDR_OFFSET;
stage_next <= FIND_OLDEST_INST_SAMPLE;
else
-- DONE
stage_next <= IDLE;
end if;
else
-- Convert Writer Bitmap to SLV
tmp_bitmap := to_endpoint_bitmap(inst_data.writer_bitmap);
@ -1570,8 +1586,14 @@ begin
inst_op_start <= '1';
inst_opcode <= REMOVE_INSTANCE;
-- DONE
stage_next <= IDLE;
if (remove_oldest_inst_sample = '1') then
cur_sample <= oldest_sample;
sample_addr_next <= oldest_sample + SMF_INSTANCE_ADDR_OFFSET;
stage_next <= FIND_OLDEST_INST_SAMPLE;
else
-- DONE
stage_next <= IDLE;
end if;
else
-- Continue Search
inst_op_start <= '1';