-
Notifications
You must be signed in to change notification settings - Fork 70
Python Model Output
Ordt supports generation of a python model of the register space using the -pydrvmod command line option. Functionally the model structure is similar to the C++ driver model and provides an api to convert a register path string into an address as well as support for merging multiple versions of a register space into a single model using the -overlay command line option. Unlike the current C++ model, the python model also provides an api for converting an address back into it's corresponding path.
Note: this page reflects code in version 181009.01
Python output can be generated by running the following ordt command...
ordt -pydrvmod output.py file.rdl
Or input multiple files can be added to the model using following ordt command (see here for more info)...
ordt -pydrvmod output.py -overlay v2 file2.rdl file1.rdl
The model can then be accessed as follows...
>>> import output as mod
>>> a = mod.ordt_drv_root()
>>> a.get_tags()
['foo']
>>> path = "foo.bar.a_reg[1]"
>>> a.get_address("foo", path)
{'status': 'reg', 'address': 4, 'fields': [ .. output.ordt_drv_field objects ..]}
>>> a.get_address("fool", path)
--> invalid tag: fool
{'status': 'bad tag'}
>>> path = "foo.bar"
>>> a.get_address("foo", path)
{'status': 'reg set', 'address': 0, 'children': ['a_reg']}
>>> path = "foo.bar.somereg"
>>> a.get_address("foo", path)
--> unable to find child somereg in regset bar
{'status': 'bad path'}
>>> path = "foo.bar.a_reg[1]"
>>> output = a.get_address("foo", path)
>>> len(output["fields"])
3
>>> for field in output["fields"]:
... print(field.name, field.loidx, field.width)
...
fld1 0 10
fld2 15 1
ERR25 25 1
>>> a.get_path("foo", 0x4)
{'status': 'reg', 'path': 'foo.bar.a_reg[1]'}
Home
Running Ordt
Building Ordt from source
Running Ordt Tests
Source contributions
Ordt Inputs
Ordt Outputs