[myhdl-list] Re: Style based on decorators
Brought to you by:
jandecaluwe
From: Jan D. <ja...@ja...> - 2005-12-02 09:52:13
|
Matt Ettus wrote: > I don't see the advantage of pushing everyone towards the decorators. > Am I correct in my understanding that complex cases may still need the > old syntax? Generators are the raw material in MyHDL. They can have arguments, and they can even be used dynamically in yield statements (anyone ever tried that already?) For such cases (and all others, if you want) the general syntax is and will always be available. However, there is an overwhelmingly popular usage pattern: a local generator function, embedded in a classic function that defines an interface and structure. Such a generator function has rather special characteristics. It is not intended to be reusable. Therefore, it doesn't have parameters. We don't need its name, only its code. It is intended to be called exactly once, to create a generator. It is that clearly defined and very popular pattern that decorators target. Within this pattern, there is always a decorator available, no matter how complex the generator function. This is because the @instance decorator is the catch-all decorator. All decorators create the generator and reuse the name automatically. This means that they automate the single meaningful way to use the generator function, and their presence explicitly signals this. Important advantages, I believe. > Also, I love Python and understand the desire to be Pythonic, but making > things as different as possible from preexisting HDLs doesn't seem to > buy anything but a steep learning curve. I don't think you can argue that the decorators make things "as different as possible". On the contrary I would say, although this is not a design goal either. In fact, there is a close correspondence with certain Verilog statements: @instance <-> initial @always <=> always @always_comb <=> always_comb I guess this may make MyHDL code with decorators easier to understand by users of other HDLs. Regards, Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Losbergenlaan 16, B-3010 Leuven, Belgium From Python to silicon: http://myhdl.jandecaluwe.com |