libresidfp  1.2.3
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 <cstdint>
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  friend class State;
167 
168 private:
169  const double wlSnake;
170 
171 #ifdef SLOPE_FACTOR
172  // Slope factor n = 1/k
173  // where k is the gate coupling coefficient
174  // k = Cox/(Cox+Cdep) ~ 0.7 (depends on gate voltage)
175  mutable double n;
176 #endif
177 
178  uint32_t nVddt_Vw_2;
179 
180  const uint16_t nVddt;
181  const uint16_t nVt;
182  const uint16_t nVmin;
183 
185 
186 public:
187  explicit Integrator6581(FilterModelConfig6581& new_fmc) :
188  wlSnake(new_fmc.getWL_snake()),
189 #ifdef SLOPE_FACTOR
190  n(1.4),
191 #endif
192  nVddt_Vw_2(0),
193  nVddt(new_fmc.getNormalizedValue(new_fmc.getVddt())),
194  nVt(new_fmc.getNormalizedValue(new_fmc.getVth())),
195  nVmin(new_fmc.getNVmin()),
196  fmc(new_fmc) {}
197 
198  void setVw(uint16_t Vw) { nVddt_Vw_2 = ((nVddt - Vw) * (nVddt - Vw)) >> 1; }
199 
200  int32_t solve(int32_t vi) const override;
201 };
202 
203 } // namespace reSIDfp
204 
205 #endif
Definition: Integrator6581.h:164
Definition: Dac.cpp:27
Definition: Integrator.h:31
Definition: FilterModelConfig6581.h:42
Definition: State.h:45