热度 10| |
// FUNCTION: Non-ideal OpAmp
// last revised: 22 Jan 2002 jbdavid
// REVISION HISTORY:
// Created BY: Jonathan David with modelwriter
// modified for Differential Operation
// VERSION: $Revision: 1 $
// AUTHORS: Modelwriter Standard Library
// Cadence Design Systems, Inc.
//
// GENERATED BY: Affirma Modelwriter 2.23
// ON: Tue Jan 22 20:55:47 PST 2002
//
// Description: Universal Opamp
// model opamp - Non Ideal OpAmp Model
// LIMITATIONS:
// INCLUDE FILES:
`include "discipline.h"
`include "constants.h"
//==========================================================================
module DiffOpamp (vout_p, vout_n, vcmref, vin_p, vin_n, vspply_p, vspply_n );
// PINS
inout vin_p , vin_n;
// vin_p - positive or non-inverting input
// vin_n - negative or inverting input
inout vspply_p, vspply_n; // pos and neg
output vout_p, vout_n;
input vcmref;
electrical vin_p, vin_n, vout_p, vout_n, vcmref, vspply_p, vspply_n;
// INSTANCE PARAMETERS:
// gain = Open loop voltage gain, or DC voltage gain
parameter real gain = 1000.0 exclude 0.0;
// ibias = Input bias current, the value is the same for
// both inputs [A]
parameter real ibias = 0.0n;
// pole_freq = Dominant pole frequency, or first corner
// frequency, eg. point where gain begins to roll of by 6 dB /
// octave [Hz]
parameter real pole_freq = 1.2;
// rin = Differential input resistance, or resistance
// measured between both inputs [ohms]
parameter real rin = 12.0M exclude 0.0;
// rout = Single ended output resistance [ohms]
parameter real rout = 75.0;
// vin_offset = Input offset voltage, the voltage required for
// 0 volts output [V]
parameter real vin_offset = 0.0u;
// vsoft = Output soft clipping point, measured from the
// supply rails [V]
parameter real vsoft = 0.25;
// LOCAL VARIABLES: (Comment each one)
real c1, r1; // components of the dominant pole
real vin_val; // input diff voltage
real r_rout; // output resistance
real gm_nom; // first stage gm = gain/rout
// INTERNAL NODES
electrical coutp, coutn, vref;
// FUNCTIONS
// {none}
//==========================================================================
Analog begin
@(initial_step) begin // by default ALL analyses included (446+)
r1 = gain;
gm_nom = 1.0;
c1 = 1/(`M_TWO_PI * pole_freq * gain);
r_rout = rout;
end
vin_val= V(vin_p, vin_n) + vin_offset;
// ------ Vref is at Virtual Ground
V(vref, vspply_n) <+ 0.5*V(vspply_p,vspply_n);
// ------ Input Stage
I(vin_p, vin_n) <+ vin_val / rin;
I(vref, vin_p) <+ ibias;
I(vref, vin_n) <+ ibias;
// ------ GM stage
I(vref, coutp) <+ gm_nom*vin_val ;
I(vref, coutn) <+ -gm_nom*vin_val ;
// ------ Dominant Pole.
I(coutp, vref) <+ 2*c1*ddt(V(coutp, vref));
I(coutp, vref) <+ 2*V(coutp, vref)/r1;
I(coutn, vref) <+ 2*c1*ddt(V(coutn, vref));
I(coutn, vref) <+ 2*V(coutn, vref)/r1;
// ------ Output Stage.
I(vref, vout_p) <+ 2*V(coutp, vref)/r_rout;
I(vout_p, vref) <+ 2*V(vout_p, vref)/r_rout;
I(vref, vout_n) <+ 2*V(coutn, vref)/r_rout;
I(vout_n, vref) <+ 2*V(vout_n, vref)/r_rout;
// ------ Soft Output Limiting.
if (V(vout_p) > (V(vspply_p) - vsoft))
I(coutp, vref) <+ gm_nom*(V(vout_p, vspply_p)+vsoft);
else if (V(vout_p) < (V(vspply_n) + vsoft))
I(coutp, vref) <+ gm_nom*(V(vout_p, vspply_n)-vsoft);
// ------ Soft Output Limiting.
if (V(vout_n) > (V(vspply_p) - vsoft))
I(coutn, vref) <+ gm_nom*(V(vout_n, vspply_p)+vsoft);
else if (V(vout_n) < (V(vspply_n) + vsoft))
I(coutn, vref) <+ gm_nom*(V(vout_n, vspply_n)-vsoft);
end
endmodule