The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> Hidden states for PSS Analysis
https://designers-guide.org/forum/YaBB.pl?num=1217866408

Message started by emax on Aug 4th, 2008, 9:13am

Title: Hidden states for PSS Analysis
Post by emax on Aug 4th, 2008, 9:13am

I have read the article by Ken Kundert 'Hidden States in SpectreRF' but could not get rid of the hidden states for the following code. For the PSS analysis it generates error for variable 'i' for hidden state.
Please help!

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

module SAR_CL(vin,vclk,vd9,vd8,vd7,vd6,vd5,vd4,vd3,vd2,vd1,vd0,vdb9,vdb8,vdb7,vdb6,vdb5,vdb4,vdb3,vdb2,vdb1,vdb0);
input vin,vclk;
output vd9,vd8,vd7,vd6,vd5,vd4,vd3,vd2,vd1,vd0,vdb9,vdb8,vdb7,vdb6,vdb5,vdb4,vdb3,vdb2,vdb1,vdb0;
electrical vin,vclk,vd9,vd8,vd7,vd6,vd5,vd4,vd3,vd2,vd1,vd0,vdb9,vdb8,vdb7,vdb6,vdb5,vdb4,vdb3,vdb2,vdb1,vdb0,hold;

parameter real trise  = 100p  from [0:inf);
parameter real tfall  = 100p  from [0:inf);
parameter real tdel   = 10p   from [0:inf);
parameter real vtrans = 0.6 from [0:inf);
real comp_out;real result[0:10];
real resultb[0:10];
integer i;

  analog
  begin
     @ (initial_step)
     begin
        i = 10;
      result[10] = 1.2;
      result[9]  = 0;
      result[8]  = 0;
      result[7]  = 0;
      result[6]  = 0;
      result[5]  = 0;
      result[4]  = 0;
      result[3]  = 0;
      result[2]  = 0;
      result[1]  = 0;
      result[0]  = 0;
     end
     @ (cross(V(vclk) - vtrans, +1))
     begin
       comp_out = V(vin);
     if (comp_out > vtrans)
     begin
        result[i]    = 1.2;
        resultb[i]   = 0.0;
        result[i-1]  = 1.2;
        resultb[i-1] = 0.0;
     end
     else
     begin
        result[i]    = 0.0;
        resultb[i]   = 1.2;
        result[i-1]  = 1.2;
        resultb[i-1] = 0.0;
     end
     
       i = i - 1;
     if (i <= 0)
     begin
        i = 10;
        result[10] = 1.2;
        result[9]  = 0;
        result[8]  = 0;
        result[7]  = 0;
        result[6]  = 0;
        result[5]  = 0;
        result[4]  = 0;
        result[3]  = 0;
        result[2]  = 0;
        result[1]  = 0;
     end
     else
     begin
        i = i;
     end              
     end

     V(vd9)  <+ transition( result[10], tdel, trise, tfall );
     V(vd8)  <+ transition( result[9],  tdel, trise, tfall );
     V(vd7)  <+ transition( result[8],  tdel, trise, tfall );
     V(vd6)  <+ transition( result[7],  tdel, trise, tfall );
     V(vd5)  <+ transition( result[6],  tdel, trise, tfall );
     V(vd4)  <+ transition( result[5],  tdel, trise, tfall );
     V(vd3)  <+ transition( result[4],  tdel, trise, tfall );
     V(vd2)  <+ transition( result[3],  tdel, trise, tfall );
     V(vd1)  <+ transition( result[2],  tdel, trise, tfall );
     V(vd0)  <+ transition( result[1],  tdel, trise, tfall );

     V(vdb9) <+ transition( resultb[10], tdel, trise, tfall );
     V(vdb8) <+ transition( resultb[9],  tdel, trise, tfall );
     V(vdb7) <+ transition( resultb[8],  tdel, trise, tfall );
     V(vdb6) <+ transition( resultb[7],  tdel, trise, tfall );
     V(vdb5) <+ transition( resultb[6],  tdel, trise, tfall );
     V(vdb4) <+ transition( resultb[5],  tdel, trise, tfall );
     V(vdb3) <+ transition( resultb[4],  tdel, trise, tfall );
     V(vdb2) <+ transition( resultb[3],  tdel, trise, tfall );
     V(vdb1) <+ transition( resultb[2],  tdel, trise, tfall );
     V(vdb0) <+ transition( resultb[1],  tdel, trise, tfall );

  end

endmodule

Title: Re: Hidden states for PSS Analysis
Post by Geoffrey_Coram on Aug 4th, 2008, 10:59am

I haven't completely understood your model, but it looks like what you might want to try is to set "i" based on which voltage is above zero:
 if (V(vdb0) > 0) i = 0;
 else if (V(vdb1) > 0) i = 1;
 ..


Title: Re: Hidden states for PSS Analysis
Post by jbdavid on Aug 6th, 2008, 9:49am

you are using the variable i to "remember" the value over time.. THIS IS EXACTLY what causes a hidden state.
Save NO information , keep no HISTORY in a VARIABLE..
- instead use a capacitor as an integrator to store the information you want to keep. since a capacitor is Electrical - spectreRF can "see" it and there is no hidden state..
--
good luck

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.