[myhdl-list] Would you ...
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2012-09-25 15:45:54
|
use function attributes instead of named arguments for a MyHDL module configuration? Not sure if this would be a good idea or not. Example: def mymodule(clock, reset, a, b, c): if hasattr(mymodule, 'use_filter') and mymodule.use_filter: aflt = Signal(intbv(0, min=c.min, max=c.max)) gens = myfilter(clock, reset, a, aflt) else: aflt,gens = (a,[]) @always_seq(clock.posedge, reset=reset) def hdl(): c.next = a + b gens = [gens, hdl] return gens Traditionally you would add: mymodule(clock, reset, a, b, c, UseFilt=False) After writing this it dawned on me, most of the time it would be bad. I guess a function attribute would only be useful if you wanted every MyHDL module instance to act exactly the same (e.g. if the filter was enabled in one instance it would be enabled in all instances). So where this might be useful is if you are using technology primitives (FPGA primitives) and you want to instantiate a primitive based on a technology, say Xilin or Altera. But in that case you would want the attribute to be global to all the modules, hmmm. Regards, Chris |