• 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. Simulation issue with ideal relay implemented in verilog...

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 126
  • Views 16792
  • 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

Simulation issue with ideal relay implemented in verilog a

lahsivece
lahsivece over 11 years ago

 Hi ,

 I am trying to simulate a verilog a relay . Please find the code below (The designer's guide to verilog AMS; Chap 3 listing 13)

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

module SWITCH(inp, inn, outp, outn);
input inp,inn;
parameter real switch1=0;
electrical inp, inn, outp, outn;
analog begin
    @(cross(V(inp,inn)-switch1,1))
;
    if(V(inp,inn) > switch1)
        V(outp,outn) <+ 0.0;
    else
    I(outp,outn) <+ 0.0;

end

endmodule

The testbench for simulation and output wavforms are shown below.

If the "switch" waveform (which controls the switch) is switching, shouldn't the output be switching also. Please advise

 

  • OUTPUT.png
  • View
  • Hide
  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    This probably depends on the rest of your circuit. I'd not seen the schematic until I clicked on the image - but what's happening is that the capacitor is being charged up (instantaneously, since there's no impedance) and then holding that voltage when the relay is open - because there's nothing to discharge it. Even if you ended up with a gmin resistor (which I don't think you do), that would be a time constant of 1s. Try adding a 10M resistor in parallel with the capacitor, and you'll then see it start to discharge during the off cycles.

    I'd checked it with this circuit below and got the attached waveforms before I saw the picture:

    //
    v1 (sinin 0) vsource type=sine freq=5k ampl=1
    v2 (clk 0) vsource type=pulse val0=0 val1=1 rise=1u fall=1u period=20u width=10u
    I1 (clk 0 sinin sinout) SWITCH switch1=0.5
    r2 (sinout 0) resistor r=100k

    ahdl_include "SWITCH.va"

    tran tran stop=200u

    As you can see, it's working fine.

    Regards,

    Andrew.

    • SWITCH.png
    • View
    • Hide
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Marah
    Marah over 6 years ago in reply to Andrew Beckett

    Hello, 

    I am trying to simulate NEM relay based inverter using verilog-a .  Please find the code below  

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

    module OHMIC_CANTILEVER_RF_MEMS_SWITCH(s,d,g);  inout s, d, g;  electrical s, d, g;  kinematic z, velocity;

    // Dimensions   parameter real g_0=0.6e-6 from (0:inf); // nominal gap height [m]  parameter real g_d=0.2e-6 from (0:inf); // nominal gap height minus dimple thickness [m]  parameter real l=75e-6 from (0:inf); // beam length [m]  parameter real t=5e-6 from (0:inf); // beam thickness [m]  parameter real w=30e-6 from (0:inf); // beam width [m]  parameter real W_c=10e-6 from (0:inf); // contact width [m]  parameter real W=10e-6 from (0:inf); // electrode width [m]  parameter real x=30e-6 from (0:inf); // beam anchor to electrode edge distance [m]  // Electrical parameters  parameter real R_c=1.0 from [0:inf); // contact resistance [Ohm]  // Material parameters: beam (gold)  parameter real rho=19.2e3 from (0:inf); // mass density [kg/m^3]  parameter real E=78e9 from (0:inf); // Young's modulus [Pa]  // Material parameters: gas (air):  parameter real lambda=1.5e-7 from [0:inf); // mean-free path [m]  parameter real mu=1.845e-5 from (0:inf); // viscosity coefficient [kg/(m.s)]  // van der Waals and nuclear force coefficients  parameter real c_1=10e-80 from [0:inf); // van der Waals force coefficient [N.m]  parameter real c_2=10e-75 from [0:inf); // nuclear force coefficient [N.m^8]

    real A, b, C_ds, C_gs, C_u, F_c, F_e, F_s, f_m_0, I1, I2, IIP3, k_1, m, Q_e, Q_m, t_s_max, t_s_min, V_H, V_P, V_S;

    analog begin

    @ ( initial_step ) begin  A=W*w;  $strobe("\n%M: A (electrode area [m^2]) = %E",A);  m=0.4*rho*l*t*w;  $strobe("%M: m (effective beam mass [kg]) = %E",m);  k_1=2*E*w*pow(t/l,3)*(1-x/l)/(3-4*pow(x/l,3)+pow(x/l,4));  $strobe("%M: k_1 (spring constant [N/m]) = %E",k_1);  V_H=sqrt(2*k_1*(g_0-g_d)*pow(g_d,2)/(`P_EPS0*A));  $strobe("%M: V_H (hold-down voltage [V]) = %E",V_H);  V_P=sqrt(8*k_1*pow(g_0,3)/(27*A*`P_EPS0));  $strobe("%M: V_P (pull-in voltage [V]) = %E",V_P);  f_m_0=sqrt(k_1/m)/(2*`M_PI);  $strobe("%M: f_m_0 (mechanical resonant frequency [Hz]) = %E",f_m_0);  Q_m=(sqrt(E*rho)*pow(t,2)*pow(g_0,3))/(mu*pow(w*l,2));  $strobe("%M: Q_m (mechanical quality factor []) = %E",Q_m);  V_S=V_P;  t_s_max=27*pow(V_P,2)/(4*2*`M_PI*f_m_0*Q_m*pow(V_S,2));  $strobe("%M: t_s_max (maximum switching time [s], V_S = V_P) = %E",t_s_max);  t_s_min=3.67*V_P/(V_S*sqrt(k_1/m));  $strobe("%M: t_s_min (minimum switching time [s], V_S = V_P) = %E",t_s_min);  C_u=`P_EPS0*W_c*w/g_0;  $strobe("%M: C_u (up-state capacitance [F]) = %E",C_u);  IIP3=10*log(2*k_1*pow(g_0,2)/(`M_PI*10e9*pow(C_u*50,2)))+30;  $strobe("%M: IIP3 (third order intercept [dBm], C=C_u, delta_f < f_m_0, f=10 GHz, Z=50 Ohm) = %E",IIP3);  end

    // b: damping coefficient [N.s/m] (displacement-compensated squeeze-film damping)  Q_e=Q_m*pow(1.1-pow(g_d*tanh(Pos(z)/g_d)/g_0,2),1.5)*(1+9.9638*pow(lambda/(g_0-g_d*tanh(Pos(z)/g_d)),1.159));  $strobe("\n%M: Q_e (displacement-compensated mechanical quality factor []) = %E",Q_e);  b=k_1/(2*`M_PI*f_m_0*Q_e);  $strobe("%M: b (damping coefficient [N.s/m]) = %E",b);

    // Forces  F_c=c_1*W_c*w/pow(g_d-g_d*tanh(Pos(z)/g_d)+1e-9,3)-c_2*W_c*w/pow(g_d-g_d*tanh(Pos(z)/g_d)+1e-9,10);  $strobe("%M: F_c (attractive van der Waals and repulsive nuclear forces [N]) = %E",F_c);  F_e=`P_EPS0*A*pow(V(s,g),2)/2*1/pow(g_0-Pos(z),2);  //F_e=`P_EPS0*A*pow(V(s,g),2)/2*1/pow(g_0-g_d*tanh(Pos(z)/g_d),2); // Envelope simulation  $strobe("%M: F_e (electrostatic force [N]) = %E",F_e);  F_s=k_1*Pos(z);  //F_s=k_1*g_d*tanh(Pos(z)/g_d); // Envelope simulation  $strobe("%M: F_s (spring force [N]) = %E",F_s);

    // Nonlinear state-space description  Pos(velocity):ddt(Pos(z))==Pos(velocity);  Pos(z):ddt(Pos(velocity))==1/m*(-b*Pos(velocity)-F_s+F_e+F_c+white_noise(4*`P_K*$temperature*b, "BROWNIAN_NOISE"));

    C_ds=`P_EPS0*W_c*w/(g_0-Pos(z));  I1=ddt(C_ds*V(d,s));  I2=V(d,s)/R_c+white_noise(4*`P_K*$temperature/R_c, "JOHNSON_NYQUIST_NOISE_R_c");  if (Pos(z)<g_d)  I(d,s)<+I1;  else  I(d,s)<+I2;

    C_gs=`P_EPS0*A/(g_0-Pos(z));  I(g,s)<+ddt(C_gs*V(g,s));

    end

    endmodule

     The testbench for simulation and output wavforms are attached below. I am not getting the correct output waveforms and I do not know why.  

    Thank you in advance,

    Marah

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Marah
    Marah over 6 years ago in reply to Andrew Beckett

    Hello, 

    I am trying to simulate NEM relay based inverter using verilog-a .  Please find the code below  

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

    module OHMIC_CANTILEVER_RF_MEMS_SWITCH(s,d,g);  inout s, d, g;  electrical s, d, g;  kinematic z, velocity;

    // Dimensions   parameter real g_0=0.6e-6 from (0:inf); // nominal gap height [m]  parameter real g_d=0.2e-6 from (0:inf); // nominal gap height minus dimple thickness [m]  parameter real l=75e-6 from (0:inf); // beam length [m]  parameter real t=5e-6 from (0:inf); // beam thickness [m]  parameter real w=30e-6 from (0:inf); // beam width [m]  parameter real W_c=10e-6 from (0:inf); // contact width [m]  parameter real W=10e-6 from (0:inf); // electrode width [m]  parameter real x=30e-6 from (0:inf); // beam anchor to electrode edge distance [m]  // Electrical parameters  parameter real R_c=1.0 from [0:inf); // contact resistance [Ohm]  // Material parameters: beam (gold)  parameter real rho=19.2e3 from (0:inf); // mass density [kg/m^3]  parameter real E=78e9 from (0:inf); // Young's modulus [Pa]  // Material parameters: gas (air):  parameter real lambda=1.5e-7 from [0:inf); // mean-free path [m]  parameter real mu=1.845e-5 from (0:inf); // viscosity coefficient [kg/(m.s)]  // van der Waals and nuclear force coefficients  parameter real c_1=10e-80 from [0:inf); // van der Waals force coefficient [N.m]  parameter real c_2=10e-75 from [0:inf); // nuclear force coefficient [N.m^8]

    real A, b, C_ds, C_gs, C_u, F_c, F_e, F_s, f_m_0, I1, I2, IIP3, k_1, m, Q_e, Q_m, t_s_max, t_s_min, V_H, V_P, V_S;

    analog begin

    @ ( initial_step ) begin  A=W*w;  $strobe("\n%M: A (electrode area [m^2]) = %E",A);  m=0.4*rho*l*t*w;  $strobe("%M: m (effective beam mass [kg]) = %E",m);  k_1=2*E*w*pow(t/l,3)*(1-x/l)/(3-4*pow(x/l,3)+pow(x/l,4));  $strobe("%M: k_1 (spring constant [N/m]) = %E",k_1);  V_H=sqrt(2*k_1*(g_0-g_d)*pow(g_d,2)/(`P_EPS0*A));  $strobe("%M: V_H (hold-down voltage [V]) = %E",V_H);  V_P=sqrt(8*k_1*pow(g_0,3)/(27*A*`P_EPS0));  $strobe("%M: V_P (pull-in voltage [V]) = %E",V_P);  f_m_0=sqrt(k_1/m)/(2*`M_PI);  $strobe("%M: f_m_0 (mechanical resonant frequency [Hz]) = %E",f_m_0);  Q_m=(sqrt(E*rho)*pow(t,2)*pow(g_0,3))/(mu*pow(w*l,2));  $strobe("%M: Q_m (mechanical quality factor []) = %E",Q_m);  V_S=V_P;  t_s_max=27*pow(V_P,2)/(4*2*`M_PI*f_m_0*Q_m*pow(V_S,2));  $strobe("%M: t_s_max (maximum switching time [s], V_S = V_P) = %E",t_s_max);  t_s_min=3.67*V_P/(V_S*sqrt(k_1/m));  $strobe("%M: t_s_min (minimum switching time [s], V_S = V_P) = %E",t_s_min);  C_u=`P_EPS0*W_c*w/g_0;  $strobe("%M: C_u (up-state capacitance [F]) = %E",C_u);  IIP3=10*log(2*k_1*pow(g_0,2)/(`M_PI*10e9*pow(C_u*50,2)))+30;  $strobe("%M: IIP3 (third order intercept [dBm], C=C_u, delta_f < f_m_0, f=10 GHz, Z=50 Ohm) = %E",IIP3);  end

    // b: damping coefficient [N.s/m] (displacement-compensated squeeze-film damping)  Q_e=Q_m*pow(1.1-pow(g_d*tanh(Pos(z)/g_d)/g_0,2),1.5)*(1+9.9638*pow(lambda/(g_0-g_d*tanh(Pos(z)/g_d)),1.159));  $strobe("\n%M: Q_e (displacement-compensated mechanical quality factor []) = %E",Q_e);  b=k_1/(2*`M_PI*f_m_0*Q_e);  $strobe("%M: b (damping coefficient [N.s/m]) = %E",b);

    // Forces  F_c=c_1*W_c*w/pow(g_d-g_d*tanh(Pos(z)/g_d)+1e-9,3)-c_2*W_c*w/pow(g_d-g_d*tanh(Pos(z)/g_d)+1e-9,10);  $strobe("%M: F_c (attractive van der Waals and repulsive nuclear forces [N]) = %E",F_c);  F_e=`P_EPS0*A*pow(V(s,g),2)/2*1/pow(g_0-Pos(z),2);  //F_e=`P_EPS0*A*pow(V(s,g),2)/2*1/pow(g_0-g_d*tanh(Pos(z)/g_d),2); // Envelope simulation  $strobe("%M: F_e (electrostatic force [N]) = %E",F_e);  F_s=k_1*Pos(z);  //F_s=k_1*g_d*tanh(Pos(z)/g_d); // Envelope simulation  $strobe("%M: F_s (spring force [N]) = %E",F_s);

    // Nonlinear state-space description  Pos(velocity):ddt(Pos(z))==Pos(velocity);  Pos(z):ddt(Pos(velocity))==1/m*(-b*Pos(velocity)-F_s+F_e+F_c+white_noise(4*`P_K*$temperature*b, "BROWNIAN_NOISE"));

    C_ds=`P_EPS0*W_c*w/(g_0-Pos(z));  I1=ddt(C_ds*V(d,s));  I2=V(d,s)/R_c+white_noise(4*`P_K*$temperature/R_c, "JOHNSON_NYQUIST_NOISE_R_c");  if (Pos(z)<g_d)  I(d,s)<+I1;  else  I(d,s)<+I2;

    C_gs=`P_EPS0*A/(g_0-Pos(z));  I(g,s)<+ddt(C_gs*V(g,s));

    end

    endmodule

     The testbench for simulation and output wavforms are attached below. I am not getting the correct output waveforms and I do not know why.  

    Thank you in advance,

    Marah

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to Marah
    Marah said:
    I am not getting the correct output waveforms and I do not know why.

    Me neither. I don't know what you're expecting the waveforms to look like because you didn't say - most likely it's because either your model is incorrectly modelling what you think you're modelling, or your expectations of what it's supposed to do are incorrect. 

    I have absolutely no idea why you've posted on the end of a topic which has virtually no relationship to your question (other than being about Verilog-A). Your question is about a MEMS relay, whereas the original post was about a simple electrical switch. 

    Also (and this is important) the Forum Guidelines clearly tell you not to post on the end of old threads, and to provide as much relevant data as you can.

    Kindest Regards,

    Andrew.

    • 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