UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
6,399 Views
Registered: ‎04-29-2012

Dynamic memory allocation

I'm trying to implement 4GB memory by dynamic memory allocation

I get an error saying Allocation not possible at the below line

new_ptr := new mem_entry;

 

 

0 Kudos
8 Replies
Historian
Historian
6,399 Views
Registered: ‎02-25-2008

Re: Dynamic memory allocation


@diabolique0007 wrote:

I'm trying to implement 4GB memory by dynamic memory allocation

I get an error saying Allocation not possible at the below line

new_ptr := new mem_entry;

 

 


Could you please be a little more specific?

----------------------------Yes, I do this for a living.
0 Kudos
6,395 Views
Registered: ‎04-29-2012

Re: Dynamic memory allocation

Below is my package and the lines in red are those which show error

 

library ieee;
use ieee.std_logic_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
package mem_pkg is
subtype mem_width_t is std_logic_vector(31 downto 0);
subtype mem_depth_t is integer range 0 to 1073741823;
type mem_t is array(mem_depth_t) of mem_width_t;
--variable my_mem : mem_t;
type mem_entry ;
type entry_ptr is access mem_entry;

type mem_entry is record
address : integer;
data : std_logic_vector(31 downto 0);
nxt : entry_ptr;
end record;

type head is record
num_entries : integer;
list_ptr : entry_ptr;
end record;

type head_ptr is access head;
procedure wr_data (
constant location: in integer;
constant data : in std_logic_vector;
variable first : inout head_ptr
) ;
procedure rd_data (
constant location : in integer;
variable data : out std_logic_vector ;
variable allocated : out boolean;
variable first : inout head_ptr
) ;
end; -- mem_pkg

package body mem_pkg is
procedure wr_data (
constant location: in integer;
constant data : in std_logic_vector;
variable first : inout head_ptr
) is
variable temp_ptr : entry_ptr;
variable new_ptr : entry_ptr;
variable prev_ptr : entry_ptr;
variable done : boolean := false;
begin
-- set done to true when allocation occurs
done := false;
-- first access to memory
if(first.num_entries = 0)then
first.list_ptr := new mem_entry;
first.num_entries := 1;
first.list_ptr.address := location;
first.list_ptr.data := data;
first.list_ptr.nxt := null;
done := true;
-- address is lowest value so far in allocation to put
-- at head of list
elsif(location < first.list_ptr.address)then
new_ptr := new mem_entry;
new_ptr.data := data;
new_ptr.nxt := first.list_ptr;
new_ptr.address := location;
first.list_ptr := new_ptr;
first.num_entries := first.num_entries + 1;
done := true;
else -- location must be >=first.list_prt.address
temp_ptr := first.list_ptr;
while temp_ptr /= null and not done loop
if(temp_ptr.address = location)then
-- address already allocated
temp_ptr.data:= data;
done := true;
elsif(temp_ptr.address > location)then
new_ptr := new mem_entry;
new_ptr.address := location;
new_ptr.data := data;
new_ptr.nxt := temp_ptr;
-- break pointer chain and insert new_ptr
prev_ptr.nxt := new_ptr;
first.num_entries := first.num_entries + 1;
done := true;
else
prev_ptr := temp_ptr;
temp_ptr := temp_ptr.nxt;
end if;
end loop;
-- address must be greater than address of
-- last pointer in chain
if(not done )then
new_ptr := new mem_entry;
new_ptr.address := location;
new_ptr.data := data;
--add new_ptr to end of chain
new_ptr.nxt := null;
prev_ptr.nxt := new_ptr;
first.num_entries := first.num_entries + 1;
done := true;
end if;
end if;
--wait for 0 ns;
end wr_data;

procedure rd_data(
constant location: in integer;
variable data : out std_logic_vector;
variable allocated : out boolean;
variable first : inout head_ptr
)is
variable temp_ptr : entry_ptr;
variable is_allocated : boolean;
begin
-- set allocated to true when read hits already
-- allocated spot
is_allocated := false;
if ( first.list_ptr /= null and first.num_entries /= 0 and location >= first.list_ptr.address ) then
temp_ptr := first.list_ptr;
while (temp_ptr /= null and not is_allocated and location >= temp_ptr.address) loop
if temp_ptr.address = location then
-- address has been allocated
data := temp_ptr.data;
is_allocated := true;
else
temp_ptr := temp_ptr.nxt;
end if;
end loop;
end if;
if not is_allocated then
data := (data'range => 'U');
end if;
allocated := is_allocated;
--wait for 0 ns;
end rd_data;
end;

0 Kudos
Historian
Historian
6,385 Views
Registered: ‎02-25-2008

Re: Dynamic memory allocation

is this for synthesis or simulation?

----------------------------Yes, I do this for a living.
0 Kudos
6,383 Views
Registered: ‎04-29-2012

Re: Dynamic memory allocation

This is for simulation
0 Kudos
6,383 Views
Registered: ‎04-29-2012

Re: Dynamic memory allocation

This is for simulation

0 Kudos
Xilinx Employee
Xilinx Employee
6,380 Views
Registered: ‎05-14-2008

Re: Dynamic memory allocation

Can you post the whole error message? And in which process did you encounter this error, synthesis, translate, map or PAR?

Vivian

-------------------------------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------------------------------
如果提供的信息能解决您的问题,请标记为“接受为解决方案”。
如果您认为帖子有帮助,请点击“奖励”。谢谢!
-------------------------------------------------------------------------------------------------
0 Kudos
Teacher rcingham
Teacher
6,374 Views
Registered: ‎09-09-2010

Re: Dynamic memory allocation

"This is for simulation."

Which OS, simulator and version?
Please post the entire message, using copy+paste.

 

Possibly you are trying to allocate more simulation memory than the simulator has access to.

 


------------------------------------------
"If it don't work in simulation, it won't work on the board."
0 Kudos
6,364 Views
Registered: ‎04-29-2012

Re: Dynamic memory allocation

ERROR:HDLParsers:1014 - "C:/Users/kolambks/AppData/Local/Temp/ecs_temp/abc/mem_pkg.vhd" Line 52. Allocators unsupported.
ERROR:HDLParsers:1014 - "C:/Users/kolambks/AppData/Local/Temp/ecs_temp/abc/mem_pkg.vhd" Line 61. Allocators unsupported.
ERROR:HDLParsers:1014 - "C:/Users/kolambks/AppData/Local/Temp/ecs_temp/abc/mem_pkg.vhd" Line 76. Allocators unsupported.
ERROR:HDLParsers:1014 - "C:/Users/kolambks/AppData/Local/Temp/ecs_temp/abc/mem_pkg.vhd" Line 92. Allocators unsupported.

 

Xilinx Design Suite 12.2

 

0 Kudos