Re: Setting of enum values

Jan Coombs <[email protected]> Thu, 21 Jan 2016 00:33:46 +0000
Newsgroups gmane.comp.python.myhdl
Message-ID <20160121003346.4cc3702d@t500>
On Wed, 20 Jan 2016 23:11:46 +0100
Marcel Hellwig <[email protected]> wrote:

> As far as I can see, there is no action on this topic anymore.

Agreed, it is a complex one, and I accept the reasons for not
pursuing this. Where I want to have close control of bits I
import values.  These are created using simple assignments, 
which are sometimes shortened using range(x,y,z)

> I'm currently encounter a Problem with exactly this.
> My Problem is, that I have some (cpu-)modes, which I'd like to
> have in an extra file, because I use them from some points in
> my code. So I create a file cpumode.py with the following
> content:
> 
> cpumode.py:
> > class CpuMode(object):
> >     User = 0b10000
> >     FIQ = 0b10001
> >     IRQ = 0b10010
> >     Supervisor = 0b10011
> >     Abort = 0b101111
> >     Undefined = 0b11011
> >     System = 0b111111
> 
> In the next file, I import it via
> 
> > from cpumode import CpuMode
> 
> 
> Now, myhdl tells me:
> 
> > myhdl.ConversionError: in file xxx.py, line 63:
> >     Unsupported attribute: User
> 
> line 63:
> > if mode == CpuMode.User:

I had this type of problem with VHDL, something like 'data not
locally static' but have not seen it with MyHDL.  Perhaps this
is because simple named constant values are just converted
into numbers in the Verilog or VHDL files.  

In one large processor design most of the ~24 source files
import basic configuration parameters, like buss width, and
perhaps a third import opcode constants. There seems to be no
problem using this method. 

Hope this helps, else, for sample code email me directly.

Regards, Jan Coombs.

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140