Skip to content

Commit

Permalink
Add more ifs to cocotb_handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekcyjna committed Mar 6, 2024
1 parent 01d54f4 commit 32974c1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/regression/cocotb.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,20 @@ def get_cocotb_handle(self, path_components: list[str]) -> ModifiableObject:
obj = self.dut
# Skip the first component, as it is already referenced in "self.dut"
for component in path_components[1:]:
# As the component may start with '_' character, we need to use '_id'
# function instead of 'getattr' - this is required by cocotb.
obj = obj._id(component, extended=False)
try:
# As the component may start with '_' character, we need to use '_id'
# function instead of 'getattr' - this is required by cocotb.
obj = obj._id(component, extended=False)
except AttributeError:
if component[0] == "\\" and component[-1] == " ":
# workaround for cocotb/verilator weirdness
# for some escaped names lookup fails, but works when unescaped
obj = obj._id(component[1:-1], extended=False)
elif component[0] != "\\" and component[-1] != " ":
# wrokaround for different name generation on different yosys versions
obj = obj._id("\\" + component + " ", extended=False)
else:
raise

return obj

Expand Down

0 comments on commit 32974c1

Please sign in to comment.