Re: [myhdl-list] Constant ints in interfaces
Brought to you by:
jandecaluwe
From: Josy B. <jos...@gm...> - 2015-03-16 10:04:03
|
<snip> > class Interface(object): > def __init__(self): > self.a = Signal(intbv(0, min=-1000, max=1000)) > self.c = 10 > > where c gets converted as interface_name.c. > > My understanding from the docs is that this should be supported, but I > might be missing something. I noticed this previously with IntEnum, but <snip> Henry, I noticed similar behaviour when using a class (as I also have local functions in the class), here is my code: class CorrectionCoefficients(object): ''' a VHDL-record like object ''' def __init__(self, WIDTH_PRNU, WIDTH_FPN, p = 0, f = 0): self.WIDTH_FPN = WIDTH_FPN self.WIDTH_PRNU = WIDTH_PRNU self.fpn = Signal(intbv(f)[WIDTH_FPN:]) self.prnu = Signal(intbv(p)[WIDTH_PRNU:]) def toCorrectionCoefficients(self, v): # need an unique name as 'alias' otherwise the 'self.WIDTH_FPN' shows up as a constant in the VHDL tccWIDTH_FPN = self.WIDTH_FPN @always_comb def tcc(): lv = v self.fpn.next = lv[tccWIDTH_FPN:] self.prnu.next = lv[:tccWIDTH_FPN] return tcc def tointbv(self, y): ''' build a flattened vector from the record's elements in ascending order''' # need an unique name as 'alias' otherwise the 'self.WIDTH_FPN' shows up as a constant in the VHDL :) tiWIDTH_FPN = self.WIDTH_FPN @always_comb def ti(): y.next[tiWIDTH_FPN:] = self.fpn y.next[:tiWIDTH_FPN] = self.prnu return ti Regards, Josy |