Re: Setting of enum values

Thomas Heller <[email protected]> Thu, 21 Jan 2016 09:47:48 +0100
Newsgroups gmane.comp.python.myhdl
Message-ID <[email protected]>
Am 20.01.2016 um 23:11 schrieb Marcel Hellwig:
> Hello everyone,
>
> As far as I can see, there is no action on this topic anymore. 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 the same problem and currently only see these two possibilities:

1. Import each constant and assign it in the myhdl code, like this:

from cpumode import CpuMode
cpumode_User = CpuMode.User
...

2. Define the constants as module level constants
and use 'from mymodule import *' in the myhdl code.


Thomas


------------------------------------------------------------------------------
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