Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

using linked list in vhdl

Status
Not open for further replies.

vaisram

Member level 1
Joined
Dec 2, 2010
Messages
32
Helped
6
Reputation
12
Reaction score
5
Trophy points
1,288
Activity points
1,469
i need to read a file containing 3000000 (30 million) values and pass it to the DUT one at a time with a valid.. Is it possible to create linked lists in VHDL, read the file at zero time and load all the values into it? If the answer is yes, then how do i do it? Or is there any other method to do it?
 

Which memory device is intended to store the data? No programmable logic device has sufficient memory capacity, so you have to provide external memory. The list has to be read sequentially at runtime.
 

could you provide a few more details on this??? im groping in the dark.. the huge data is slowing down my vcs simulation..
 

Reviewing your post, I understand that your referring to a simulation problem. Perhaps it should be stated more clearly. I think, handling a large amount of date will slow down the simulation anyway. I'm not sure, if you'll possible run into a memory size limitation of simulation variables, but having multiple Megabyte of data isn't unusual in memory controller simulation.

I don't yet understand the purpose of the linked list. The standard method would be to read a sequential stimulus signal from a file when needed, you don't even require an intermediate storage for it. Or is it the case, that the stimulus data has to be replayed in a random sequence? Then a storage would be necessary. But it's simply an array in the test bench.
 

Yes you can use linked lists, but you would usually use them for data sets that grow dynamically rather than an existing array. If it is a huge data set you need to read in one go, your only option is an array. Linked lists are used to save memory, but can improve performance.

Can you not read the data from the file as it is required?

here is an example of linked lists taken from my doulos VHDL guide:

Code:
type Item;
type link is access Item; --pointer to item

type Item is record
  data : integer;
  nextItem : link;
end record;

......
varaible StartOfList, Ptr : link;  --initialise to null

.....
Ptr := new Item;
Ptr.data := 1982719;
Ptr.NextItem := StartOfList;  --link item into list
StartOfList := Ptr; 

.......

--To delete the list
while StartOfList /= null loop
  Ptr := StartOfList.NextItem;
  DEALLOCATE(StartOfList);
  StartOfList := Ptr;
end loop;

But if you load the entire list it will use more memory than a single array, but performance might be improved over a large memory (but you will probably lose that performance as you search through the list)

If what you want is a sparce memory model, I have created one previously using protected types and pointers. You dynamically create a block of ram as it is written to. So if you had a 4GB address space, you dont tie up your entire system ram with an array you hardly ever access.
 
i need the linked list because there are multiple files that i will be reading and each file size is huge.. once i have read a data, i want to free up the memory space by de-allocating the linked list.. in this way, my simulation will also be fast as i will be using hte system memory instead of secondary storage and i will also save the system memory space for the new data..

---------- Post added at 14:51 ---------- Previous post was at 14:49 ----------

One more point i want to mention here is, i dont want to use an array data structure as it is a static memory.. so it will definitely eat up my memory space.. linked list has an option of dynamic memory allocation which is why im trying to implement using this..

---------- Post added at 15:01 ---------- Previous post was at 14:51 ----------

let me give more details on what im actually doing so that it will give u a better idea..

the RTL will write something like 180 files each containing 24million values .. another module in the RTL will read these files one by one and process.. the read will be in chunks of 6 files.. so what i intend to do is create 6 independent linked lists which will store the 24 million values each and then pass on these values to the other RTL module whenever there is a read request.. i will de-allocate the linked list when the read is done so that i can create a new one whenever there is a new write.. hope this information is sufficient for you to understand and help me out.. kindly let me know if u need more clarifications..
 

I have given you the basic outline of a linked list above. You will need to create everything using access types. An access type is a pointer to any other type. You declare them link this:

type my_ptr_t is access some_other_type;

You can then put these pointers inside record types to create linked lists. Objects are created with the new keyword:

variable ptr : my_ptr_t; --pointers MUST be variables. This is the same as "int *var" in c
...
ptr := new some_other_type;

you can dereference pointers using the .all field on a pointer (the same as *var in C):

my_var := ptr.all;

Pointers in VHDL are limited because you cannot get the address of anything (there is no equivalent of the & in C). You can only create pointer with the new keyword and copy them into functions/procedures.

So if you can cope with these restrictions, have a go at what you want. But I doubt many people here have ever done what you are attempting. I can try and help but I have never done it.
 
Your assumption, that linked lists are an effective solution for the said simulation problem has some prerequisites in simulator operation methods and performance. I'm not sure, if they are validated. I fear, that some operations can't be effectively performed in VHDL. They would rather call for supplementary concepts, e.g. VHPI interfaces, that allow to move the huge data processing effort to an external C application. No idea, if your simulator can support something like that.
 

hi FvM.. im using VCS simulator and i think it does support VHPI interfaces.. but the requirements in the project are such that i need to do it only using vhdl and nothing else..
 

Another question I have is why are you writing a file in one module then opening it again in another? usually it is simpler just to pass the data between the two modules using some behavioural interface (often using the 'transaction attribute to discover when data is ready). This will probably save a decent overhead on the processing time.
 

i need a file write here because only after the entire write is complete by one module, the other module starts the read.. i tried a sample code for the linked list with the help you provided.. it worked fine :) .. thanks for your help .. now i shud expand on it..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top