On Wed, May 29, 2019 at 4:51 PM Ricky Teachey
Another approach is to abandon the idea of HDL namespace parent class, and just create a HDL (or hdl) decorator:
@hdl # decorator adds a custom __setattr__ class C: ...
The decorator would modify the __setatrr__ method of the class so that members of the class have signal behavior. You could even write the decorator so that you specify which attributes have signal behavior, and the remainders don't:
@hdl(list('xyz')) class C: def __init__(self, **kwargs): for k,v in kwargs.items(): setattr(self, k, v)
c = C(x=1, a=2) # x is a signal, a is not
hmmm ... this is clever to restrict what is a signal and what is not. I like the class inheritance better in this case, as it is easier and one less feature to learn for average hardware engineers. I do completely understand why software engineer likes this approach, you just add one line and the class behavior can be modified without needing to modify anything of the class itself, especially when it already has a non-empty inheritance list.