Thread: [myhdl-list] Interface conversion bug in 0.9-dev?
Brought to you by:
jandecaluwe
From: SHEN C. <she...@co...> - 2015-02-15 19:46:14
|
Hi all, I found that the conversion of shadow signal in an "interface" is wrong if the signal is in a list. Consider the two programs t1 and t2 at the end of the message. I define a signal A.X, and use a slice of it A.X0 as a condition in proc(). I realized that it is important to have "a.X.next = 1" in the process, otherwise a.X (and by extension a.X0) will be regarded as constants. However, the constant/variable inference is broken in t2, where A.X is a list, and A.X0 is a slice of an element in the list. t2.py converts to the following verilog code. Note the if(False) line, it seems that a.X0 is treated as a constant, despite the "a_X[0] <= 1" assignment. always @(posedge clk) begin: LOGIC_PROC if (False) begin b <= 1; end else begin b <= 0; a_X[0] <= 1; end end I don't think this is correct behavior. It took me some time before I realize there is some constant v.s. variable inference going on. I'm not sure if I understood it correctly. Is there any documentation on this? Thank you. regards, Shenchen ============================== t1.py ============================= from myhdl import * class A(object): def __init__(self): self.X = Signal(intbv(0)[8:]) self.X0 = self.X(0) def logic(clk, b): a = A() @always(clk.posedge) def proc(): if a.X0: b.next = 1 else: b.next = 0 a.X.next = 1 return proc clk = Signal(False) b = Signal(intbv(0)[8:]) toVerilog(logic, clk, b) =================================================================== ============================== t2.py ============================= from myhdl import * class A(object): def __init__(self): self.X = [Signal(intbv(0)[8:]), Signal(intbv(0)[8:])] self.X0 = self.X[0](0) def logic(clk, b): a = A() @always(clk.posedge) def proc(): if a.X0: #if a.X[0][0]: b.next = 1 else: b.next = 0 a.X[0].next = 1 return proc clk = Signal(False) b = Signal(intbv(0)[8:]) toVerilog(logic, clk, b) =================================================================== |
From: SHEN C. <she...@co...> - 2015-02-17 21:57:26
|
Hi all, I hope someone could shed some light on this conversion problem, either fixes, workarounds or points to look at in the source code. I've been trying to switch to 0.9 and use Interface in my new project, and this conversion problem is the last thing holding us back. Thank you. regards, shenchen On 2015-02-16 03:45, SHEN Chen wrote: > Hi all, > > I found that the conversion of shadow signal in an "interface" is > wrong > if the signal is in a list. > Consider the two programs t1 and t2 at the end of the message. > > I define a signal A.X, and use a slice of it A.X0 as a condition in > proc(). > I realized that it is important to have "a.X.next = 1" in the > process, > otherwise a.X (and by extension a.X0) will be regarded as constants. > > However, the constant/variable inference is broken in t2, where A.X > is > a list, and A.X0 is a slice of an element in the list. > t2.py converts to the following verilog code. Note the if(False) > line, > it seems that a.X0 is treated as a constant, despite the "a_X[0] > https://lists.sourceforge.net/lists/listinfo/myhdl-list |
From: Christopher F. <chr...@gm...> - 2015-02-18 13:31:05
|
On 2/15/2015 1:45 PM, SHEN Chen wrote: <snip> > However, the constant/variable inference is broken in t2, where A.X is > a list, and A.X0 is a slice of an element in the list. > t2.py converts to the following verilog code. Note the if(False) line, > it seems that a.X0 is treated as a constant, despite the "a_X[0] <= 1" > assignment. > > always @(posedge clk) begin: LOGIC_PROC > if (False) begin > b <= 1; > end > else begin > b <= 0; > a_X[0] <= 1; > end > end > > I don't think this is correct behavior. In this complicated "container" example (signal inside a more complicated structure) you can always create a local reference and it should work/help. I posted a work around here (also changed the example slightly, see the second and third module). https://gist.github.com/cfelton/1648ad98e2bda5745ec9 Not sure if this will work in your case or not. It will take some more investigation to determine if this is a bug or a not supported feature, and if it is to be a not supported, can it be detected. > > It took me some time before I realize there is some constant v.s. > variable inference going on. > I'm not sure if I understood it correctly. Is there any documentation > on this? Thank you. We are in the process of generating the documentation on interfaces for 0.9 release. The only documentation that currently exists is the MEP (MEP107). I don't think it describes signal/variable/constant handling. I will add this to the documentation being added. Regards, Chris |
From: Christopher F. <chr...@gm...> - 2015-02-18 14:44:19
|
<snip> > > https://gist.github.com/cfelton/1648ad98e2bda5745ec9 > > Not sure if this will work in your case or not. > > It will take some more investigation to determine if > this is a bug or a not supported feature, and if it > is to be a not supported, can it be detected. > I played around with this some more, the issue can be reproduced in 0.8.1 using just list-of-signals and ShadowSignals. It doesn't appear to be tied to the /interface/ conversion. The above gist link has an example of each. Regards, Chris |
From: SHEN C. <she...@co...> - 2015-02-19 12:23:30
|
I agree the original title was poorly chosen. It's a problem with ShadowSignal. I occurs no matter if interface is used. A local reference does correct the variable inference. Thank you. However, if I have to remember to do this every time, I'd rather not using shadow signal for list element at all, shenchen On 2015-02-18 22:43, Christopher Felton wrote: >> https://gist.github.com/cfelton/1648ad98e2bda5745ec9 [1] Not sure if >> this will work in your case or not. It will take some more >> investigation to determine if this is a bug or a not supported >> feature, >> and if it is to be a not supported, can it be detected. > > I played around with this some more, the issue can be > reproduced in 0.8.1 using just list-of-signals and > ShadowSignals. It doesn't appear to be tied to the > /interface/ conversion. The above gist link has an > example of each. > > Regards, > Chris > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and > Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & > more > Get technology previously reserved for billion-dollar corporations, > FREE > http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list -- Links: ------ [1] https://gist.github.com/cfelton/1648ad98e2bda5745ec9 |