|
From: Maciej S. <mac...@ce...> - 2015-05-29 16:34:25
|
Hi, I have managed to implement time and wait for/on/until statements in vhdlpp [1] with tests [2]. I have chosen yet another way that seems much simpler. By default vhdlpp analyzes time expressions used in the processed file and then stores the required time precision in `timescale directive. This approach does not solve the problem of different timescales in modules. Therefore there is an additional option for iverilog & ivlpp to override `timescale directives. This way all time expressions use the same format and everything works as expected. I guess it might be useful also for (System)Verilog simulations as well. Regards, Orson 1. https://github.com/steveicarus/iverilog/pull/70 2. https://github.com/orsonmmz/ivtest/tree/time_test On 05/23/2015 12:26 AM, Martin Whitaker wrote: > Your second option is standard SystemVerilog, so that is the best way to go. > For accuracy, you should probably store time constants as a mantissa + exponent. > > Martin > > Maciej Sumiński wrote: >> Hi, >> >> I am looking for the best way to implement expressions related to time >> in vhdlpp. Ideally, I would use SystemVerilog's time literals, so: >> >> wait for 10 ns; >> >> is translated to: >> >> #10ns; >> >> This ought to be trivial with the current ivl version. The only obstacle >> I face now is to support constants, like: >> >> constant a : time := 10 ns; >> >> The problem here is how to use them in SystemVerilog modules that may >> have different time scales. >> >> * First option >> One solution that is easy for me to implement is to prepare an >> Icarus-specific function that takes mantissa and exponent to describe a >> time period: >> >> localparam a = $ivl_time(10, -9); >> >> Then during elaboration the value would be adjusted according to the >> time scale of scope where it is used. >> >> * Second option >> While the first approach satisfies my needs, there might be a solution >> that you find more advantageous. It also does not introduce any >> Icarus-specific functions. >> >> Though it is not available at the moment, it should be fairly easy to >> make localparam accept time literals, so the initial example becomes: >> >> localparam a = 10ns; >> >> but the current implementation stores time as floating point numbers >> adjusted to the time scale of the scope where a delay was defined [1]. >> >> In order to use a localparam value in a scope that uses a different time >> scale, the absolute time value has to be preserved and adjusted during >> elaboration (just like $ivl_time would do). To do so, I may either >> introduce a new type (veritime?), or assume time values are saved in >> femtoseconds. >> >> Do you have any thoughts/preference? >> >> Regards, >> Orson >> >> 1. https://github.com/steveicarus/iverilog/blob/master/parse.y#L2782 >> >> >> >> ------------------------------------------------------------------------------ >> One dashboard for servers and applications across Physical-Virtual-Cloud >> Widest out-of-the-box monitoring support with 50+ applications >> Performance metrics, stats and reports that give you Actionable Insights >> Deep dive visibility with transaction tracing using APM Insight. >> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y >> >> >> >> _______________________________________________ >> Iverilog-devel mailing list >> Ive...@li... >> https://lists.sourceforge.net/lists/listinfo/iverilog-devel >> > > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y > _______________________________________________ > Iverilog-devel mailing list > Ive...@li... > https://lists.sourceforge.net/lists/listinfo/iverilog-devel > |