Commit c6783f6a authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

modules/swcore: bugfix to allocator preventing from using twice the same page when memory gets full

The problem occured in swc_page_alloc_ram_bug.vhd when there were no more free
pages (out_nomem_d1='1') and input block was requesting allocation and setting
usecnt (alloc FSM in S_PCKSTART_SET_AND_REQ). The operation was _done_ because
there is always one free page read in advance, prepared to be allocated to a
requesting input block and set usecnt does not depend on out_nomem_d1.
However, reading of the next free page from the memory was done only on
alloc_req, only if there were still some free pages (q_read_p0 <= alloc_req &
!out_nomem_d1).
That means allocator was holding address of the page just allocated to one of
the input blocks, and was giving the same address to the next one requesting
allocation (if in the meantime out_nomem_d1 went to '0').
To fix that I've added one register keeping information if the page read from
the memory was already given to any requestor. If it was then I do _read_ of the
new page imediately after there are some new pages (out_nomem_d1 = '0') so that
it is ready when next time somebody asks.
parent dd0dadd6
......@@ -273,6 +273,7 @@ architecture syn of swc_page_allocator_new is
signal res_almost_full : std_logic_vector(g_resource_num -1 downto 0);
-----------------------------
signal pg_adv_valid : std_logic;
type t_alloc_req is record
alloc : std_logic;
......@@ -339,6 +340,19 @@ begin -- syn
end if;
end process;
-- keeping the information if free page read from memory was already allocated
-- to any of the ports
process(clk_i)
begin
if rising_edge(clk_i) then
if (rst_n_i = '0' or alloc_req_in.alloc = '1') then
pg_adv_valid <= '0';
elsif(out_nomem_d1 = '0') then
pg_adv_valid <= '1';
end if;
end if;
end process;
-- write queue when freeing and not initializing (because when initializing we use other
-- port of this memory)
......@@ -356,7 +370,7 @@ begin -- syn
-- nomem_d0 : _______|-------
-- alloc_d0 " _______|-|____ <= this need to be handled
-- nomem_d1 : ________|-------
q_read_p0 <= '1' when (alloc_req_d0.alloc = '1') and (out_nomem_d1 = '0') else '0';
q_read_p0 <= '1' when (pg_adv_valid = '0' and out_nomem_d1 = '0') else '0';
-- address of page stored in the memory (queue)
q_input_addr_p1 <= std_logic_vector(wr_ptr_p1) when initializing = '1' else alloc_req_d1.pgaddr_free;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment