Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ipxact fix #964

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions submodules/LIB/scripts/ipxact_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,15 @@ def __init__(
if isinstance(max_size, str):
# transform the string into a mathemathical expression and retrieve the maximum value
max_size = max_size.replace(" ", "")
for param in parameters_list:
max_size = max_size.replace(param.name, param.max_value)
max_size = eval(max_size)
while True:
for param in parameters_list:
# only replace complete words
max_size = re.sub(r"\b" + param.name + r"\b", param.max_value , max_size)

# if the string only contains numbers or operators, evaluate it and break the loop
if re.match(r"^[0-9\+\-\*\/\(\)]+$", max_size):
max_size = eval(max_size)
break

# Compute the the size of the register in steps of 8 bits, rounding up
self.sw_size = 8 * math.ceil(max_size / 8)
Expand Down
Loading