Re: [myhdl-list] delays in VHDL conversion
Brought to you by:
jandecaluwe
From: Josy B. <jos...@gm...> - 2015-02-09 08:39:02
|
Henry Gomersall <heng <at> cantab.net> writes: > > On 08/02/15 22:22, Josy Boelen wrote: > <snip> > > Actually the converted code is wrong, the statements like: > > constant lowTime: integer := 10; > > wait for lowTime ns; > > > > are incorrect, they should either be: > > constant lowTime: integer := 10; > > wait for lowTime * 1.0 ns; > > > > or: > > constant lowTime: time := 10.0 ns; > > wait for lowTime ; > > > > Should be easy to fix in the MyHDL code. > > You mean in the conversion routines? The easiest way I can think of is > to replace the "ns" string with "* 1.0 ns" > here: > https://bitbucket.org/jandecaluwe/myhdl/src/b07b52398020b3bd737d0b4f1574 f0d94eefccb5/myhdl/conversion/_toVHDL.py?at=default#cl-970 > > No doubt that will break other things though? Is there a reason why > there can't always be a multiplier (other than code neatness)? > <snip> I meant exactly that, and the '* 1.0 ns' would be my preferred too, and is definitely the easiest. I don't think this will break any other code. Specifically setting the 'times' using real numbers, e.g.: def ClkDriver(clk, period=20.0): lowTime = period / 2 highTime = period - lowTime ... wait for lowTime ns; will not help either, as VHDL expects a time-type value and the 'ns' is part of that and can not be used as a units specifier. I'm not aware if there is a cast to convert something (int or real) into a time-type. Of course we could write the function(s) to do this and add these to the MyHDL package and modify the MyHDL code: elif f is delay: self.write( "to_VHDLtime( ") self.visit(node.args[0]) # this will end up in visit_Num() and produce an integer or a real (I suppose) self.write(" )") return Regards, Josy |