Skip to content
Snippets Groups Projects
Commit 2ab5ede7 authored by Maciej Lipinski's avatar Maciej Lipinski
Browse files

[swcore/res_mgr] adapted resource managerment unit to work with new allocator...

[swcore/res_mgr] adapted resource managerment unit to work with new allocator and intergrated the unit into allocator (core and multiport
parent 2893c871
Branches
Tags
No related merge requests found
......@@ -200,18 +200,24 @@ architecture syn of swc_multiport_page_allocator is
end component;
type t_port_state is record
req_ib : std_logic;
req_ob : std_logic;
req_alloc : std_logic;
req_free : std_logic;
req_set_usecnt : std_logic;
req_force_free : std_logic;
req_addr_usecnt: std_logic_vector(g_page_addr_width-1 downto 0);
req_addr_free : std_logic_vector(g_page_addr_width-1 downto 0);
req_addr_f_free: std_logic_vector(g_page_addr_width-1 downto 0);
req_ucnt_set : std_logic_vector(g_usecount_width-1 downto 0);
req_ucnt_alloc : std_logic_vector(g_usecount_width-1 downto 0);
req_ib : std_logic;
req_ob : std_logic;
req_alloc : std_logic;
req_free : std_logic;
req_set_usecnt : std_logic;
req_force_free : std_logic;
req_addr_usecnt : std_logic_vector(g_page_addr_width-1 downto 0);
req_addr_free : std_logic_vector(g_page_addr_width-1 downto 0);
req_addr_f_free : std_logic_vector(g_page_addr_width-1 downto 0);
req_ucnt_set : std_logic_vector(g_usecount_width-1 downto 0);
req_ucnt_alloc : std_logic_vector(g_usecount_width-1 downto 0);
req_resource : std_logic_vector(g_resource_num_width-1 downto 0);
req_free_resource : std_logic_vector(g_resource_num_width-1 downto 0);
req_free_res_valid : std_logic;
req_f_free_resource : std_logic_vector(g_resource_num_width-1 downto 0);
req_f_free_res_valid : std_logic;
req_rescnt_pg_num : std_logic_vector(g_page_addr_width -1 downto 0);
grant_ib_d : std_logic_vector(2 downto 0);
grant_ob_d : std_logic_vector(2 downto 0);
......@@ -303,15 +309,22 @@ architecture syn of swc_multiport_page_allocator is
begin -- syn
gen_records : for i in 0 to g_num_ports-1 generate
ports(i).req_force_free <= force_free_i(i);
ports(i).req_free <= free_i(i);
ports(i).req_alloc <= alloc_i(i);
ports(i).req_set_usecnt <= set_usecnt_i(i);
ports(i).req_addr_usecnt<= pgaddr_usecnt_i (g_page_addr_width * (i+1) -1 downto g_page_addr_width*i);
ports(i).req_addr_free <= pgaddr_free_i (g_page_addr_width * (i+1) -1 downto g_page_addr_width*i);
ports(i).req_addr_f_free<= pgaddr_force_free_i(g_page_addr_width * (i+1) -1 downto g_page_addr_width*i);
ports(i).req_ucnt_set <= usecnt_set_i(g_usecount_width * (i+1) - 1 downto g_usecount_width*i);
ports(i).req_ucnt_alloc <= usecnt_alloc_i(g_usecount_width * (i+1) - 1 downto g_usecount_width*i);
ports(i).req_force_free <= force_free_i(i);
ports(i).req_free <= free_i(i);
ports(i).req_alloc <= alloc_i(i);
ports(i).req_set_usecnt <= set_usecnt_i(i);
ports(i).req_free_res_valid <= free_resource_valid_i(i);
ports(i).req_f_free_res_valid <= force_free_resource_valid_i(i);
ports(i).req_addr_usecnt <= pgaddr_usecnt_i (g_page_addr_width *(i+1)-1 downto g_page_addr_width *i);
ports(i).req_addr_free <= pgaddr_free_i (g_page_addr_width *(i+1)-1 downto g_page_addr_width *i);
ports(i).req_addr_f_free <= pgaddr_force_free_i (g_page_addr_width *(i+1)-1 downto g_page_addr_width *i);
ports(i).req_ucnt_set <= usecnt_set_i (g_usecount_width *(i+1)-1 downto g_usecount_width *i);
ports(i).req_ucnt_alloc <= usecnt_alloc_i (g_usecount_width *(i+1)-1 downto g_usecount_width *i);
ports(i).req_resource <= resource_i (g_resource_num_width*(i+1)-1 downto g_resource_num_width*i);
ports(i).req_free_resource <= free_resource_i (g_resource_num_width*(i+1)-1 downto g_resource_num_width*i);
ports(i).req_f_free_resource <= force_free_resource_i(g_resource_num_width*(i+1)-1 downto g_resource_num_width*i);
ports(i).req_rescnt_pg_num <= rescnt_page_num_i (g_page_addr_width *(i+1)-1 downto g_page_addr_width *i);
end generate gen_records;
-- MUXes
......@@ -435,6 +448,7 @@ begin -- syn
g_num_ports => g_num_ports,
g_usecount_width => g_usecount_width,
--- management
g_with_RESOURCE_MGR => g_with_RESOURCE_MGR,
g_page_size => g_page_size,
g_max_pck_size => g_max_pck_size,
g_special_res_num_pages => g_special_res_num_pages,
......@@ -485,8 +499,7 @@ begin -- syn
alloc_done(i) <= '1' when (ports(i).req_alloc ='1' and pg_rsp_vec(i)='1' and done_alloc ='1') else '0';
free_done(i) <= '1' when (ports(i).req_free ='1' and pg_rsp_vec(i)='1' and done_free ='1') else '0';
force_free_done(i) <= '1' when (ports(i).req_force_free='1' and pg_rsp_vec(i)='1' and done_force_free='1') else '0';
set_usecnt_done(i) <= '1' when (ports(i).req_set_usecnt='1' and pg_rsp_vec(i)='1' and done_usecnt ='1') else '0';
set_usecnt_done(i) <= '1' when (ports(i).req_set_usecnt='1' and pg_rsp_vec(i)='1' and done_usecnt ='1') else '0';
end generate gen_done;
alloc_done_o <= alloc_done;
......@@ -525,10 +538,51 @@ begin -- syn
pg_resource_in <= (others => '0');
pg_free_resource_valid <= '0';
pg_rescnt_page_num <= (others => '0');
end generate;
end generate gen_no_RESOURCE_MGR;
gen_RESOURCE_MGR: if (g_with_RESOURCE_MGR = true) generate
p_gen_resource_reqs : process(ports)
variable tmp_resource_in : std_logic_vector(g_resource_num_width-1 downto 0);
variable tmp_free_res_valid : std_logic;
variable tmp_rescnt_pg_num : std_logic_vector(g_page_addr_width -1 downto 0);
begin
tmp_resource_in := (others => 'X');
tmp_free_res_valid := '0';
tmp_rescnt_pg_num := (others => 'X');
for i in 0 to g_num_ports-1 loop
if(ports(i).grant_ib_d(0) = '1') then
tmp_resource_in := ports(i).req_resource;
tmp_free_res_valid := '0';
tmp_rescnt_pg_num := ports(i).req_rescnt_pg_num;
elsif(ports(i).grant_ob_d(0) = '1') then
if(ports(i).req_free = '1' and ports(i).req_free_res_valid = '1') then
tmp_resource_in := ports(i).req_free_resource;
tmp_free_res_valid := '1';
elsif(ports(i).req_force_free = '1' and ports(i).req_f_free_res_valid ='1') then
tmp_resource_in := ports(i).req_f_free_resource;
tmp_free_res_valid := '1';
else -- to see problems in red on simulation
tmp_resource_in := (others =>'X');
tmp_free_res_valid := '0';
end if;
tmp_rescnt_pg_num := (others =>'X');
end if;
end loop; -- i
pg_resource_in <= tmp_resource_in;
pg_free_resource_valid <= tmp_free_res_valid;
pg_rescnt_page_num <= tmp_rescnt_pg_num;
end process p_gen_resource_reqs;
gen_res_out : for i in 0 to g_num_ports-1 generate
resource_o ((i+1)*g_resource_num_width-1 downto i*g_resource_num_width) <= pg_resource_out when (free_done(i) ='1' or force_free_done(i) ='1') else
(others => '0');
res_full_o ((i+1)*g_resource_num -1 downto i*g_resource_num) <= pg_res_full;
res_almost_full_o((i+1)*g_resource_num -1 downto i*g_resource_num) <= pg_res_almost_full;
end generate gen_res_out;
end generate gen_RESOURCE_MGR;
--------------------------------------------------------------------------------------------------
......
......@@ -239,16 +239,20 @@ architecture syn of swc_page_allocator_new is
signal usecnt_addr_rd_p0 : std_logic_vector(g_page_addr_width-1 downto 0);
signal usecnt_rddata_p1 : std_logic_vector(g_usecount_width-1 downto 0);
signal usecnt_ena_wr_p1_ram1, usecnt_ena_wr_p1_ram2 : std_logic;
signal rescnt_rddata_p1 : std_logic_vector(g_resource_num_width-1 downto 0);
signal ena_wr_p1_ram1, ena_wr_p1_ram2 : std_logic;
signal rddata_p1_ram1, rddata_p1_ram2 : std_logic_vector(g_usecount_width+1+g_resource_num_width-1 downto 0);
signal addr_wr_p1_ram1,addr_wr_p1_ram2 : std_logic_vector(g_page_addr_width-1 downto 0);
signal usecnt_wrdata_p1_ram1, usecnt_wrdata_p1_ram2 : std_logic_vector(g_usecount_width+1-1 downto 0);
signal usecnt_rddata_p1_ram1, usecnt_rddata_p1_ram2 : std_logic_vector(g_usecount_width+1-1 downto 0);
signal usecnt_addr_wr_p1_ram1,usecnt_addr_wr_p1_ram2 : std_logic_vector(g_page_addr_width-1 downto 0);
signal rescnt_wrdata_p1_ram1, rescnt_wrdata_p1_ram2 : std_logic_vector(g_resource_num_width-1 downto 0);
signal wrdata_p1_ram1, wrdata_p1_ram2 : std_logic_vector(g_usecount_width+1+g_resource_num_width-1 downto 0);
signal q_output_addr_p1 : std_logic_vector(g_page_addr_width-1 downto 0);
signal q_input_addr_p1 : std_logic_vector(g_page_addr_width-1 downto 0);
signal done_p1 : std_logic;
signal ram_ones : std_logic_vector(g_page_addr_width + g_usecount_width -1 downto 0);
signal done_p1 : std_logic;
signal ram_ones : std_logic_vector(g_page_addr_width + g_usecount_width -1 downto 0);
signal free_last_usecnt : std_logic;
--debuggin sygnals
signal tmp_dbg_dealloc : std_logic; -- used for symulation debugging, don't remove
......@@ -257,17 +261,30 @@ architecture syn of swc_page_allocator_new is
signal usecnt_not_zero : std_logic;
signal real_nomem_d0 : std_logic;
signal real_nomem_d1 : std_logic;
-------------------------- resource management
signal res_mgr_alloc : std_logic;
signal res_mgr_free : std_logic;
signal res_mgr_res_num : std_logic_vector(g_resource_num_width-1 downto 0);
signal res_mgr_rescnt_set : std_logic;
signal set_usecnt_allowed_p1 : std_logic;
signal res_almost_full : std_logic_vector(g_resource_num -1 downto 0);
-----------------------------
type t_alloc_req is record
alloc : std_logic;
free : std_logic;
f_free : std_logic;
set_usecnt : std_logic;
usecnt_set : std_logic_vector(g_usecount_width-1 downto 0); -- input when setting usecnt
usecnt_alloc : std_logic_vector(g_usecount_width-1 downto 0); -- input when allocating usecnt
pgaddr_free : std_logic_vector(g_page_addr_width -1 downto 0);
pgaddr_usecnt : std_logic_vector(g_page_addr_width -1 downto 0);
grant_vec : std_logic_vector(g_num_ports-1 downto 0);
alloc : std_logic;
free : std_logic;
f_free : std_logic;
set_usecnt : std_logic;
usecnt_set : std_logic_vector(g_usecount_width-1 downto 0); -- input when setting usecnt
usecnt_alloc : std_logic_vector(g_usecount_width-1 downto 0); -- input when allocating usecnt
pgaddr_free : std_logic_vector(g_page_addr_width -1 downto 0);
pgaddr_usecnt : std_logic_vector(g_page_addr_width -1 downto 0);
grant_vec : std_logic_vector(g_num_ports-1 downto 0);
resource : std_logic_vector(g_resource_num_width-1 downto 0);
free_res_valid : std_logic;
rescnt_page_num : std_logic_vector(g_page_addr_width -1 downto 0);
end record;
constant c_pipeline_depth : integer := 2;
......@@ -278,28 +295,34 @@ architecture syn of swc_page_allocator_new is
signal alloc_req_d1 : t_alloc_req;
constant alloc_req_zero : t_alloc_req := (
alloc => '0',
free => '0',
f_free => '0',
set_usecnt => '0',
usecnt_set => (others => '0'),
usecnt_alloc => (others => '0'),
pgaddr_free => (others => '0'),
pgaddr_usecnt=> (others => '0'),
grant_vec => (others => '0'));
alloc => '0',
free => '0',
f_free => '0',
set_usecnt => '0',
usecnt_set => (others => '0'),
usecnt_alloc => (others => '0'),
pgaddr_free => (others => '0'),
pgaddr_usecnt => (others => '0'),
grant_vec => (others => '0'),
resource => (others => '0'),
free_res_valid => '0',
rescnt_page_num => (others => '0'));
begin -- syn
ram_ones <= (others => '1');
alloc_req_in.alloc <= alloc_i;
alloc_req_in.free <= free_i;
alloc_req_in.f_free <= force_free_i;
alloc_req_in.set_usecnt <= set_usecnt_i;
alloc_req_in.usecnt_set <= usecnt_set_i;
alloc_req_in.usecnt_alloc <= usecnt_alloc_i;
alloc_req_in.pgaddr_free <= pgaddr_free_i;
alloc_req_in.pgaddr_usecnt<= pgaddr_usecnt_i;
alloc_req_in.grant_vec <= req_vec_i;
ram_ones <= (others => '1');
alloc_req_in.alloc <= alloc_i;
alloc_req_in.free <= free_i;
alloc_req_in.f_free <= force_free_i;
alloc_req_in.set_usecnt <= set_usecnt_i;
alloc_req_in.usecnt_set <= usecnt_set_i;
alloc_req_in.usecnt_alloc <= usecnt_alloc_i;
alloc_req_in.pgaddr_free <= pgaddr_free_i;
alloc_req_in.pgaddr_usecnt <= pgaddr_usecnt_i;
alloc_req_in.grant_vec <= req_vec_i;
alloc_req_in.resource <= resource_i;
alloc_req_in.free_res_valid <= free_resource_valid_i;
alloc_req_in.rescnt_page_num<= rescnt_page_num_i;
p_pipe: process(clk_i)
begin
......@@ -352,26 +375,28 @@ begin -- syn
ra_i => std_logic_vector(rd_ptr_p0),
rd_o => q_output_addr_p1);
usecnt_addr_wr_p1_ram1 <= std_logic_vector(rd_ptr_p0) when initializing = '1' else
addr_wr_p1_ram1 <= std_logic_vector(rd_ptr_p0) when initializing = '1' else
q_output_addr_p1 when alloc_req_d1.alloc = '1' else
alloc_req_d1.pgaddr_free;
usecnt_addr_wr_p1_ram2 <= std_logic_vector(rd_ptr_p0) when initializing = '1' else
addr_wr_p1_ram2 <= std_logic_vector(rd_ptr_p0) when initializing = '1' else
alloc_req_d1.pgaddr_usecnt when alloc_req_d1.set_usecnt = '1' else
alloc_req_d1.pgaddr_free;
usecnt_ena_wr_p1_ram1 <= alloc_req_d1.alloc or
ena_wr_p1_ram1 <= alloc_req_d1.alloc or
alloc_req_d1.free or
alloc_req_d1.f_free or
initializing;
usecnt_ena_wr_p1_ram2 <= alloc_req_d1.set_usecnt or
alloc_req_d1.free or -- zero when free (later RAM1 will be used)
alloc_req_d1.f_free or
ena_wr_p1_ram2 <= (alloc_req_d1.set_usecnt and set_usecnt_allowed_p1) or
alloc_req_d1.free or -- zero when free (later RAM1 will be used)
alloc_req_d1.f_free or
initializing;
----------------------------------- form write RAM data ------------------------------------
----------------------------------- (a bit complex) ------------------------------------
usecnt_wrdata_p1_ram1 <= '1' & alloc_req_d1.usecnt_alloc when alloc_req_d1.alloc = '1' else
'0' & f_gen_dummy_vec('0', g_usecount_width) when alloc_req_d1.f_free = '1' else
'0' & f_gen_dummy_vec('0', g_usecount_width) when initializing = '1' else
......@@ -380,40 +405,49 @@ begin -- syn
usecnt_wrdata_p1_ram2 <= '1' & alloc_req_d1.usecnt_set when alloc_req_d1.set_usecnt = '1' else
'0' & f_gen_dummy_vec('0', g_usecount_width);
rescnt_wrdata_p1_ram1 <= alloc_req_d1.resource when (alloc_req_d1.alloc = '1' and alloc_req_d1.set_usecnt = '0') else
f_gen_dummy_vec('0', g_resource_num_width) ;
rescnt_wrdata_p1_ram2 <= alloc_req_d1.resource when alloc_req_d1.set_usecnt = '1' else
f_gen_dummy_vec('0', g_resource_num_width) ;
usecnt_addr_rd_p0 <= alloc_req_d0.pgaddr_free;
wrdata_p1_ram1 <= rescnt_wrdata_p1_ram1 & usecnt_wrdata_p1_ram1;
wrdata_p1_ram2 <= rescnt_wrdata_p1_ram2 & usecnt_wrdata_p1_ram2;
usecnt_addr_rd_p0 <= alloc_req_d0.pgaddr_free;
usecnt_rddata_p1 <= usecnt_rddata_p1_ram2(g_usecount_width-1 downto 0) when (usecnt_rddata_p1_ram2(g_usecount_width) = '1') else
usecnt_rddata_p1_ram1(g_usecount_width-1 downto 0);
usecnt_rddata_p1 <= rddata_p1_ram2(g_usecount_width-1 downto 0) when (rddata_p1_ram2(g_usecount_width) = '1') else
rddata_p1_ram1(g_usecount_width-1 downto 0);
rescnt_rddata_p1 <= rddata_p1_ram2(g_resource_num_width+g_usecount_width downto g_usecount_width+1) when (rddata_p1_ram2(g_usecount_width) = '1') else
rddata_p1_ram1(g_resource_num_width+g_usecount_width downto g_usecount_width+1);
-- stores usecnts of pages, the addres is the page_addr (not ptr)
U_UseCnt_RAM_1 : swc_rd_wr_ram
generic map (
g_data_width => g_usecount_width+1,
g_data_width => g_usecount_width+1+g_resource_num_width,
g_size => 2**g_page_addr_width)
port map (
clk_i => clk_i,
rst_n_i => rst_n_i,
we_i => usecnt_ena_wr_p1_ram1,
wa_i => usecnt_addr_wr_p1_ram1,
wd_i => usecnt_wrdata_p1_ram1,
we_i => ena_wr_p1_ram1,
wa_i => addr_wr_p1_ram1,
wd_i => wrdata_p1_ram1,--usecnt_wrdata_p1_ram1,
ra_i => usecnt_addr_rd_p0,
rd_o => usecnt_rddata_p1_ram1);
rd_o => rddata_p1_ram1);
-- stores usecnts of pages, the addres is the page_addr (not ptr)
U_UseCnt_RAM_2 : swc_rd_wr_ram
generic map (
g_data_width => g_usecount_width+1,
g_data_width => g_usecount_width+1+g_resource_num_width,
g_size => 2**g_page_addr_width)
port map (
clk_i => clk_i,
rst_n_i => rst_n_i,
we_i => usecnt_ena_wr_p1_ram2,
wa_i => usecnt_addr_wr_p1_ram2,
wd_i => usecnt_wrdata_p1_ram2,
we_i => ena_wr_p1_ram2,
wa_i => addr_wr_p1_ram2,
wd_i => wrdata_p1_ram2,--usecnt_wrdata_p1_ram2,
ra_i => usecnt_addr_rd_p0,
rd_o => usecnt_rddata_p1_ram2);
rd_o => rddata_p1_ram2);
p_pointers : process(clk_i)
begin
......@@ -498,7 +532,7 @@ begin -- syn
end if;
end process;
-- out_nomem <= real_nomem;
free_last_usecnt <= (not initializing) when (alloc_req_d1.free = '1' and unsigned(usecnt_rddata_p1) = 1) else '0';
pgaddr_o <= q_output_addr_p1;
done_o <= done_p1;
done_alloc_o <= done_p1 and alloc_req_d1.alloc;
......@@ -507,7 +541,7 @@ begin -- syn
done_force_free_o <= done_p1 and alloc_req_d1.f_free;
rsp_vec_o <= alloc_req_d1.grant_vec;
nomem_o <= out_nomem or initializing;
free_last_usecnt_o <= (not initializing) when (alloc_req_d1.free = '1' and unsigned(usecnt_rddata_p1) = 1) else '0';
free_last_usecnt_o <= free_last_usecnt;
gen_no_RESOURCE_MGR: if (g_with_RESOURCE_MGR = false) generate
resource_o <= (others => '0');
......@@ -518,4 +552,66 @@ begin -- syn
dbg_o (g_num_dbg_vector_width-1 downto g_page_addr_width+1) <= (others =>'0');
end generate;
gen_RESOURCE_MGR: if (g_with_RESOURCE_MGR = true) generate
--------------------------------------------------------------------------------------------------
-- Resource Manager logic and instantiation
--------------------------------------------------------------------------------------------------
p_usecnt_set_allow : process(clk_i)
begin
if rising_edge(clk_i) then
if rst_n_i = '0' then
set_usecnt_allowed_p1 <= '0';
else
if(alloc_req_d0.set_usecnt ='1') then
if(res_almost_full(to_integer(unsigned(alloc_req_d0.resource))) = '1') then
-- not enough to accommodate max size frame, sorry we cannot serve the request
set_usecnt_allowed_p1 <= '0';
else
set_usecnt_allowed_p1 <= '1';
end if;
else
set_usecnt_allowed_p1 <= '0';
end if;
end if;
end if;
end process;
res_mgr_alloc <= alloc_req_d1.alloc and done_p1;
res_mgr_free <= ((alloc_req_d1.free and free_last_usecnt) or alloc_req_d1.f_free) and done_p1;
res_mgr_res_num <= rescnt_rddata_p1 when (alloc_req_d1.free_res_valid='0' and
(alloc_req_d1.free='1' or alloc_req_d1.f_free='1')) else
alloc_req_d1.resource;
res_mgr_rescnt_set <= done_p1 and alloc_req_d1.set_usecnt and set_usecnt_allowed_p1;
------ resource management
RESOURCE_MANAGEMENT: swc_alloc_resource_manager
generic map(
g_num_ports => g_num_ports,
g_max_pck_size => g_max_pck_size,
g_page_size => g_page_size,
g_total_num_pages => g_num_pages,
g_total_num_pages_width => g_page_addr_width,
g_special_res_num_pages => g_special_res_num_pages,
g_resource_num => g_resource_num,
g_resource_num_width => g_resource_num_width,
g_num_dbg_vector_width => g_num_dbg_vector_width
)
port map (
clk_i => clk_i,
rst_n_i => rst_n_i,
resource_i => res_mgr_res_num,
alloc_i => res_mgr_alloc,
free_i => res_mgr_free,
rescnt_set_i => res_mgr_rescnt_set,
rescnt_page_num_i => alloc_req_d1.rescnt_page_num,
res_full_o => res_full_o,
res_almost_full_o => res_almost_full,
dbg_o => dbg_o
);
resource_o <= rescnt_rddata_p1;
set_usecnt_succeeded_o <= res_mgr_rescnt_set;
res_almost_full_o <= res_almost_full;
end generate;
end syn;
......@@ -88,6 +88,8 @@
-- Revisions :
-- Date Version Author Description
-- 2010-03-30 1.0 mlipinsk Created
-- 2013-10-30 1.1 mlipinsk adapted to optimized alloc (alloc & usecnt at
-- same time must be handled)
-------------------------------------------------------------------------------
library ieee;
......@@ -210,15 +212,38 @@ begin
end loop;
else
-----------------------------------------------------------------------------------------
-- "resource count set" is used to move a number of pages from "unknown" resources
-- to any other resource pool. Therefore, if the cur_res is different then "unknown" (0),
-- we subtract from unknown pool
-----------------------------------------------------------------------------------------
if(alloc_i = '1') then
if(alloc_i = '1' and rescnt_set_i = '1') then
-- here we allocate the first page of frame, so it's always to unknown resource num=0
-- and we also, at the same time, set usecnt (i.e. take pages from unknown to other
-- resource), so we need to:
-- * add to the indicated resource (cur_res) the number of set pages
-- (rescnt_page_num_i) - rescnt_set request)
-- * add to the unknown resources a single page - allocation request
-- * substract from unknown resource the number of set pages (rescnt_page_num) and
-- add single page for the allocation
-- ... SIMPLE...;-p
resources(cur_res).cnt <= resources(cur_res).cnt + unsigned(rescnt_page_num_i);
if(cur_res /= 0) then
resources(0).cnt <= resources(0).cnt - unsigned(rescnt_page_num_i) + 1;
else
resources(0).cnt <= resources(0).cnt + 1;
end if;
elsif(alloc_i = '1') then
-- we are allocating a page, it can be the first page (so unknow resource) but
-- it can also be inter-frame page (known resource...)
resources(cur_res).cnt <= resources(cur_res).cnt + 1;
elsif(free_i = '1') then
-- freeing page from some resource
resources(cur_res).cnt <= resources(cur_res).cnt - 1;
elsif(rescnt_set_i = '1') then
-- "resource count set" is used to move a number of pages from "unknown" resources
-- to any other resource pool. Therefore, if the cur_res is different then "unknown" (0),
-- we subtract from unknown pool
-- setting page usecnt and moving a number of pages from unknown resource to
-- a known one
resources(cur_res).cnt <= resources(cur_res).cnt + unsigned(rescnt_page_num_i);
if(cur_res /= 0) then
resources(0).cnt <= resources(0).cnt - unsigned(rescnt_page_num_i);
......
......@@ -659,6 +659,7 @@ architecture rtl of xswc_core is
g_page_num => c_mpm_page_num,
g_usecount_width => c_usecount_width,
-- management
g_with_RESOURCE_MGR => true,
g_max_pck_size => c_res_mmu_max_pck_size,
g_page_size => g_mpm_page_size,
g_special_res_num_pages => c_res_mmu_special_res_num_pages,
......
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