• 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. "ERROR: attempt to access a quantity that depends on the...

Stats

  • Locked Locked
  • Replies 13
  • Subscribers 126
  • Views 5292
  • 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

"ERROR: attempt to access a quantity that depends on the time derivative" in Verilog-A

rhanna
rhanna over 4 years ago


Hi,

I'm new to verilogA and trying to compile a module including the following nested loop in an analog process:

for(k=0; k<5; k=k+1) begin
     for(j=0; j<25; j=j+1) begin
          I(x_node[k])<+ V(x_node[k]) + (1-alpha)* h*ddt(V(x_node[k])) - tanh(mul_Vin_w_Vin + mul_c_w_Vin + w_rec[j]*(V(x_node[k]) - alpha* h*ddt(V(x_node[k]))) + b_node[k]);
          V(Vout)<+ w_Vout[k] * V(x_node[k]) + b_Vout;
     end
end

where: 
=====
k, j are genvars.
x_node is a vector of internal nodes.
h, mul_Vin_w_Vin, mul_c_w_Vin, alpha, b_Vout are assumed to be constants.
w_rec, b_node, w_Vout are parameter vectors.
Vout is an output port.


I'm trying to force the current branched from these nodes to 0 and use the simulator to solve for V(x_node[k]).

I had this error at the bolded line:

Error: Encountered an attempt to access a quantity that depends on the time derivative. The software allows only symbolic use of such quantities. Either remove the need to access this quantity or create an internal node, assign the voltage of the internal node to this quantity, and access the voltage of the internal node.

I couldn't fully understand what's the problem with using "ddt()" in the expression, Can you please explain a bit more about the problem and the suggested solution? 

Thanks in advance,
Ramy

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    Ramy,

    The challenge is that the simulator needs to keep track of the history when computing a derivative, and it's hard to do that when it's embedded within an expression (in this case it's within the argument to tanh). You can workaround this by using a temporary internal node - something like:

    V(tempNode[k]) <+ alpha* h*ddt(V(x_node[k]));
    I(x_node[k])<+ V(x_node[k]) + (1-alpha)* h*ddt(V(x_node[k])) - tanh(mul_Vin_w_Vin + mul_c_w_Vin + w_rec[j]*(V(x_node[k]) - V(tempNode[k])) + b_node[k]);

    You'd declare tempNode as and internal node:

    electrical[0:5] tempNode;

    Note that you may need to scale the value appropriately to ensure that the voltage is reasonable (I don't know enough about the system or the coefficients to understand the magnitude of the result of this part of the expression). In essence you want the voltages to be similar range to those in the rest of the circuit to prevent convergence/accuracy issues (so probably up to a few volts, no more).

    Regards,

    Andrew.

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

    Hi Andrew,

    Thanks a lot for your explanation.

    In the meantime after posting my question, I tried the same idea:

    ////////////////////////////////////////////
    electrical [0:5] d;
    //..
    for(k=0; k<5; k=k+1) begin
         for(j=0; j<25; j=j+1) begin
              V(d[k])<+ h*ddt(V(x_node[k]));
              I(x_node[k])<+ V(x_node[k]) + (1-alpha)* h*ddt(V(x_node[k])) - tanh(mul_Vin_w_Vin + mul_c_w_Vin + w_rec[j]*(V(x_node[k]) - alpha*V(d[k]) + b_node[k]);
              V(Vout)<+ w_Vout[k] * V(x_node[k]) + b_Vout;
         end
    end
    /////////////////////////////////////////

    > I have a syntax error in the above-bolded part which I couldn't debug. Can you please guide me?

    > I understand your point about scaling and that's the purpose of having alpha.

    Regards,

    Ramy

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

    Hi Ramy,

    You're missing a close parenthesis (I've added it back - and highlighted it in red below):

    I(x_node[k])<+ V(x_node[k]) + (1-alpha)* h*ddt(V(x_node[k])) - tanh(mul_Vin_w_Vin + mul_c_w_Vin + w_rec[j]*(V(x_node[k]) - alpha*V(d[k])) + b_node[k]);

    Andrew

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

    Thanks for debugging this.

    After correction, it seems to have the initial error.



    Ramy

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

    Which version of Spectre are you using? In the terminal window type "spectre -W" to find this out.

    Andrew

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

    It's 19.1.0.496.isr12

    Ramy

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

    I see you made another small change from that image, but even with that, I can't reproduce it (even with the same version of Spectre). Perhaps I couldn't spot a small difference somewhere.

    It's probably easier if you post the entire code - at the moment I'm making stuff up around the bit you've shown here, and maybe the problem is dependent upon the context it's in? Hard to be sure (since I can't reproduce it).

    Andrew

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

    Dear Andrew,

    Basically, the idea is to implement a RNN (Recurrent Neural Network) model in Verilog-A language.
    Since Verilog-A is compatible with the simulator, the system of equations derived from the model (like (1) & (2) in the listing below) can be solved.

    Let's assume a single-input-single-output model for simplicity. Kindly check below for a sample to what I'm trying to implement:

    /////////////////////////////////////////////////////////////////////////////////

    `include "constants.vams"
    `include "disciplines.vams"

    module test ( out, in );

    //port declaration


    input in;
    output out;
    electrical in, out;
    parameter integer n=5; //n: size of internal nodes
    electrical [0:n-1] x_node; //x_node: internal node (hidden nodes)
    electrical [0:n-1] d; //d: temperory internal node

    //parameters declaration
    //below w -> refers to weight, b -> refers to bias, which are the hyper-parameters coming from the learning process


    parameter real h=2e-12;
    parameter real alpha=0.1;
    parameter real w_in [0:n-1]='{0,0,0,0,0};
    //parameter real w_rec [0:n-1][0:n-1]= '{'{0,0,0,0,0},'{0,0,0,0,0},'{0,0,0,0,0},'{0,0,0,0,0},'{0,0,0,0,0}}; //not allowed in Verilog-A
    //flatten w_rec
    parameter real w_rec [0:24]= '{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //generally [0:pow(n,2)-1] 
    parameter real w_out [0:n-1]='{0,0,0,0,0};
    parameter real b_node [0:n-1]='{0,0,0,0,0}; 
    parameter real b_out=0;

    //variables declaration

    real c;
    genvar i, j, k; //iterators -> declared as genvar to use analog operators within the loop
    real mul_in_w_in, mul_c_w_in; // mul -> refers to a product

    analog begin

              //1.evaluate c
              c= h * ddt(V(in));

             //2.evalute in*w_in & c*w_in
             for(i=0; i<n; i=i+1) begin
                  mul_in_w_in = mul_in_w_in + w_in[i] * V(in);
                  mul_c_w_in = mul_c_w_in + w_in[i] * c * (1-alpha);
             end

             //3.evaluate V(x_node)
             for(k=0; k<5; k=k+1) begin
                  for(j=0; j<25; j=j+1) begin
                       V(d[k])<+ h * ddt(V(x_node[k]));
                       I(x_node[k])<+ V(x_node[k]) + (1-alpha) * V(d[k]) - tanh(mul_in_w_in + mul_c_w_in + w_rec[j] * (V(x_node[k]) - alpha * V(d[k])) + b_node[k]); //(1)
                       V(out)<+ w_out[k] * V(x_node[k]) + b_out; //(2)
                  end
             end
       end

    endmodule

    //////////////////////////////////////////////////////////////////////////////////////////////

    Regards,

    Ramy

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

    Hi Ramy,

    The issue is because of the assignment to the variable c earlier in the analog block - that's then used in the calculation of mul_c_w_in in step 2, and then that's used within the tanh() in step 3. So it's the same as before - you need to have somewhere to compute the derivative in the matrix. So using the same trick (and I'll leave it to you to play with scaling) solves this - defining cc as electrical (I could have changed c to be electrical rather than real, but I made the node called cc instead), and then:

              //1.evaluate c
    //          c= h * ddt(V(in));
              V(cc) <+ h * ddt(V(in));
    
             //2.evalute in*w_in & c*w_in
             for(i=0; i<n; i=i+1) begin
                  mul_in_w_in = mul_in_w_in + w_in[i] * V(in);
                  mul_c_w_in = mul_c_w_in + w_in[i] * V(cc) * (1-alpha);
             end
    
             //3.evaluate V(x_node)
             for(k=0; k<5; k=k+1) begin
                  for(j=0; j<25; j=j+1) begin
                       V(d[k])<+ h * ddt(V(x_node[k]));
                       I(x_node[k])<+ V(x_node[k]) + (1-alpha) * V(d[k]) - tanh(mul_in_w_in + mul_c_w_in + w_rec[j] * (V(x_node[k]) - alpha * V(d[k])) + b_node[k]); //(1)
                       V(out)<+ w_out[k] * V(x_node[k]) + b_out; //(2)
                  end
             end
       end

    Regards,

    Andrew

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

    Dear Andrew,

    Thanks for your help.

    The code went through but I have a problem with convergence where V(out) is fixed at some high value of voltage while it should be transitioning between 0 and 1 V.

    -> According to my knowledge, I have to keep the simulation timestep as small as possible to let the system converge.
     
    Here, I assume:  t = t_prev + alpha * h 

    where h: is a fixed timestep taken during sample generation for learning my model.
               alpha: is a parameter between 0 and 1 to control the simulation timestep (alpha * h).

    and it's clear if I set alpha to values close to 1 the system stability deteriorates.

    -> Recalling your hint:

    "Note that you may need to scale the value appropriately to ensure that the voltage is reasonable (I don't know enough about the system or the coefficients to understand the magnitude of the result of this part of the expression). In essence, you want the voltages to be similar range to those in the rest of the circuit to prevent convergence/accuracy issues (so probably up to a few volts, no more)."

    I'm a bit confused about what happened when the time derivative is assigned to the voltage of an internal node and the consequences of this on convergence.
    Could you please clarify this point? I would appreciate if you can give an example on how voltage should be scaled.

    Thanks in advance for your time,

    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