Python abstraction layer for registerfile access
Project description
regfile_generics
Installation
From PyPI
python3 -m pip install --upgrade regfile-generics
From source
git clone https://github.com/icglue/regfile_generics
cd regfile_generics
python3 -m pip install .
Usage
Setup Regfile and Regfile Device for Access
See tests/fixtures.py how to create a regfile by deriving from the Regfile class. Implement read/write functions and pass them (or overwrite while deriving) to an adequate RegfileDevice class.
Accessing Registers
# dict like:
regfile["reg1_high"] = {"cfg": 0x0AA, "cfg_trigger": 0x0, "cfg_trigger_mode": 0x0}
# or single field (might issue read-modify-write)
regfile["reg1_high"]["cfg"] = 0xB
# uvm like (register have a _r suffix, field a _f suffix to avoid collisions):
regfile.reg1_high_r.cfg_f.set(2)
regfile.reg1_high_r.update()
# write_update
regfile["reg1_high"].write_update(cfg=0xA, cfg_trigger_mode=1)
# read (can be int or dict or string context)
print(regfile["reg1_high"])
assert (
str(regfile["reg1_high"])
== "Register reg1_high: {'cfg': 0xa, 'cfg_trigger': 0x0, 'cfg_trigger_mode': 0x1} = 0x1000a"
)
assert regfile["reg1_high"] == 0x1000A
assert dict(regfile["reg1_high"]) == {"cfg": 10, "cfg_trigger": 0, "cfg_trigger_mode": 1}
# read entire entry to a variable, so that no further read/write request will be issued
rh1 = regfile["reg1_high"].read_entry()
print(f"cfg: {rh1['cfg']}")
print(f"trigger: {rh1['cfg_trigger']}")
print(f"mode: {rh1['cfg_trigger_mode']}")
# bool access
regfile["reg1_high"] = 0
if regfile["reg1_high"]:
assert False
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for regfile_generics-0.2.0.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 838c746623f5083e78da5894544ddf41ccabfcc90cd2aea9faf04aab1cfb2a30 |
|
MD5 | da6848d0020164460d57b5d56d275387 |
|
BLAKE2b-256 | 0dde4597cb29506142b7ca622cd4e1bffc907c5f0531b309ebdb56b3678fee3c |
Close
Hashes for regfile_generics-0.2.0.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccd4e56860bd3303e8074e4aab4a6d85b155b4b4e94417f84d0e1f3ff63688d9 |
|
MD5 | 79692eb0b51a8ffecef3615b8f575b67 |
|
BLAKE2b-256 | 697a80804ed3b230ac4928c1a7dcbd097d487d54b5dcdf4f88f7b8973d7bfdd6 |