Thread: [myhdl-list] elif + toVHDL function
Brought to you by:
jandecaluwe
From: patrick <pat...@gm...> - 2010-03-26 20:03:59
|
Hello everyone, this is my first post to this list. I also posted this question on comp.lang.verilog and comp.lang.vhdl as a 'reply' to the message on the first ASIC designed with myHDL (great news!). This list is probably more appropriate for posting my question, so here goes. The rest of this message is a copy of the text also posted to the newsgroups: Hello Jan, First of all, congratulations with this result! I have only recently become acquainted with myHDL and it looks very nice. Specifically, I like myHDL's conversion capabilities and the possibility of writing testbenches in python. I have a question on myHDL's conversion capabilities: When I use a 'elif some_condition:' statement and try to translate it to VHDL I get the following error: myhdl.ConversionError: in file regp2p.py, line 15: no else test With the toVerilog function the translation works fine. Is a 'elif some_condition:' statement treated differently by the toVHDL function (than by the toVerilog function) or is a 'elif some_condition:' statement in myHDL something other than a 'else: if some_condition:' statement? I attached a small example at the end of this post (a posedge sensitive register with an asynchronous clear and an enable input). Thanks, Patrick from myhdl import * def regp2p( clr, clk, en, pin, pout, width ): intreg = Signal(intbv(0)[width:]) @always(clk.posedge, clr.posedge) def register_p2p(): if clr: intreg.next = 0 # This works with toVerilog but not with toVHDL elif en: intreg.next = pin # This works with both toVerilog and toVHDL # else: # if en: # intreg.next = pin @always_comb def outputs(): pout.next = intreg return register_p2p, outputs width = int(8) clr = Signal(bool(0)) clk = Signal(bool(0)) en = Signal(bool(0)) pin = Signal(intbv(0)[width:]) pout = Signal(intbv(0)[width:]) def main(): toVerilog.name = 'regp2p' toVerilog( regp2p, clr = clr, clk = clk, en = en, pin = pin, pout = pout, width = width ) toVHDL( regp2p, clr = clr, clk = clk, en = en, pin = pin, pout = pout, width = width ) if __name__ == '__main__': main() |
From: Jan D. <ja...@ja...> - 2010-03-29 13:15:49
|
patrick wrote: > > I have a question on myHDL's conversion capabilities: > When I use a 'elif some_condition:' statement and try to translate it > to VHDL I get the following error: > > myhdl.ConversionError: in file regp2p.py, line 15: > no else test > > With the toVerilog function the translation works fine. > > Is a 'elif some_condition:' statement treated differently by the > toVHDL function (than by the toVerilog function) or is a 'elif > some_condition:' statement in myHDL something other than a 'else: if > some_condition:' statement? The basic issue is explained here: http://www.myhdl.org/doc/0.6/whatsnew/0.6.html#template-transformation It may be possible to make template transformation more sophisticated and handle code such as yours. However, the workaround for now is to put the clock-triggered part of the logic in the "else" clause, as you found out. Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com Analog design automation: http://www.mephisto-da.com World-class digital design: http://www.easics.com |
From: Patrick <pat...@gm...> - 2010-03-29 17:00:02
|
Thank you for your quick reply and for the link. I haven't used VHDL in a while and I didn't stop to think about the difference between verilog/VHDL sensitivity lists. Thanks, Patrick On Mon, Mar 29, 2010 at 3:15 PM, Jan Decaluwe <ja...@ja...> wrote: > patrick wrote: > > > > > I have a question on myHDL's conversion capabilities: > > When I use a 'elif some_condition:' statement and try to translate it > > to VHDL I get the following error: > > > > myhdl.ConversionError: in file regp2p.py, line 15: > > no else test > > > > With the toVerilog function the translation works fine. > > > > Is a 'elif some_condition:' statement treated differently by the > > toVHDL function (than by the toVerilog function) or is a 'elif > > some_condition:' statement in myHDL something other than a 'else: if > > some_condition:' statement? > > The basic issue is explained here: > > http://www.myhdl.org/doc/0.6/whatsnew/0.6.html#template-transformation > > It may be possible to make template transformation more > sophisticated and handle code such as yours. However, the > workaround for now is to put the clock-triggered part of > the logic in the "else" clause, as you found out. > > Jan > > -- > Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com > Python as a HDL: http://www.myhdl.org > VHDL development, the modern way: http://www.sigasi.com > Analog design automation: http://www.mephisto-da.com > World-class digital design: http://www.easics.com > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > |