Re: [myhdl-list] New way of specifying user defined code, not working inside class
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2012-01-19 12:24:31
|
On 1/19/12 5:51 AM, Wesley New wrote: > Hi All, > > I have had to change the way my uesr-defined code was written to the new > method, using <func>.verilog_code but I am having a problem using it > inside a class. > > Here is the code: > > from myhdl import * > > class sw_reg: > > def __init__(self): > #self.sw_reg_r_wrapper.__dict__['verilog_code'] = "verilog" > #self.sw_reg_r_wrapper.verilog_code = "verilog" > temp2 = 0 > > > def sw_reg_wrapper(self, wb_clk_i): > > #======================== > # TODO:Simulation Logic > #======================== > @always(wb_clk_i.posedge) > def logic(): > temp = 1 > > return logic > > sw_reg_r_wrapper.verilog_code = "verilog code blah blah" > > > But when I call the toVerilog method, as below, it doesnt use the > user-defined code (Note: this works when there is no class) > > #======================================= > # For testing of conversion to verilog > #======================================= > def convert(): > > x = sw_reg_r() > wb_clk_i = Signal(bool(0)) > > toVerilog(x.sw_reg_r_wrapper, wb_clk_i=wb_clk_i) > > > if __name__ == "__main__": > convert() > > I have tried adding the verilog_code explicitly to the dictionary > associated with the function (See the commented lines in the __init__ > function) but this doesnt work either. What am I doing wrong? > > Thanks for you time. > > Wesley > > > This is currently a known limitation, you cannot convert a class method directly because the convert does not recognize the first parameter, "self", and uses "self" as a port. The current work around, is to have a normal function that is converted and have the class method invoke the function (essentially pass all arguments except self). This is one of the items I was hoping to address in the MEP I proposed but finding adequate time to work on it is, lets say, difficult. Hope that helps, Chris |