- 
                Notifications
    
You must be signed in to change notification settings  - Fork 996
 
pyosys: fix a number of regressions from 0.58 #5441
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
Conversation
| 
           Would like to ping @jix and @georgerennie on this one as well  | 
    
- consistently use value semantics for objects passed along FFI boundary (not ideal but matches previous behavior) - add new overload of RTLIL::Module: addMemory that does not require a "donor" object - the idea is `Module`, `Memory`, `Wire`, `Cell` and `Process` cannot be directly constructed in Python and can only be added to the existing memory hierarchy in `Design` using the `add` methods - `Memory` requiring a donor object was the odd one out here - fix superclass member wrapping only looking at direct superclass for inheritance instead of recursively checking superclasses - fix superclass member wrapping not using superclass's denylists - fix Design's `__str__` function not returning a string - fix the generator crashing if there's any `std::function` in a header - misc: add a crude `__repr__` based on `__str__`
| 
           I decided to go with value semantics for now. The reason is this was the ≤0.58 behavior and I think any change requires more thought and JF approval: # 0.58
d = ys.Design()
class Monitor(ys.Monitor):
	def __init__(self):
		super().__init__()
		self.mods = []
	def py_notify_module_add(self, mod):
		self.mods.append(mod.name.str())
m = Monitor()
d.monitors.append(m)
print(d.monitors) # []Python really has no strategyy for L-values unless the codebase is already built like Python, i.e., shared pointers all around. In the latter case you can just plug into Python's refcounting, but for values it would actually stores a pointer to the area of memory where the value is. With containers that's particularly bad because you won't even notice a memory issue, you might get an entirely new valid value and spend 6 hours debugging what the heck happened. Hypothetically speaking of course. I can do something a bit more bespoke but for now I'll err on the side of not breaking existing code.  | 
    
| return cell; | ||
| } | ||
| 
               | 
          ||
| RTLIL::Memory *RTLIL::Module::addMemory(RTLIL::IdString name) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with adding this method
What are the reasons/motivation for this change?
Explain how this is achieved.
a.b.append(x)mutates a copy ofa.b. but this was the previous behavior.Module,Memory,Wire,CellandProcesscannot be directly constructed in Python and can only be added to the existing memory hierarchy inDesignusing theaddmethods -Memoryrequiring a donor object was the odd one out here__str__function not returning a stringstd::functionin a header__repr__based on__str__Make sure your change comes with tests. If not possible, share how a reviewer might evaluate it.
With a Yosys compiled with ENABLE_PYTHON,
python3 ./tests/pyosys/run_tests.py yosys