Re: [myhdl-list] int(EnumItem)
Brought to you by:
jandecaluwe
From: Felton C. <chr...@gm...> - 2009-07-14 11:21:09
|
On Jul 14, 2009, at 4:36 AM, Jan Decaluwe wrote: > Felton Christopher wrote: >> >> Does it make sense to add the following to the EnumItem class? >> >> def __int__(self): >> return int(self._val) >> >> def __long__(self): >> return long(self._val) >> >> def __float__(self): >> return float(self._val) > > Probably, unless you also expect this to be easily convertible? Yeah, I guess that would of been part of it as well. I had a design I was converting from Verilog. In this particular case I had a packet decoder. The first part of the packet was some command structure the last part data. To decode the command portion the "state" variable is assigned to state and compared to state. Later the same variable counts through the rest of the packet. Essentially the "state" was a simple byte counter. In that case, I would do something like >>> state.next = state + 1 This probably does not make sense. When using the enum it should only be used with strictly with a state variable. Such that the underlying value is not known or directly needed. Thanks |