regfile_generics.regfile_device
Generic Devices on which a regfile can operate.
Classes
Regfile Device class that handels the access of a Regfile |
|
RegfileDev that operates on words only (implements read-modify-write if necessary) |
|
Debug implementation of |
|
RegfileDev that operates on word sizes (implements read-modify-write if this) |
|
Debug implementation of |
|
Forwards regfile operations to a function call with string command, |
|
Forwards regfile operations to a function call with string command, |
Functions
|
Function to get bits for RegfileDebug* classes |
Module Contents
- class regfile_generics.regfile_device.RegfileDev(callback=None, bytes_per_word=4, logger=None, prefix='', **kwargs)
Regfile Device class that handels the access of a Regfile
- Parameters:
callback (Optional[dict[str, Callable]]) – dict with rfdev_read/rfdev_write/blockread/blockwrite pointing to a register read/write function
bytes_per_word (int) – bytes per word a single register access can handle (default 4)
logger (Optional[logging.Logger]) – logger instance
prefix (str) – prefix for (debug) logging with the logger instance
Deprecated since version 0.2.0:
- key blockread:
reference to a blockread function, use callback dict instead
- key blockwrite:
reference to a blockwrite function, use callback dict instead
- logger = None
- callback
- property n_word_bytes: int
Returs the number of bytes per word the device handles on one operation.
- Return type:
int
- blockread(start_addr, size)
Initiate a blockread used for
- Parameters:
start_addr (int) – start address of read data
size (int) – number of words to be read
- Return type:
list[int]
- blockwrite(start_addr, values)
Initiate a blockwrite used for memory access :param start_addr: start address of write data :param value: word list to be written
- Parameters:
start_addr (int)
values (tuple[int, Ellipsis])
- Return type:
None
- rfdev_read(addr)
Read method calling rfdev_read of callback dict passed upon init - could be overridden, when deriving a new RegfileDev
- Parameters:
addr (int)
- Return type:
int
- read(baseaddr, entry)
Read a register entry relative to a base address
- Parameters:
baseaddr (int) – Base address of the Register File
entry (regfile_generics.regfile.RegfileEntry) – A register entry
- Return type:
int
- rfdev_write(addr, value, mask, write_mask)
Read method could be overridden when deriving a new RegfileDev default implementation is to call the function passed while initialization, through the value of the “rfdev_write”-key of the callback dictionary.
- Parameters:
addr (int) – Absolute Address to be accessed for write
value (int) – Value to be written
mask (int) – Mask for the write operation to the register
write_mask (int) – Mask of writeable bits inside the register (e.g. to determine if read-modify-write is necessary)
- Return type:
None
- write(baseaddr, entry, value, mask)
Read a register entry relative to a base address
- Parameters:
baseaddr (int) – Base address of the Register File
entry (regfile_generics.regfile.RegfileEntry) – A register entry
value (int) – register value
mask (int) – mask for the operation
- Return type:
None
- readwrite_block(start_addr, values, write)
Deprecated since version 0.2.0.
Use
blockread()orblockwrite()instead.
- class regfile_generics.regfile_device.RegfileDevSimple(callback=None, bytes_per_word=4, logger=None, prefix='', **kwargs)
Bases:
RegfileDevRegfileDev that operates on words only (implements read-modify-write if necessary)
Derived from
RegfileDevAllowed callback entries:
- key rfdev_read:
read function (signature
RegfileDev.rfdev_read())- key rfdev_write_simple:
write function which has the same signature like
rfdev_write_simple()
- Parameters:
callback (Optional[dict[str, Callable]])
bytes_per_word (int)
logger (Optional[logging.Logger])
prefix (str)
- rfdev_write_simple(addr, value)
Simple write operation - calls back rfdev_write_simple if passed to constructor.
- Parameters:
addr (int) – absolute address for write operation
value (int) – value to write
- Return type:
None
- rfdev_write(addr, value, mask, write_mask)
RegfileDevrfdev_write implementations - executes the read-modify-write if necessary- Parameters:
addr (int) – absolute Address to be accessed for write
value (int) – value to be written
mask (int) – mask for the write operation to the register
write_mask (int) – mask of writeable bits inside the register
- Return type:
None
- regfile_generics.regfile_device.regfile_dev_debug_getbits(interactive, default_value, promptprefix)
Function to get bits for RegfileDebug* classes
- Parameters:
interactive (bool)
default_value (int)
promptprefix (str)
- Return type:
int
- class regfile_generics.regfile_device.RegfileDevSimpleDebug(interactive=False, **kwargs)
Bases:
RegfileDevSimpleDebug implementation of
RegfileDevSimple- Parameters:
interactive (bool) – if set to
Truethe regfile device will request a user input upon read.
- mem: dict[int, int]
- write_count = 0
- read_count = 0
- rfdev_read(addr)
Debug read function interactive if necessary
- Param:
addr address
- Parameters:
addr (int)
- Return type:
int
- rfdev_write_simple(addr, value)
Debug write function to mem attribute.
- Parameters:
addr (int) – absolute address for write operation
value (int) – value to write
- Return type:
None
- getvalue(addr)
Get value out of the memory, randomize if necessary.
- Parameters:
addr (int) – address to be read
- Return type:
int
- class regfile_generics.regfile_device.RegfileDevSubword(callback=None, bytes_per_word=4, logger=None, prefix='', **kwargs)
Bases:
RegfileDevRegfileDev that operates on word sizes (implements read-modify-write if this)
Derived from
RegfileDevAllowed callback entries:
- key rfdev_read:
read function (signature
RegfileDev.rfdev_read())- key rfdev_write_simple:
write function which has the same signature like
rfdev_write_simple()
- Parameters:
callback (Optional[dict[str, Callable]])
bytes_per_word (int)
logger (Optional[logging.Logger])
prefix (str)
- rfdev_write(addr, value, mask, write_mask)
Read method could be overridden when deriving a new RegfileDev default implementation is to call the function passed while initialization, through the value of the “rfdev_write”-key of the callback dictionary.
- Parameters:
addr (int) – Absolute Address to be accessed for write
value (int) – Value to be written
mask (int) – Mask for the write operation to the register
write_mask (int) – Mask of writeable bits inside the register (e.g. to determine if read-modify-write is necessary)
- Return type:
None
- rfdev_write_subword(addr, value, size)
Word size write operation - calls back rfdev_write_subword if passed to constructor.
- Parameters:
addr (int) – absolute address for write operation (lower address bit indicate word position)
value (int) – value to write
size (int) – number of bytes to write
- Return type:
None
- class regfile_generics.regfile_device.RegfileDevSubwordDebug(interactive=False, **kwargs)
Bases:
RegfileDevSubwordDebug implementation of
RegfileDevSimple- Parameters:
interactive (bool) – if set to
Truethe regfile device will request a user input upon read.
- mem: dict[int, int]
- write_count = 0
- read_count = 0
- getvalue(addr)
Return memory value
- Parameters:
addr (int) – address were the data will be read
- Return type:
int
- rfdev_read(addr)
Debug read function interactive if necessary
- Param:
addr address
- Parameters:
addr (int)
- Return type:
int
- rfdev_write_subword(addr, value, size)
Word size write operation - calls back rfdev_write_subword if passed to constructor.
- Parameters:
addr (int) – absolute address for write operation (lower address bit indicate word position)
value (int) – value to write
size (int) – number of bytes to write
- Return type:
None
- class regfile_generics.regfile_device.StringCmdRegfileDevSimple(execute=None, **kwargs)
Bases:
RegfileDevSimpleForwards regfile operations to a function call with string command, to do the regfile operations.
- Read:
- r<NUMBITS> <address>
e.g. r32 0x1C
- Write:
- w<NUMBITS> <address> <value>
e.g. w32 0x80 0xF9852A
- Parameters:
execute (Optional[Callable[[str], Optional[str]]])
- execute = None
- class regfile_generics.regfile_device.StringCmdRegfileDevSubword(**kwargs)
Bases:
RegfileDevSubwordForwards regfile operations to a function call with string command, to do the regfile operations.
- Read:
- r<NUMBITS> <address>
e.g. r32 0x1C
- Write:
- w<NUMBITS> <address> <value> [bsel]
- e.g. w32 0x80 0xF9852A
w32 0x80 0xF9852A 0x1
- execute
- rfdev_read(addr)
Read method calling rfdev_read of callback dict passed upon init - could be overridden, when deriving a new RegfileDev
- Parameters:
addr (int)
- Return type:
int
- rfdev_write_subword(addr, value, size)
Word size write operation - calls back rfdev_write_subword if passed to constructor.
- Parameters:
addr (int) – absolute address for write operation (lower address bit indicate word position)
value (int) – value to write
size (int) – number of bytes to write
- Return type:
None