Re: [myhdl-list] Convertible records
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2011-09-02 16:06:48
|
On 9/2/2011 10:35 AM, Sébastien Bourdeauducq wrote: > On 09/02/2011 04:24 PM, Christopher Felton wrote: >> My basic thought would be to create a type in MyHDL, SignalStruct, and >> then create long unique variable names in the converted HDL. >> >> Example: >> >> class MyBus(SignalStruct): >> def __init__(self): >> self.addr = Signal(intbv(0)[16:]) >> self.data = Signal(intbv(0)[8:]) >> # ... > > I'm not sure having the base "SignalStruct" would be even necessary. A > regular object should be enough (and potentially more flexible), no? > > i.e. "class MyBus():" could just work as well.. > Yes, at this point I don't have any justification for having a base class. It is just a gut feeling that have a specific base class will be useful (user shows intent). 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. The second part would be that the base class can have helper functions (again, this is a gut and not fully thought out) to help the conversion. Instead of the conversion analyzer having to jump down the class hierarchy, the SignalStruct can return signals (and signals of self object signals :) ). Regards, Chris |