module: gated_charge_pump_noise
description: 
parameters:  double thermal_noise_pos, double thermal_noise_neg
             double flicker_corner_freq_pos, double flicker_corner_freq_neg
inputs:  double_interp pol
outputs:  double out
classes:  
OneOverfPlusWhiteNoise pos_noise()
OneOverfPlusWhiteNoise neg_noise()

static_variables: double pos_noise_scale, double neg_noise_scale
init:  
double flicker_slope;

flicker_slope = -10.0;
pos_noise.set(flicker_corner_freq_pos,flicker_slope,Ts);
neg_noise.set(flicker_corner_freq_neg,flicker_slope,Ts);

pos_noise_scale = thermal_noise_pos*sqrt(0.5/Ts);
neg_noise_scale = thermal_noise_neg*sqrt(0.5/Ts);
out = 0.0;
end:  
code:  
double interp_val, pos_noise_val, neg_noise_val;

pos_noise_val = pos_noise_scale*pos_noise.inp();
neg_noise_val = neg_noise_scale*neg_noise.inp();

if (pol == 1.0)
   out = pos_noise_val;
else if (pol == -1.0)
   out = neg_noise_val;
else if (pol >= -1.0 && pol <= 1.0)  
   {
    interp_val = (1.0 + pol)/2.0;
    out = sqrt(interp_val)*pos_noise_val + sqrt(1.0 - interp_val)*neg_noise_val;
   }
else
   out = 0.0;

