|
Message
From: Gunnar Dahlgren<gunnar.dahlgren@a...>
Date: Thu Mar 18 14:03:24 CET 2004
Subject: [oc] "malloc" and "free" implementation in Verilog
In case the original issue was regarding Verilog for modelling in general, this answer might be useful: You can't. Verilog doesn't have dynamic memory handling built into the language.
However, you can use the powerful PLI interface to call functions written in C, including functions using dynamic memory handling. Of course, this will not be synthesisable in any way, but it is fine for simulation.
I don't have any reference to code using the PLI laying around, but the Verilog Language Reference Manual should contain most of the stuff you need. It used to be available on the net, but from a quick search I couldn't find it anymore... The filenames are ovi.verilog.lrm.1.0.pdf and ovi.pli.1.0.pdf if that is of any help. They can be ordered from the IEEE, www.ieee.org anyway, but probably at a cost. Maybe someone else has a good pointer? :)
Regards Gunnar Dahlgren
At 13:33 2004-03-18 +0100, Joachim Strombergson wrote: >Aloha! > >Quoting abhi_vlsi02@y...: >> How to implement dynamic memory allocatuion using Verilog? > >What do you mean with dynamic mem allocation with respect to hardware >implementation? What is the application/purpose? > >Is it cache memory, hw-acceleration of an OS or? > >> Where can I get the Verilog code for dynamic memory allocation? >> Can anybody give some pointers to some code! > >I might be wrong, but I don't think there are that many examples of malloc-type >implementations in hardware. What you can do is look at processors that >implement TLB-support, which normally contains tables/bits to keep track of >allocated pages and some sort of control mechanism (i.e. a FSM) to check >requested addresses with the allocated pages. > >A malloc is similar, the difference mainly being: >(1) You allocate a requested *number* of pages and hand back the address, not >check the address agains allocated pages. > >(2) You need to handle fragmentation somehow. This is because when you then get >free() calls you will end upp with free pages scattered in between allocated >pages. The discrete knapsack problem will then unsure that you will not be able >to allocate all free space in a given free area, thus leaving more and more >single empty pages in between the allocated ones. Basic mem allocation >problem. > >There are possibly opportunities to handle pointer matching, mem fill, mem copy >operations in HW thereby gaining CPU performance, and some CPUs do this, but >have never seen a complete, full blown malloc() in HW. > >Anybody else on the OC-list with different experience? > >-- >Med vänlig hälsning, Yours > >Joachim Strömbergson - Alltid i harmonisk svängning. >VP, Research & Development >---------------------------------------------------------------------- >InformAsic AB / Hugo Grauers gata 5B / SE-411 33 GÖTEBORG / Sweden >Tel: +46 31 68 54 90 Fax: +46 31 68 54 91 Mobile: +46 733 75 97 02 >E-mail: joachim.strombergson@i... Home: www.informasic.com >---------------------------------------------------------------------- > >_______________________________________________ >http://www.opencores.org/mailman/listinfo/cores >
|
 |