Re: [myhdl-list] Convertible records
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2011-09-02 19:10:35
|
On 9/2/2011 1:15 PM, Jan Langer wrote: > Hi all, > > Am 02.09.2011 um 18:06 schrieb Christopher Felton: >> How the conversion analyzer works now, it looks at free variables (not >> sure what a free variable is) and checks the type. If the type were >> to >> be any class (object) the converter has to do more work to determine >> if >> appropriate signals exist in the class. If the converter can check >> for >> a particular type (base class) then it knows it has signals and can >> extract. Make sense? Maybe the AST easily supports this and the base >> class is not needed. > > > maybe it would be a good idea to let the converter "ask" the class how > it wants to be converted. In a very simple case something like: > > class SignalStruct: > def __signals__(self): > return self.a,self.b > > Jan > My thought was something like this: class SignalStruct(object): def __init__(self): pass def __signals__(self): return self.__dict__ class MyBus(SignalStruct): def __init__(self): self.addr = Signal(intbv(0)[16:]) self.data = Signal(intbv(0)[8:]) bus = MyBus() bus.__signals__() # This will return the signal objects with the names, the function # can also inspect each of the dict elemets and make sure they are # the correct types. At this point, I think (naively) this is a big chunk. This private function (__signals__) will need to dig deeper for embedded SignalStructs etc. .chris |