You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The SystemRDL compiler always checks if VALUE fits in WIDTH in the following construction: field {...} F[WIDTH] = VALUE.
However, this validation code crashes if WIDTH is too large.
For example, compiling the following code crashes the compiler (I compile with peakrdl dump main.rdl)
addrmap name {
reg {
field { } f[-1] = 1; // Here -1 becomes 18446744073709551614 according to the SystemRDL Spec
} R;
};
Error:
Traceback (most recent call last):
File "...", line 8, in <module>
sys.exit(main())
File ".../venv/lib/python3.8/site-packages/peakrdl/main.py", line 183, in main
options.subcommand.main(importers, options)
File ".../venv/lib/python3.8/site-packages/peakrdl/subcommand.py", line 151, in main
top = process_input.elaborate(rdlc, parameters, options)
File ".../venv/lib/python3.8/site-packages/peakrdl/process_input.py", line 145, in elaborate
root = rdlc.elaborate(
File ".../venv/lib/python3.8/site-packages/systemrdl/compiler.py", line 421, in elaborate
walker.RDLWalker(skip_not_present=True).walk(root_node, ValidateListener(self.env))
File ".../venv/lib/python3.8/site-packages/systemrdl/walker.py", line 159, in walk
self.walk(child, *listeners)
File ".../venv/lib/python3.8/site-packages/systemrdl/walker.py", line 159, in walk
self.walk(child, *listeners)
File ".../venv/lib/python3.8/site-packages/systemrdl/walker.py", line 159, in walk
self.walk(child, *listeners)
File ".../venv/lib/python3.8/site-packages/systemrdl/walker.py", line 150, in walk
self.current_action = self.do_enter(node, listener)
File ".../venv/lib/python3.8/site-packages/systemrdl/walker.py", line 176, in do_enter
action = listener.enter_Component(node) or WalkerAction.Continue
File ".../venv/lib/python3.8/site-packages/systemrdl/core/validate.py", line 44, in enter_Component
prop_rule.validate(node, prop_value)
File ".../venv/lib/python3.8/site-packages/systemrdl/properties/builtin.py", line 436, in validate
if value >= (1 << node.width):
MemoryError
Version systemrdl-compiler==1.27.3
Expected behavior
I expect the tool to not crash :)
It is possible to check if VALUE fits in WIDTH using logarithms instead of 1 << node.width. Maybe it will fix this issue
The text was updated successfully, but these errors were encountered:
Describe the bug
The SystemRDL compiler always checks if
VALUE
fits inWIDTH
in the following construction:field {...} F[WIDTH] = VALUE
.However, this validation code crashes if
WIDTH
is too large.For example, compiling the following code crashes the compiler (I compile with
peakrdl dump main.rdl
)Error:
Version
systemrdl-compiler==1.27.3
Expected behavior
I expect the tool to not crash :)
It is possible to check if
VALUE
fits inWIDTH
using logarithms instead of1 << node.width
. Maybe it will fix this issueThe text was updated successfully, but these errors were encountered: