The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Mar 28th, 2024, 11:44pm
Pages: 1
Send Topic Print
Op-amp Macro Model in ahdlLib (Read 3337 times)
hchanda
Community Member
***
Offline



Posts: 33

Op-amp Macro Model in ahdlLib
Dec 05th, 2006, 3:42pm
 
Hi,

I have seen earlier postings on understanding the op-amp macro model in ahdlLib (not an ideal one).
But if I want to use it as a ideal op-amp, I defined very high gain, high input resistance, high unity gain frequency and very low output resistance .
I was using op-amp in the inverting mode , where there is a resistor between input source and in- and a feedback resistor from output to in-.
The in+ is grounded and I have also grounded the vref too.

gain=100e10
rin=100e10
rout=0
Fu=100e10

Vin=1.65V
R1=2K (between input source and in-)
Rfeedback=1K
vsupply+=1.65
vsupply-=0
Then by simulating this I would expect output to be -825mV which is not what I am getting from the model.

By looking into the verilog-A model it is not very clear to me how it is calculating the output voltage of an opamp.
Can anyone please provide the information on the calculation of opamp output voltage? (for the opamp in ahdlLib).

Thanks in advance,
hc
Back to top
 
 

hc
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1998
Massachusetts, USA
Re: Op-amp Macro Model in ahdlLib
Reply #1 - Dec 6th, 2006, 4:18am
 
The opamp.va module that I see has output limiting such that the output voltage can't go (much?) below the negative supply, which in your case is 0.  Hence, I would not expect an output of -825mV.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
hchanda
Community Member
***
Offline



Posts: 33

Re: Op-amp Macro Model in ahdlLib
Reply #2 - Dec 7th, 2006, 3:10pm
 
Oops ! I didn't realize that I was giving 0V as negative power supply, Thank you
But still like to know how it calculates the output voltage. I appreciate your time and help
hc








Back to top
 
 

hc
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1998
Massachusetts, USA
Re: Op-amp Macro Model in ahdlLib
Reply #3 - Dec 8th, 2006, 11:56am
 
I see the module contributing a current that is a gain (gm_nom) times the input voltage difference.  So, I guess it's not really computing the voltage, but rather supplying a current that works with the feedback network to determine the voltage.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: Op-amp Macro Model in ahdlLib
Reply #4 - Dec 8th, 2006, 2:50pm
 
All,
   Please remember that this forum is a general resource for everyone. As such, you should try to ask your questions in a way that everyone benefits from the answer. In that spirit, if you have a question or comment about a model, you should include the model here or give a pointer to where it is publicly available. If you ask about proprietary models that many visitors do not have access to, then you limit the number of people that can answer your question and the number that benefit from a response. If you really need to ask a question about a proprietary model, try to develop an abstract or alternate version that exhibits the same behavior and use that to ask your question.

Thanks,
-Ken
Back to top
 
 
View Profile WWW   IP Logged
hchanda
Community Member
***
Offline



Posts: 33

Re: Op-amp Macro Model in ahdlLib
Reply #5 - Dec 8th, 2006, 5:03pm
 
Geoffrey thank you for the answer.

Ken, I'll take care to follow your suggestion. I completely agree with you.
The model is

// Based on the OVI Verilog-A Language Reference Manual, version 1.0 1996
//
//

`define PI      3.14159265358979323846264338327950288419716939937511



//--------------------
// opamp
//
// -  operational amplifier
//
// vin_p,vin_n: differential input voltage [V,A]
// vout:        output voltage [V,A]
// vref:        reference voltage [V,A]
// vspply_p:    positive supply voltage [V,A]
// vspply_n:    negative supply voltage [V,A]
//
// INSTANCE parameters
//    gain           = gain []
//    freq_unitygain = unity gain frequency [Hz]
//    rin            = input resistance [Ohms]
//    vin_offset     = input offset voltage referred to negative [V]
//    ibias          = input current [A]
//    iin_max           = maximum current [A]
//    slew_rate      = slew rate [A/F]
//    rout           = output resistance [Ohms]
//    vsoft          = soft output limiting value [V]
//
// MODEL parameters
//    {none}
//

module opamp(vout, vref, vin_p, vin_n, vspply_p, vspply_n);
input vref, vspply_p, vspply_n;
inout vout, vin_p, vin_n;
electrical vout, vref, vin_p, vin_n, vspply_p, vspply_n;
parameter real gain = 835e3;
parameter real freq_unitygain  = 1.0e6;
parameter real rin = 1e6;
parameter real vin_offset = 0.0;
parameter real ibias = 0.0;
parameter real iin_max = 100e-6;
parameter real slew_rate = 0.5e6;
parameter real rout = 80;
parameter real vsoft = 0.5;
  real c1;
  real gm_nom;
  real r1;
  real vmax_in;
  real vin_val;

  electrical cout;

analog begin

     @ ( initial_step or initial_step("dc") ) begin
        c1 = iin_max/(slew_rate);
        gm_nom = 2 * `PI * freq_unitygain * c1;
        r1 = gain/gm_nom;
        vmax_in = iin_max/gm_nom;
     end

     vin_val = V(vin_p,vin_n) + vin_offset;

     //
     // Input stage.
     //
     I(vin_p, vin_n) <+ (V(vin_p, vin_n) + vin_offset)/ rin;
     I(vref, vin_p) <+ ibias;
     I(vref, vin_n) <+ ibias;

     //
     // GM stage with slewing
     //
     I(vref, cout) <+ V(vref, cout)/100e6;

     if (vin_val > vmax_in)
        I(vref, cout) <+ iin_max;
     else if (vin_val < -vmax_in)
        I(vref, cout) <+ -iin_max;
     else
        I(vref, cout) <+ gm_nom*vin_val ;

     //
     // Dominant Pole.
     //
     I(cout, vref) <+ ddt(c1*V(cout, vref));
     I(cout, vref) <+ V(cout, vref)/r1;

     //
     // Output Stage.
     //
     I(vref, vout) <+ V(cout, vref)/rout;
     I(vout, vref) <+ V(vout, vref)/rout;

     //
     // Soft Output Limiting.
     //
     if (V(vout) > (V(vspply_p) - vsoft))
        I(cout, vref) <+ gm_nom*(V(vout, vspply_p)+vsoft);
     else if (V(vout) < (V(vspply_n) + vsoft))
        I(cout, vref) <+ gm_nom*(V(vout, vspply_n)-vsoft);
  end
endmodule



Back to top
 
 

hc
View Profile   IP Logged
jbdavid
Community Fellow
*****
Offline



Posts: 378
Silicon Valley
Re: Op-amp Macro Model in ahdlLib
Reply #6 - Dec 8th, 2006, 9:31pm
 
The output stage is a norton equivalent circuit..
current source into a resistor.. if there is No other resistance on vout node (ie its open!)
then V(vout,ref) = V(cout,ref)
since the current source is effectively a vccs with a gain of 1/rout dependent on V(cout,ref)

Once you understand this part, you can write out a "macromodel" of the model to understand how it works
(assuming you understand macro models.. ) - but its easier to assume a bias point and do it - ignoring things (for the first cut) like the output voltage clamp..

Then you can add in the secondary effects like the voltage clamp.
Do this about 200 times, and you 'll stop writing out macromodel diagrams..
If you can't wait quite that long, you might take a look at the tool from Lynguent that will keep a schematic of the model you are writing, in parallel with the code..
Good luck

hchanda wrote on Dec 8th, 2006, 5:03pm:
     //
     // Output Stage.
     //
     I(vref, vout) <+ V(cout, vref)/rout;
     I(vout, vref) <+ V(vout, vref)/rout;


Back to top
 
 

jbdavid
Mixed Signal Design Verification
View Profile WWW   IP Logged
smchiu
Junior Member
**
Offline



Posts: 11

Re: Op-amp Macro Model in ahdlLib
Reply #7 - Jul 26th, 2007, 3:46pm
 
Hi,

I have looked at the above code and have a question.
Under the "Dominant Pole" section, why is there two assignments to I(cout, vref)?
Sams as under the "output stage" section, two assignments to I(vref,vout) & I(vout,vref).

Thanks a lot, guys.
David.
Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Op-amp Macro Model in ahdlLib
Reply #8 - Jul 27th, 2007, 1:49am
 
Hi David,
Verilog-A defines that all contribution statements (assignments) to a current are added up, so under the dominant pole section, the first contribution is the Cap and the second the Res of the pole.

BOE
Back to top
 
 
View Profile   IP Logged
smchiu
Junior Member
**
Offline



Posts: 11

Re: Op-amp Macro Model in ahdlLib
Reply #9 - Jul 28th, 2007, 7:43pm
 
Thanks a lot for your reply. I have also looked at this code, and came across the following line:

//
// GM stage with slewing
//
    I(vref, cout) <+ V(vref, cout)/100e6;

I have been thinking for a while, but was scatching my head as to what this is actually doing. I have tried to comment this out as well, but it doesn't seem to do anything to the output.

Any one can give a hand? Thanks in advance!

Best,
David.
Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Op-amp Macro Model in ahdlLib
Reply #10 - Jul 30th, 2007, 4:10am
 
smchiu wrote on Jul 28th, 2007, 7:43pm:
...
//
// GM stage with slewing
//
    I(vref, cout) <+ V(vref, cout)/100e6;

I have been thinking for a while, but was scatching my head as to what this is actually doing. I have tried to comment this out as well, but it doesn't seem to do anything to the output.
...

David,
r1 is in parallel:
Code:
 // Dominant Pole.
 I(cout, vref) <+ V(cout, vref)/r1;  

So, it doesn't do much, unless r1 is of the order of 100M...

BOE
Back to top
 
 
View Profile   IP Logged
smchiu
Junior Member
**
Offline



Posts: 11

Re: Op-amp Macro Model in ahdlLib
Reply #11 - Jul 30th, 2007, 9:34am
 
HI BOE,

Thanks for your reply. I am just curious why do they put in 100e6 in the first place then? It seems it's hard-coded there. What does it represent?

Thanks.
David.
Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Op-amp Macro Model in ahdlLib
Reply #12 - Aug 3rd, 2007, 1:02am
 
Hi David,smchiu wrote on Jul 30th, 2007, 9:34am:
I am just curious why do they put in 100e6 in the first place then? It seems it's hard-coded there. What does it represent?
Good question. I suppose it's there to avoid problems if you configure the opamp such that r1 gets extremly large...
BOE
Back to top
 
 
View Profile   IP Logged
X
New Member
*
Offline



Posts: 1

Re: Op-amp Macro Model in ahdlLib
Reply #13 - May 19th, 2017, 8:21am
 
Hi,

Did somebody who used this ahdlLib opamp had any issue to assign the slew_rate parameter in the properties?

I assigned it, but in the simulation log, it is showing always the default value of 500K. I tested higher and lower values in the slew_rate parameter field, and nothing changed.

Somebody has a clue on what is happening?

Thanks in advance for the help.
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1998
Massachusetts, USA
Re: Op-amp Macro Model in ahdlLib
Reply #14 - May 22nd, 2017, 7:59am
 
Did you look at the netlist? Do you see a different value? Did you try changing the value of other parameters, and did the simulation results change?
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.