satvika
New Member
Offline
Posts: 1
|
Hi,
I am generating triangular wave using the following code. I am instantiating this in top level module. Is there a way I can change the value of period on the fly, if I need to change from one frequency to another.
module V_triangle_generator(out); output out; voltage out;
parameter real period = 10n from [0:inf), ampl = 1;
integer slope; real offset;
analog begin @(timer(0,period)) begin slope = +1; offset = $realtime; discontinuity(1); end
@(timer(period/2,period)) begin slope = -1; offset = $realtime; discontinuity(1); end
V(out) <+ ampl * slope * (4*($realtime-offset)/period - 1); end endmodule
Thanks in advance
|