On Fri, May 24, 2019 at 3:45 PM Ricky Teachey
Another idea if you really want to be able to do `foo = 5` and have it behave the way you want:
Create a custom dictionary type to hold locals() (and perhaps globals() if needed). Unless I'm wrong, that dict type can pretty much do whatever you want, including overriding assignment behavior. Then just run the code using exec(), passing the custom hdl_locals().
You could package up a custom python interpreter for hardware programming which simply execs() the python code using this customized assignment behavior provided by hdl_locals(). Such a customized namespace is a very pythonic approach, and if I understand correctly, most regular non hdl python would probably be able to run.
I am not sure I understand this ... could you give me a short example? The thing is, it need to work at arbitrary closures, not just the __main__, and you would like to import a hardware module just like you import a python module. If there is a one single thing that is not really python native, I feel it kind of defeated the purpose of creating a Python HDL in the first place. (and execs() are scary too ...)