pcisim.lib.memory
index
../../src/pcisim/lib/memory.py

A module to manage virtual memory.

 
Classes
       
__builtin__.object
MemoryBlock
NaturalMemoryManager
pcisim.lib.MyException(exceptions.Exception)
NotPowerOfTwo
OutOfMemory

 
class MemoryBlock(__builtin__.object)
    Represents a virtual memory block.
 
@ATTRIBS
    (int) start : block start virtual address
    (int) end : block end virtual address
    (int) size : block virtual size
 
  Methods defined here:
__init__(self, address=0, size=0)
@PARAMS
    (int) address : block start virtual address
    (int) size : block virtual size
 
@NOTES
    self.end address is calculated.
calc_bounds(self)
Calculates self.end address.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class NaturalMemoryManager(__builtin__.object)
    Emulates memory allocation for natural aligned addresses.
 
Allocation algorithms are the following:
    a) Place a new block in first available position
    b) Relocate blocks to tide up space
 
Algorithm b) is only used when free memory is not enough. Note that
if b) fails too, OutOfMemory exception is raised.
 
@ATTRIBS
    (list)(MemoryBlock) blocks : allocated memory blocks
 
  Methods defined here:
__init__(self, memsize)
@PARAMS
    (int) memsize : virtual memory size
alloc(self, blksize)
Request allocation of a MemoryBlock.
 
@PARAMS
    (int) blksize : size of the block to allocate.
 
@RETURN
    (MemoryBlock) allocated block
 
@RAISES
    - OutOfMemory if no memory is available.
    - NotPowerOfTwo if blksize is not naturally aligned.
free(self)
Frees all the allocated memory and destroyes blocks.
get_memfree(self)
Get free virtual memsize.
 
@RETURN
    (int) virtual free memory size
get_memsize(self)
Get total virtual memsize.
 
@RETURN
    (int) virtual memory size
get_relocated(self)
Get last relocated blocks.
 
@RETURN
    (MemoryBlock)(listiterator) relocated blocks.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class NotPowerOfTwo(pcisim.lib.MyException)
    Indicates that given value is not a power of 2 base.
 
@ATTRIBS
    (int) value : subject value
 
 
Method resolution order:
NotPowerOfTwo
pcisim.lib.MyException
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, value)
@PARAMS
    (int) value : subject value
__str__(self)
validate(self)
This function validates the value.
 
If value is ok, no exception is raised.
 
@RAISES
    NotPowerOfTwo if validation fails.

Data descriptors inherited from pcisim.lib.MyException:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class OutOfMemory(pcisim.lib.MyException)
    Indicates that a memory manager has no free memory available.
 
@ATTRIBS
    (NaturalMemoryManager) manager : subjct memory manager.
 
 
Method resolution order:
OutOfMemory
pcisim.lib.MyException
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, manager)
@PARAMS
    (NaturalMemoryManager) manager : subjct memory manager.
__str__(self)

Data descriptors inherited from pcisim.lib.MyException:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
Data
        __all__ = ['NaturalMemoryManager', 'MemoryBlock', 'NotPowerOfTwo', 'OutOfMemory']