• 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. ddt() at a certain timestep in Verilog-A

Stats

  • Locked Locked
  • Replies 11
  • Subscribers 125
  • Views 15868
  • 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

ddt() at a certain timestep in Verilog-A

rhanna
rhanna over 4 years ago

Hi,

if

electrical [0:n] x_node;
electrical [0:n] d;
parameter real n=5;
real a=1e-9;
genvar i;
//...
for(i=0; i<n; i=i+1) begin
     V(d[i])<+ a*ddt(V(x_node[i]));
end
//...

Is it possible to find V(d[i]) at a certain timestep? How?

Regards,
Ramy

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago
    rhanna said:
    Is it possible to find V(d[i]) at a certain timestep? How?

    What do you mean by this? You can plot the signal if you wish - is that what you want?

    Andrew

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

    Hi Andrew,

    V(d[i]) is ddt() of the signal V(x_node[i])

    I know that the simulator chooses deltaT but I need to find the derivative at some specific timesteps to use it in the same code

    for example something like:  ddt(V(x_node[i]) + 0.5*(1-alpha)*h*V(d[i])) , but this will be just ddt(V(x_node[i]))

    Is there a way to implement this?

    Thanks

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

    I'm not sure you really made it much clearer - what isn't clear is what you mean by "some specific timesteps". Perhaps you are wanting to have some expression which uses the value from some fixed delay beforehand (in which case you could use the delay() function), or maybe you could use @(timer(...)) to regularly sample the value and derivative and then combine the current and previous samples in some way. However, I'm just guessing what your actual intention is here - that's what's not obvious from your question.

    Andrew

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

    Hi Andrew,

    I have discrete state-space equations 
    in the form:
    Xi = A.Xi-1 + B.Ui
    Yi = C.Xi

    I need to convert these difference equations into differential to be solved by the simulator
    for example by the aid of forward Euler method we can say:
    Xi = X + (1-alpha).h.ddt(X)           at t = ti-1 + alpha.h
    Xi-1 = X - alpha.h.ddt(X)

    after plugging Xi and Xi-1, the simulator solves for X

    As forward Euler is not so efficient, I'm trying to approx. the state-space equations using Runge-Kutta method RK4 https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods:
    where Xi = X + (1-alpha).h.1/6.(K1 + 2K2 + 2K3 + K4)
    K1: derivative at initial point, K2 and K3 are mid-point derivatives and K4 is the derivative at the endpoint.

    In Verilog-A:
    K1 <+ ddt(V(X_node));
    but how can K2, K3, K4 be implemented?

    I hope my idea is clear now.

    Thanks for your care.

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

    I'm a bit rusty on this, but I think the best solution would be to convert the discrete state-space representation into the z-domain and then you can use the zi_zp or zi_nd functions in Verilog-A to easily represent the system in the z-domain. See this http://mocha-java.uccs.edu/ECE5710/ECE5710-Notes05.pdf (I'm sure there are many other places that would describe this). This seems the simplest way - utilising a built-in feature of Verilog-A rather than doing all the work yourself.

    Otherwise you could probably implement some kind of sampling using @(timer) as I suggested to do what you're asking, but I've never tried doing that to implement a differential equivalent of the state space equations, so I can't say for certain (and I don't have the time to think it through, do experiments and so on) whether it is the right approach or not. 

    Andrew

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

    Thanks, Andrew for your time.

    Maybe with MATLAB also, there can be a move to the Z domain then by d2c() we can transform the TF to the S domain. The problem that the sampling time is fixed.

    In order to have a variable timestep, the simulator should solve the differential equations which should come from the state-space difference equations.

    Regarding the usage of @timer(start_time, period)

    the period is the time taken from the start_time at which there's a value for X or ddt(X). How can I know this during the runtime?

    Regards,

    Ramy

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

    Ramy,

    I thought you said your state space equations were discrete state space equations. If so, transforming them to the Z-domain makes most sense, and then there is a discrete time step. The zi_zp or zi_nd functions (and the other combinations) are told the period for the z-domain system. The simulator itself can still have variable time steps.

    Maybe I'm misunderstanding something in what you're asking. If they were continuous time state space equations, you could convert them to a Laplace transform (s-domain) representation and use the laplace_zp, laplace_nd functions in Verilog-A.

    Andrew.

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

    Dear Andrew,

    The state-space equations are discrete, let's say the output is Y[n] = C.X[n]. The Z-transform filter output is Y(z). I'm looking for Y(t).

    How can that be reached through Verilog-A? 

    Ramy

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

    Ramy,

    That’s exactly what the zi_* functions do. You give them the zeros and poles or numerator and denominator of the z-domain transfer function, the discrete period and the time domain input signal and it will give you the time domain response. 

    Andrew

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

    Thanks for your explanation. 

    This would help a lot if the system is linear.

    In some cases, the system is non-linear for example: X[n+1] = tanh(A.X[n] + B.U[n] + C) and it will be so hard to find a TF.

    Do you have any advice on how can I deal with this or in this case I have to work in the time domain?

    Ramy

    • 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