|
From: Martin W. <mai...@ma...> - 2015-05-22 22:26:31
|
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 > |