pylab_ml.misc.registermaster.Register
- class Register(cpuaddr, addr, bank=0, name='', slices={}, description='', rm=None)[source]
Bases:
object- __init__(cpuaddr, addr, bank=0, name='', slices={}, description='', rm=None)[source]
Initialize the Register object with the given parameters and set up the necessary attributes.
- Parameters:
cpuaddr (int) – The CPU address of the register.
addr (int) – The address of the register.
bank (int, optional) – The bank address of the register (default is 0).
name (str, optional) – The name of the register (default is “”).
slices (dict, optional) – The bit-slices of the register (default is {}).
description (str, optional) – The description of the register (default is “”).
rm (RegisterMaster, optional) – The RegisterMaster instance (default is None).
Methods
__init__(cpuaddr, addr[, bank, name, ...])Initialize the Register object with the given parameters and set up the necessary attributes.
read([compare, onlycheck, tolerance, mask])Read from the Register with selected protocol.
res()Get the reset value of the register by checking the reset values of all bit-slices defined in the register master excel file.
write([value])Write to the Register with selected protocol.
writebase(bank)Write the bank address to the interface if the current bank is different from the given bank or if the forcebank flag is set.
Attributes
Returns the register address
Print the documentation for the register.
Bit-slice over full register,shadow register, read/write the true regiser only if None
Get the binary representation of the register value.
Generate a table of the bit-slices of the register, including their names, directions, values in decimal, hexadecimal, and binary formats, and reset values.
- property addr
Returns the register address
- Returns:
The address of the register to access, determined by the current protocol type and the defined addresses in the register master excel file.
- Return type:
int
- property help
Print the documentation for the register.
- read(compare=None, onlycheck=True, tolerance=0, mask=None)[source]
Read from the Register with selected protocol.
- Parameters:
compare (int or None) – compare value, if None than no compare
onlycheck (bool) – True (default) result is the compare value 0 or 1 False result is compare value and the read value
tolerance (int) – tolerance for compare, default is 0
mask (int or None) – mask for compare, default is None (no mask)
- Returns:
error (int) – 0 if compare is successful, 1 if compare fails, or the value read from the register if onlycheck is False.
value (int) – The value read from the register (only returned if onlycheck is False).
-1 (int) – If the protocol is not defined or if there is an error while reading from the hardware.
- res()[source]
Get the reset value of the register by checking the reset values of all bit-slices defined in the register master excel file.
- Returns:
valres – The reset value of the register if all bit-slices have a defined reset value, or a string indicating that the reset value is not defined if any bit-slice does not have a defined reset value.
- Return type:
int or str
- property value
Bit-slice over full register,shadow register, read/write the true regiser only if None
- Returns:
value – The value of the register, either from the cache or by reading from the hardware if the cache is empty and the register is in atomic mode.
- Return type:
int
- property value_bin
Get the binary representation of the register value.
eg. for a 16-bit register with value 0xABCD, the binary representation would be “1010 1011 1100 1101”.
- Returns:
Binary representation of the register value, grouped in 4-bit segments.
- Return type:
str
- property value_table
Generate a table of the bit-slices of the register, including their names, directions, values in decimal, hexadecimal, and binary formats, and reset values.
- Returns:
df – A DataFrame containing the bit-slice information for the register, with columns for location, name, direction, decimal value, hexadecimal value, binary value, and reset value.
- Return type:
pandas.DataFrame
- write(value=None)[source]
Write to the Register with selected protocol.
- Parameters:
value (int or None) – The value to write to the register. If None, the method will attempt to write the cached value of the register.
- Returns:
result – The result of the write operation. Returns -1 if the protocol is not defined.
- Return type:
int