Commit b1ff9b89 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

modules/swcore: bugfix in allocator, read new free page sooner when there are…

modules/swcore: bugfix in allocator, read new free page sooner when there are again some pages available

This one fixes the situation when allocFSM in one of the input blocks requests
usecount set and new allocation (S_PCKSTART_SET_AND_REQ state) while out_nomem
is just before the transition from high to low. In that case arbiter grants
access to this Input Block request (because setting usecount does not require
out_nomem to be '0'). Then, we expect first allocation immediatelly after
out_nomem is 0, but reading next page happens only when out_nomem_d1 is '0'.
That's too late and the same page address was given to two subsequent allocation
requests.
The fix forces q_read aligned to out_nomem_d0 to read earlier next allocation
address. In addition, _done_ for allocation is now generated only if there was a
valid page address read in advance from the memory (to prevent double
allocations of the same page).
parent 29aef651
......@@ -339,10 +339,12 @@ begin -- syn
process(clk_i)
begin
if rising_edge(clk_i) then
if (rst_n_i = '0' or alloc_req_in.alloc = '1') then
if (rst_n_i = '0') then
pg_adv_valid <= '0';
elsif(out_nomem_d1 = '0') then
elsif(out_nomem_d0 = '0') then
pg_adv_valid <= '1';
elsif(alloc_req_in.alloc = '1') then
pg_adv_valid <= '0';
end if;
end if;
end process;
......@@ -363,7 +365,7 @@ begin -- syn
-- nomem_d0 : _______|-------
-- alloc_d0 " _______|-|____ <= this need to be handled
-- nomem_d1 : ________|-------
q_read_p0 <= '1' when (pg_adv_valid = '0' and out_nomem_d1 = '0') else '0';
q_read_p0 <= '1' when ((pg_adv_valid = '0' or alloc_req_d0.alloc='1') and out_nomem_d0 = '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;
......@@ -517,7 +519,7 @@ begin -- syn
if (rst_n_i = '0') or (initializing = '1') then
done_p1 <= '0';
else
if(((alloc_req_d0.alloc = '1' and out_nomem_d1 = '0') or
if(((alloc_req_d0.alloc = '1' and pg_adv_valid = '1') or
alloc_req_d0.set_usecnt = '1' or alloc_req_d0.free = '1' or
alloc_req_d0.f_free = '1') and initializing = '0') then
done_p1 <= '1';
......
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