Re: [myhdl-list] Would you ...
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2012-09-25 16:45:15
|
On 9/25/2012 10:56 AM, Tom Dillon wrote: > 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. > > I agree, name arguments is what you usually want and your example is a perfect demonstration of creating very flexible IP. The use of "interfaces" helps as well. mymodule(syssigs=None, datapath=datapath, UseFilt=False) and in the module you can have def mymodule(...): (a,b,c) = datapath.GetSigs() if syssigs is not None: clock = syssigs.clock reset = syssigs.reset # ... else: # ... where datapath is: class Datapath(object): def __init__(self): self.a,self.b,self.c = [Signal...] def GetSigs(self): return self.a,self.b,self.c Regards, Chris |