Re: [myhdl-list] Setting of enum values
Brought to you by:
jandecaluwe
From: Thomas H. <th...@ct...> - 2016-01-21 08:45:41
|
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 |