The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Mar 28th, 2024, 10:13pm
Pages: 1
Send Topic Print
Changing clk period dynamically (Read 1515 times)
satvika
New Member
*
Offline



Posts: 1

Changing clk period dynamically
Jun 26th, 2014, 3:28am
 
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
Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Changing clk period dynamically
Reply #1 - Jun 26th, 2014, 9:17am
 
Satvika,
my V-AMS documentation states "[p]arameters are constants, so you cannot change the value of a parameter at runtime", so you need to change the definition of the period to a variable.
You will probably need to change the timer() implementation to make sure that no phase jumps can occur.
- B O E
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.