libsidplayfp  0.3.5
FilterModelConfig.h
1 #ifndef FILTERMODELCONFIG_H
2 #define FILTERMODELCONFIG_H
3 
4 #define OPAMP_SIZE 22
5 #define DAC_SIZE 11
6 
7 #include <memory>
8 
9 namespace reSIDfp
10 {
11 
12 class Integrator;
13 
17 
18 private:
19  static std::auto_ptr<FilterModelConfig> instance;
20  // This allows access to the private constructor
21  friend class std::auto_ptr<FilterModelConfig>;
22 
23  static const double opamp_voltage[OPAMP_SIZE][2];
24 
25  const double voice_voltage_range;
26  const double voice_DC_voltage;
27 
28  // Capacitor value.
29  const double C;
30 
31  // Transistor parameters.
32  const double Vdd;
33  const double Vth; // Threshold voltage
34  const double uCox_vcr; // 1/2*u*Cox
35  const double WL_vcr; // W/L for VCR
36  const double uCox_snake; // 1/2*u*Cox
37  const double WL_snake; // W/L for "snake"
38 
39  // DAC parameters.
40  const double dac_zero;
41  const double dac_scale;
42  const double dac_2R_div_R;
43  const bool dac_term;
44 
45  /* Derived stuff */
46  const double vmin, norm;
47  double opamp_working_point;
48  unsigned short* mixer[8];
49  unsigned short* summer[7];
50  unsigned short* gain[16];
51  double dac[DAC_SIZE];
52  unsigned short vcr_Vg[1 << 16];
53  unsigned short vcr_n_Ids_term[1 << 16];
54  int opamp_rev[1 << 16];
55 
56  double evaluateTransistor(const double Vw, const double vi, const double vx);
57 
58  FilterModelConfig();
59  ~FilterModelConfig();
60 
61 public:
62  static FilterModelConfig* getInstance();
63 
64  double getDacZero(const double adjustment) const;
65 
66  int getVO_T16() const;
67 
68  int getVoiceScaleS14() const;
69 
70  int getVoiceDC() const;
71 
72  unsigned short** getGain() { return gain; }
73 
74  unsigned short** getSummer() { return summer; }
75 
76  unsigned short** getMixer() { return mixer; }
77 
82  unsigned int* getDAC(const double dac_zero) const;
83 
84  Integrator* buildIntegrator();
85 
98  double estimateFrequency(const double dac_zero, const int fc);
99 };
100 
101 } // namespace reSIDfp
102 
103 #endif