28 #include "siddefs-fp.h"
45 unsigned int Vddt_Vw_2;
48 const unsigned short* vcr_Vg;
49 const unsigned short* vcr_n_Ids_term;
53 Integrator(
const unsigned short* vcr_Vg,
const unsigned short* vcr_n_Ids_term,
54 const int* opamp_rev,
int Vddt,
int n_snake) :
61 vcr_n_Ids_term(vcr_n_Ids_term),
62 opamp_rev(opamp_rev) {}
64 void setVw(
const int Vw) { Vddt_Vw_2 = (Vddt - Vw) * (Vddt - Vw) >> 1; }
66 int solve(
const int vi);
71 #if RESID_INLINING || defined(INTEGRATOR_CPP)
77 int Integrator::solve(
int vi)
80 const int Vgst = Vddt - x;
81 const int Vgdt = Vddt - vi;
83 const uint64_t Vgst_2 = (int64_t)Vgst * (int64_t)Vgst;
84 const uint64_t Vgdt_2 = (int64_t)Vgdt * (int64_t)Vgdt;
87 const int n_I_snake = n_snake * ((Vgst_2 >> 15) - (Vgdt_2 >> 15));
91 const int Vg = (int)vcr_Vg[(Vddt_Vw_2 >> 16) + (Vgdt_2 >> 17)];
94 const int Vgs = Vg > x ? Vg - x : 0;
95 const int Vgd = Vg > vi ? Vg - vi : 0;
98 const int n_I_vcr = (int)(vcr_n_Ids_term[Vgs & 0xffff] - vcr_n_Ids_term[Vgd & 0xffff]) << 15;
101 vc += n_I_snake + n_I_vcr;
104 x = opamp_rev[((vc >> 15) + (1 << 15)) & 0xffff];
107 return x - (vc >> 14);