Re: [myhdl-list] delays misconverted in VHDL conversion
Brought to you by:
jandecaluwe
From: Henry G. <he...@ca...> - 2015-02-11 09:08:11
|
On 08/02/15 22:22, Josy Boelen wrote: > Henry Gomersall <heng <at> cantab.net> writes: > >> > >> >I'm trying to do a poor man's RTL co-simulation by creating the files >> >needed for simulation and the relevant stimulus files (from the MyHDL >> >simulation), then writing the outputs from the Xilinx simulation to > file >> >for post-simulation comparison. For this I need a clock. >> > >> >Consider: >> > >> >def ClkDriver(clk, period=20): >> > >> > lowTime = int(period/2) >> > highTime = period - lowTime >> > >> > <at> instance >> > def driveClk(): >> > while True: >> > yield delay(lowTime) >> > clk.next = 1 >> > yield delay(highTime) >> > clk.next = 0 >> > >> > return driveClk >> > >> >This is converted to the following (pertinent) VHDL: >> > >> >architecture MyHDL of ClkDriver is >> > >> >constant lowTime: integer := 10; >> >constant highTime: integer := 10; >> > >> >begin >> > >> >CLKDRIVER_DRIVECLK: process is >> >begin >> > while True loop >> > wait for lowTime ns; >> > clk <= '1'; >> > wait for highTime ns; >> > clk <= '0'; >> > end loop; >> > wait; >> >end process CLKDRIVER_DRIVECLK; >> > >> >end architecture MyHDL; >> > >> >Xilinx Vivado complains this is a syntax error. It doesn't like the > use >> >of a constant in the "wait for lowTime ns", though it's easily fixed >> >with e.g. "wait for 10 ns". >> > >> >Is this Vivado being crap, or is this expected behaviour? I could > always >> >create my own custom VHDL template, but it would be neater to have > MyHDL >> >do it for me. >> > >> ><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. Can anyone else comment on whether this wants to be fixed? Happy to raise a PR with some form of a fix. I feel this could easily go into 0.9. My reading of the spec suggests the ns is an integral part of the time type, not some general numerical attribute, so I think the failure is expected. Cheers, Henry |