00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FILTERMODELCONFIG_H
00023 #define FILTERMODELCONFIG_H
00024
00025 #include <memory>
00026
00027 #define OPAMP_SIZE 22
00028 #define DAC_SIZE 11
00029
00030 namespace reSIDfp
00031 {
00032
00033 class Integrator;
00034
00037 class FilterModelConfig
00038 {
00039 private:
00040 static std::auto_ptr<FilterModelConfig> instance;
00041
00042 friend class std::auto_ptr<FilterModelConfig>;
00043
00044 static const double opamp_voltage[OPAMP_SIZE][2];
00045
00046 const double voice_voltage_range;
00047 const double voice_DC_voltage;
00048
00049
00050 const double C;
00051
00052
00053 const double Vdd;
00054 const double Vth;
00055 const double uCox_vcr;
00056 const double WL_vcr;
00057 const double uCox_snake;
00058 const double WL_snake;
00059
00060
00061 const double dac_zero;
00062 const double dac_scale;
00063 const double dac_2R_div_R;
00064 const bool dac_term;
00065
00066
00067 const double vmin, norm;
00068 double opamp_working_point;
00069 unsigned short* mixer[8];
00070 unsigned short* summer[7];
00071 unsigned short* gain[16];
00072 double dac[DAC_SIZE];
00073 unsigned short vcr_Vg[1 << 16];
00074 unsigned short vcr_n_Ids_term[1 << 16];
00075 int opamp_rev[1 << 16];
00076
00077 double evaluateTransistor(double Vw, double vi, double vx);
00078
00079 FilterModelConfig();
00080 ~FilterModelConfig();
00081
00082 public:
00083 static FilterModelConfig* getInstance();
00084
00085 double getDacZero(double adjustment) const { return dac_zero - (adjustment - 0.5) * 2.; }
00086
00087 int getVO_T16() const { return (int)(norm * ((1L << 16) - 1) * vmin); }
00088
00089 int getVoiceScaleS14() const { return (int)((norm * ((1L << 14) - 1)) * voice_voltage_range); }
00090
00091 int getVoiceDC() const { return (int)((norm * ((1L << 16) - 1)) * (voice_DC_voltage - vmin)); }
00092
00093 unsigned short** getGain() { return gain; }
00094
00095 unsigned short** getSummer() { return summer; }
00096
00097 unsigned short** getMixer() { return mixer; }
00098
00107 unsigned int* getDAC(double dac_zero) const;
00108
00109 Integrator* buildIntegrator();
00110
00124 double estimateFrequency(double dac_zero, int fc);
00125 };
00126
00127 }
00128
00129 #endif