uvm_mem_mam——寄存器模型(十三)

有了存储器模型,再来看看存储器的管理

//------------------------------------------------------------------------------
//
// Title: Memory Allocation Manager
//
// Manages the exclusive allocation of consecutive memory locations
// called ~regions~.
// The regions can subsequently be accessed like little memories of
// their own, without knowing in which memory or offset they are
// actually located.
//
// The memory allocation manager should be used by any
// application-level process
// that requires reserved space in the memory,
// such as DMA buffers.
//
// A region will remain reserved until it is explicitly released. 
//
//------------------------------------------------------------------------------


`ifndef UVM_MEM_MAM__SV
`define UVM_MEM_MAM__SV


typedef class uvm_mem_mam_cfg;
typedef class uvm_mem_region;
typedef class uvm_mem_mam_policy;

typedef class uvm_mem;


//------------------------------------------------------------------------------
// CLASS: uvm_mem_mam
//------------------------------------------------------------------------------
// Memory allocation manager
//
// Memory allocation management utility class similar to C's malloc()
// and free().
// A single instance of this class is used to manage a single,
// contiguous address space.
//------------------------------------------------------------------------------

class uvm_mem_mam;

   //----------------------
   // Group: Initialization
   //----------------------

   // Type: alloc_mode_e
   //
   // Memory allocation mode
   //
   // Specifies how to allocate a memory region
   //
   // GREEDY   - Consume new, previously unallocated memory
   // THRIFTY  - Reused previously released memory as much as possible (not yet implemented)
   //
   typedef enum {GREEDY, THRIFTY} alloc_mode_e;


   // Type: locality_e
   //
   // Location of memory regions
   //
   // Specifies where to locate new memory regions
   //
   // BROAD    - Locate new regions randomly throughout the address space
   // NEARBY   - Locate new regions adjacent to existing regions
   
   typedef enum {BROAD, NEARBY}   locality_e;



   // Variable: default_alloc
   //
   // Region allocation policy
   //
   // This object is repeatedly randomized when allocating new regions.
   uvm_mem_mam_policy default_alloc;


   local uvm_mem memory;
   local uvm_mem_mam_cfg cfg;
   local uvm_mem_region in_use[$];
   local int for_each_idx = -1;
   local string fname;
   local int lineno;

 

posted on 2017-12-11 22:14  dpc525  阅读(1034)  评论(0编辑  收藏  举报

导航