libsidplayfp  2.11.0
Integrator6581.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2011-2023 Leandro Nini <drfiemost@users.sourceforge.net>
5  * Copyright 2007-2010 Antti Lankila
6  * Copyright 2004, 2010 Dag Lem <resid@nimrod.no>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INTEGRATOR6581_H
24 #define INTEGRATOR6581_H
25 
26 #include "Integrator.h"
27 #include "FilterModelConfig6581.h"
28 
29 #include <stdint.h>
30 #include <cassert>
31 
32 // uncomment to enable use of the slope factor
33 // in the EKV model
34 // actually produces worse results, needs investigation
35 //#define SLOPE_FACTOR
36 
37 #include "siddefs-fp.h"
38 
39 namespace reSIDfp
40 {
41 
165 {
166 private:
167  const double wlSnake;
168 
169 #ifdef SLOPE_FACTOR
170  // Slope factor n = 1/k
171  // where k is the gate coupling coefficient
172  // k = Cox/(Cox+Cdep) ~ 0.7 (depends on gate voltage)
173  mutable double n;
174 #endif
175 
176  unsigned int nVddt_Vw_2;
177 
178  const unsigned short nVddt;
179  const unsigned short nVt;
180  const unsigned short nVmin;
181 
183 
184 public:
186  wlSnake(fmc.getWL_snake()),
187 #ifdef SLOPE_FACTOR
188  n(1.4),
189 #endif
190  nVddt_Vw_2(0),
191  nVddt(fmc.getNormalizedValue(fmc.getVddt())),
192  nVt(fmc.getNormalizedValue(fmc.getVth())),
193  nVmin(fmc.getNVmin()),
194  fmc(fmc) {}
195 
196  void setVw(unsigned short Vw) { nVddt_Vw_2 = ((nVddt - Vw) * (nVddt - Vw)) >> 1; }
197 
198  int solve(int vi) const override;
199 };
200 
201 } // namespace reSIDfp
202 
203 #endif
Definition: FilterModelConfig6581.h:43
Definition: Integrator6581.h:165
Definition: Integrator.h:30