The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Aug 16th, 2024, 9:09pm
Pages: 1
Send Topic Print
Output of a sine wave  generator is 0. (Read 1814 times)
zahrein
Junior Member
**
Offline



Posts: 14

Output of a sine wave  generator is 0.
Oct 05th, 2011, 1:53am
 
HI ,
Im trying to model  a sin wave generator. And seems nothing is  out  from the  waveform. Copied my testbench and verilog. Do give me your opinion. Appreciate a lot. Thanks

Testbench



module tb_test_ver();   //testbench  module  name

wire  pina, pinb;    // declaring wire input
sine_wave out2(.wave(pinb));
initial $vcdpluson;  //log on vpd file for dve
initial      #(50000000000) $finish;  //set to run for 50,000ps
endmodule


Verilog code  for  sine wave generator

module  sine_wave (wave);

output wave;
real offset;
electrical wave;

parameter real freq   = 1000 from (0:inf);
parameter real ampl= 1;
           
analog begin
  V(wave) <+ ampl * sin(3.142* freq * $abstime);
  $bound_step(0.05/freq);
end
endmodule


Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Output of a sine wave  generator is 0.
Reply #1 - Oct 6th, 2011, 3:46am
 
Hi zahrein,
your sine generator seems OK to me. Note that it runs with 500 Hz, so 50 ns is not very much.
Are you sure that $vcdpluson supports electrical signals?

B O E
PS: Which simulator do you use?
Back to top
 
« Last Edit: Oct 6th, 2011, 6:46am by boe »  
View Profile   IP Logged
zahrein
Junior Member
**
Offline



Posts: 14

Re: Output of a sine wave  generator is 0.
Reply #2 - Oct 6th, 2011, 6:36pm
 
Yes, Boe. Thanks for explaining the mistakes. I fix my  verilog and it can can run.

Heres the code. And im running on DVE, this is a part of the  VCS  system at my company.


module  sine_wave (wave);

output wave;
real offset;
electrical wave;

parameter real freq   = 1G;
parameter real ampl= 1;
           
analog begin
  V(wave) <+ ampl * sin(3.142* freq * $abstime);
  $bound_step(0.00001/freq);
end
endmodule
Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2386
Silicon Valley
Re: Output of a sine wave  generator is 0.
Reply #3 - Oct 6th, 2011, 8:48pm
 
Your $bound_step() will force the analog kernel to take 100K points per cycle, which is absurd. You'd be much better served using $bound_step(0.1/freq).

-Ken
Back to top
 
 
View Profile WWW   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Output of a sine wave  generator is 0.
Reply #4 - Oct 7th, 2011, 1:20am
 
Zahrein,
Note that in the analog section of Verilog-AMS code the units are given in the include file disciplines.vams, usually Volt, Ampere, second, .... And the timescale directive has no effect for the analog stuff.
This is the reason for the $bound_step issue Ken pointed out.
B O E
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: Output of a sine wave  generator is 0.
Reply #5 - Oct 7th, 2011, 7:38am
 
pi is 3.142 ??   Ugh.

Why not use `M_PI from
`include "constants.vams"
?
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Output of a sine wave  generator is 0.
Reply #6 - Oct 7th, 2011, 8:39am
 
BTW, it should be 2π (`M_TWO_PI).
-B O E
Back to top
 
 
View Profile   IP Logged
zahrein
Junior Member
**
Offline



Posts: 14

Re: Output of a sine wave  generator is 0.
Reply #7 - Oct 8th, 2011, 1:43am
 
HI Boe &  Geoffrey_Coram & ken,

Thanks  for  pointing out. The reason i  did  not  use the constant M_PI is  to  check  my code.  I increase the bound step  is    to check wether it has  an impact on my sine wave or not as my  sine wave look not so  smooth. I thought by increasing the bound step will make my sine wave to be smoother.

Thanks...

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.