The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 2:12am
Pages: 1
Send Topic Print
How to introduce delay within conditional statement? (Read 1445 times)
vpen
New Member
*
Offline



Posts: 1
Philippines
How to introduce delay within conditional statement?
Sep 26th, 2008, 7:10am
 
Hi everyone! please help. Cry... I want to introduce a delay within a conditonal if statement using Verilog-A.

My target code should function something like this:

if ( comp_flag == 1 )
          I( VOUT, GND ) <+ transition( 0.0, rdelay);
else
          V( VOUT, GND ) <+  transition( 0.0, fdelay);


but since its illegal to put transition() inside if conditons
i modified my code like below

   I(iout) <+ transition( 0.0, rdelay);
   V(vout) <+ transition( 0.0, fdelay);

if ( comp_flag == 1 )
          I( VOUT, GND ) <+  I(iout) );
else
          V( VOUT, GND ) <+  V(vout) );



The code has no error at compilation but the delay was not
accounted in the simulation?

What could be wrong with the code?

or

what alternative should i use? Cry Cry Cry


Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: How to introduce delay within conditional statement?
Reply #1 - Sep 26th, 2008, 10:45am
 
In your modified version, are "vout" and "VOUT" distinct?  Verilog-A is case-sensitive, but I'm not sure whether you were careful when excerpting your model.

I'd add two new nodes:
 electrical int_iout, int_vout;
and contribute both like this:
 I(int_iout) <+ V(int_iout) + transition( 0.0, rdelay);
 I(int_vout) <+ V(int_vout) + transition( 0.0, fdelay);
then
 if (comp_flag == 1)
   I(VOUT, GND) <+ V(int_iout);
 else
   V(VOUT, GND) <+ V(int_vout);

The internal nodes have 1-Ohm resistors on them that convert the current into a voltage; there are funny tricks when you both contribute and probe I(iout) as in your code.  In mine, the probe is always V(x).

Oh, and I assume the "0.0" first arg of transition() is just a dummy, you actually have something that changes there.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
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.