• 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. How can I save the converged values at the nodes after the...

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 125
  • Views 11439
  • 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

How can I save the converged values at the nodes after the last iteration of the time step in verilog-A?

rhanna
rhanna over 4 years ago

Hi,

There's a possible direct way to print converged values using $strobe.

Is there a way to assign these values to some variable before going to a new time step assuming that this variable is used at a previous equation?

e.g 

x = x + const * <variable>

//some equations

V(y) <+ <expression>

 //I want to assign V(y) to <variable> to be used at the first equation.

Thanks in advance.

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    I don't really understand from your example what you're expecting it to do (it seems a rather strange requirement from your initial description). Why would you need to do this?

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    I don't really understand from your example what you're expecting it to do (it seems a rather strange requirement from your initial description). Why would you need to do this?

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • rhanna
    rhanna over 4 years ago in reply to Andrew Beckett

    Sorry for the confusion.

    I have a set of equations in the form of:
    x1 = f(h_prev)
    h = g(x1)
    where h_prev is h (the converged value) at the previous time step and initially assumed to be 0, g and f are functions.
    so I need to save the converged value of h at every time step and assign it to h_prev at the begin of the next time step (excluding the initial one)

    [Update]

    I thought about writing the values to a file and then read them but I found a fatal because I'm trying to change the mode of the file. Is there a way to read and write from the same file?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago in reply to rhanna

    That seems very odd, because if you have variable time steps (which is usual with spectre), your function is going to have this strange dependency on the varying timestep. I could understand it if you were using @(timer...) to schedule a regular even and update the variables that way (i.e. like modelling some sampled data system).

    If you really want this to behave this way with a variable time step you could use something like:

    if ($abstime != lastTime) begin
      h_prev=h;
      lastTime = $abstime;
    end

    ... use h_prev in calculations and compute new h

    I've not tested this (mainly because I can't think of an application of it), but I think it should work 

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • rhanna
    rhanna over 4 years ago in reply to Andrew Beckett

    I agree that the idea is very odd.

    So basically I have got this ODE from a well-trained ML model that predicts a circuit behavior:

    dh_dt(h(t), t) = w2 * tanh( w1 * h(t) + b1) + b2 

    where: {w1, w2, b1, b2} is the parameter set of a neural network and it's known
                h(t) is the circuit state at t and dh_dt represents the dynamics (the rate of change)

    I want to solve an IVP at $abstime when h0 (the initial state) is known so I'm using:

    V(h_final) <+ idt( w2 * tanh( w1 * V(h) + b1) + b2, h0, lastTime); 
    then, I have an equation where V(ht) is a function of V(h_final)

    where: h, h_final are electrical nodes
               h0 is updated by the last value of V(ht)

    but when I debug, I'm always getting V(h_final) = 0.0, Do you think the problem with the integral? 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago in reply to rhanna

    Debugging this without seeing the full model is rather difficult (and to be honest I'm unlikely to have time to do that in the coming days before vacation). So the best thing to do with this is to contact customer support where you can share the whole model and a related testbench.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • rhanna
    rhanna over 4 years ago in reply to Andrew Beckett

    Thanks, Andrew for your time and advice.

    One last question if possible:

    I need to do integration on a certain interval, e.g. t1 -> t2, then do some calculation on the output of integration and use the result as an initial condition for subsequent integration e.g. t2 -> t3 and so on

    I tried to do that as follows:

    //initialized ic and dh_dt
    integer ic = 0;
    real dh_dt = 1.591112;
    real dh, h_, h;
    real t_scale = 0.2 * 1e6;
    real t, t_prev;

    analog begin
    t = $abstime * t_scale;
    h_ = idt(t_scale * dh_dt, ic) + dh;
    if (t != t_prev) begin
    // .. some calc. on h_ to get h and new dh_dt
    dh = h - h_; 
    t_prev = t;
    end

    But that wasn't efficient, is there a direct way to do so?

    • 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