Re: [myhdl-list] Setting of enum values
Brought to you by:
jandecaluwe
From: Marcel H. <1he...@in...> - 2016-01-22 18:39:44
|
On 20.01.2016 23:11, Marcel Hellwig wrote: > > Now, myhdl tells me: > >> > myhdl.ConversionError: in file xxx.py, line 63: >> > Unsupported attribute: User > line 63: >> > if mode == CpuMode.User: I finally found out, why this happens. Because I don't like to write the same code twice, I outsourced the if/elif section into a seperate function. > def getRegisterbank(mode): > if mode == ProcMode.User or mode == ProcMode.System: > return 0 > elif mode == ProcMode.Supervisor: > return 1 > elif mode == ProcMode.Abort: > return 2 > elif mode == ProcMode.IRQ: > return 4 > elif mode == ProcMode.FIQ: > return 5 > else: > return 3 > > @always_seq(clk.posedge, reset=reset) > def write(): > if we: > mul = 0 > if mode == ProcMode.User or mode == ProcMode.System: > mul = 0 > # ... > else: > mul = 3 > # mul = getRegisterbank(mode) > re = regbank[mul*18 + rd] > regs[re].next = din > > @always_comb > def read(): > # mul = getRegisterbank(mode) > mul = 0 > re = regbank[mul*18 + rs] > sout.next = regs[re] > > return write, read And here is the problem. When I write it directly in the write/read methods, everything works fine, but as soon as I call the getRegisterbank function, it will complain about unsupported Attribute. Is there a way around this? :/ |