• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC Design
  3. Transition in conditional statement, VerilogAMS

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 125
  • Views 5880
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Transition in conditional statement, VerilogAMS

mohthi3
mohthi3 over 1 year ago

I'm trying to create a testbench using verilogAMS, and for that, I need a port that is at times, voltage-controlled, and other times, current-controlled. I used a conditional statement for that.
Here is a snippet of my code:


if (i==0) V(Vout,n)<+VVout;

else I(Vout)<+1u;

VVout and i are variables that change value in other parts of my code.
The problem is that I can't use "transition" in a conditional statement (returns an error).
Is there a way to alternate between voltage and current source without the use of a conditional statement? If not, any way (or alternative) to using transition?

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago

    Two things:

    1. You could use transition in the statement where you are assigning VVout - provided that this is assigned outside of the conditional statement (so the transition is executed continuously)
    2. You should really have the branches being the same in a switch branch like this (i.e. it should be I(Vout,n) rather than I(Vout).

    You can't use the transition function to alter how it switches between a voltage and a current source if that's what you're asking (I'm not sure that would make a lot of sense).

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • mohthi3
    mohthi3 over 1 year ago in reply to Andrew Beckett

    Thank you for your answer!
    1-I didn't know transition could be used for a variable assignment, I don't think that's possible tho, given that even VVout is assigned in a conditional statement.
    2- What kind of problem may this cause if I may ask?

    I think I'll have to find another way to design the testbench without resorting to switching between current and voltage source. The brusque transitions without the use of "transition" is annoying in interpreting the results.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to mohthi3
    1. You could add another variable outside of the conditional statements:
      VVVout=transition(VVout,...);
      That would mean your VVout is assigned to conditionally, but you still have a transition. The transition can't be inside a conditional because it needs to be always executed so that it correctly handles the state transitions (sorry, that's probably a bit of a circular argument!)
    2. It's not really a switch branch if the branches are different - I(Vout) is the current from Vout to ground, rather than V(Vout,n) which is between nodes Vout and n. What might happen is that something ends up floating when it's not connected the same way (for example, what happens to node n?). If node n is connected to the global ground, it may end up working fine - but you might end up with convergence difficulties. Switch branches are described in the Verilog AMS LRM, and also the Cadence Verilog A manual (see relevant pages attached from our manual)

    switchbranch.pdf

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information