Re: [myhdl-list] int(EnumItem)
Brought to you by:
jandecaluwe
From: Jan D. <ja...@ja...> - 2009-07-15 07:45:04
|
Felton Christopher wrote: > 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. Yes - if the value is needed I suggest to use symbolic constants instead. -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com Analog design automation: http://www.mephisto-da.com World-class digital design: http://www.easics.com |