Re: [myhdl-list] Would you ...
Brought to you by:
jandecaluwe
From: Tom D. <td...@di...> - 2012-09-25 16:13:37
|
My personal preference is named arguments. I also use signal arguments to pass some functionality as well. Such as: mymodule(clock=None,reset=None, a=sig1, b=sig2, c=sig3, UseFilt=False) Would make it asynchronous. The mymodule definition would have to check for clock==None and return the appropriate logic. On 09/25/2012 10:45 AM, Christopher Felton wrote: > 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 > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list |