The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Mar 19th, 2024, 1:01am
Pages: 1
Send Topic Print
[Verilog-A] problem with the code (Read 907 times)
helpveriloga
New Member
*
Offline



Posts: 1

[Verilog-A] problem with the code
Sep 19th, 2019, 12:34am
 
Hi, I am trying to make a pulse generator with conditional delay.
But it is not working.
Can someone help me with this?


module verilog_pulse(out);

output out;
electrical out;

parameter real fpul = 500M;
parameter real fsin = 242M;
parameter real vdd = 0.8;
parameter real t_tran = 0;
parameter real va = 1;

real p,phase,vout,t_delay;

analog begin

@(initial_step) begin
  p=0;

       @(timer(0, 1/fpul*0.5)) begin
         if (p==0) begin
               vout=0;
               p=1;
         end
         else if (p==1) begin
               vout=vdd;
               p=0;

       phase = 2*`M_PI*idtmod(fsin, 0.0, 1.0, -0.5);
       t_delay = va*sin(phase);
       end
       end

       V(out) <+ transition(vout,t_delay,t_tran);
end

Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: [Verilog-A] problem with the code
Reply #1 - Sep 19th, 2019, 8:37am
 
Debugging by inserting $strobe statements should lead you to the problem I would think.  Also, it would help if you indented your code properly.

The use of idtmod is weird. You can generate the sine wave directly. No need to use idt or idtmod, which are expensive operations.

-Ken
Back to top
 
 
View Profile WWW   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.