Re: [myhdl-list] Setting of enum values
Brought to you by:
jandecaluwe
From: Henry G. <he...@ca...> - 2015-01-11 10:28:56
|
On 11/01/15 08:33, Jan Decaluwe wrote: > The whole blurring of integers with enum items comes from > languages that unlike VHDL don't have a good enum model. > > The whole point of a enum is to have an abstract type > where nothing matters but the item name. The MyHDL enum makes > that very clear - no integers in sight. You make a reasonable case that the normal Enum is fine as-is except for the fact that it doesn't really work with external libraries (not least because the Verilog support for enums is missing). Given that, I still think that there is a use case for something like the IntEnum - if only as a namespace encapsulation device. One usage of enums is to remove the reliance on magic numbers. Of course it's possible to have your own naming convention, but it quickly gets mucky with lots of FOO_X, FOO_Y, BAR_X, BAR_Y floating around. If it was a supported concept, then useful things like bit length could be inferred. At a very minimum, it would be useful to have namespace mangling that allows integer class attributes to be supported, as suggested in another post. This would a provide a similar feature for other types as interfaces do for Signals. To be clear, I think MyHDL is fantastic - the neat mapping of HDL concepts into standard python constructs is rather beautiful. I thank and congratulate your for it. Henry |