Repository navigation
Conversation
Register kept its own address, width, debug flag and access mode in public attributes. A subclass made by create_subclass adds a property per field, so a field with one of those names (HLS IP gets one field per scalar argument, e.g. width) took over the attribute: building the RegisterMap failed with RecursionError, AttributeError or TypeError. Store the state under private names and use those internally. The public names stay available as properties on Register, so plain registers behave as before; on a register with such a field the name now refers to the field. Refs Xilinx#1480 Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I started from #1480. A scalar HLS argument called
widthmakesregister_mapfail withRecursionError. HLS IP exposes each scalar argument as a register with one field of the same name. A field becomes a property on theRegistersubclass, so a field namedwidthreplaced the attribute thatRegister.__init__sets, and the register called its own field setter while it was being built.widthis not the only name affected. On pynq-next I get this with a single-field register:widthRecursionErrorAttributeError: ... has no setteraddressAttributeError: ... no attribute 'width'AttributeError: ... has no setteraccessTypeError: '>' not supported between ... 'str' and 'int'AttributeError: ... has no setterdebugAttributeError: ... no attribute '_buffer'AttributeError: ... has no setterbuffer,countAll of these fail while the
RegisterMapis being built, so the rest of that IP's registers can't be reached either.The change keeps the register's own state in private attributes (
_address,_width,_access,_debug_enabled) and uses those internally, including the sort key inRegisterMap.__repr__.address,width,debugandaccessstay available as properties with setters onRegister, so plain registers and existing code that reads or sets them behave as before. On a register that has a field with one of these names, the name now means the field, which is what the HLS driver in #1480 expects (register_map.width = width).In #1480 a reserved-name check with a clearer error was suggested. I went with making these names work instead.
widthis a natural name for an HLS argument (the IP in #1480 haswidthandheight), and with a check that IP would still have no usableregister_mapuntil the argument is renamed in the HLS source. If you prefer the check, I can change the PR to that.Tests added to
tests/test_registers.py:address,width,debug,access), each read-write and read-only. It reads the field, writes it through the register and through the map, checksreprand writesCTRL.Registersubclass with such a field anddebug=Truestill prints the register address.Registerstill reads and setsaddress,width,debugandaccess. This one passes before and after.How I found it
I was going through open issues in Xilinx repos and picked #1480 because it had a full traceback. I reproduced it with a
RegisterMapbuilt from anip_dictstyle description with an HLSCTRLregister plus one argument register. Then I tried the other attribute names set inRegister.__init__, and alsobufferandcount, to see which names collide.Where this can show up in practice
#1480 is a field report for
widthfrom an HLS IP withwidthandheightarguments, where the driver worked only after renaming them tocolsandrows.address,accessanddebugfail the same way in the code path, but I only know that from the reproduction, not from a user report.Verification (macOS, arm64, Python 3.11)
pytest --doctest-modulesas in CI:pynq/registers.pycoverage stays at 100 %.pynq/registers.pyare the same three as before (E741, E501, W391), all on lines this PR doesn't touch.Not run:
pynq.remote. I only used buffers and the mock devices from the tests.Refs #1480