Re: [myhdl-list] [PATCH] Remove redundant copy operators
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2009-11-03 16:24:19
|
> > > The first solution I found is to make a always_comb process, but > still, we have to use a .next, so we don't have strictly the 'alias' > behavior. This solution is sort of driven by my "think hardware" mind, > or should I say, education. > > The second solution I found, and there, MyHDL shows its supremacy, is > to use Python as a tool, and not define my ControlWord as intbv, but > to define my own class, say ctrlword that inherit from intbv, redefine > "__getattr__", such that "ctrlword.subpart3" return the right slice > from my intbv. THis also has the advantage that I keep complete > compatibility (think conversion) with the intbv type. Clever isnt't it > ? The only problem I got is that the intbv __copy__ function was > forcing the return value as being an intbv, thus, removing all the > information from my ctrlword. > It might be better to override the methods/functions in your ctlrword class than removing them from the intbv object? I did something similar with the fixed-point object, http://www.myhdl.org/doku.php/users:cfelton:projects:fxintbv, which is convertible, as well. Think this is/has been a sticky issue in the Python community in general. Seems like there are strong opinions one way or the other. In general an inheriting class needs to override all the base class methods to return the new type. I believe you are asserting that the general copy returns the type of the object being copied and there is no need to override the copy methods? .chris |