libsidplayfp 2.7.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
39namespace reSIDfp
40{
41
165{
166private:
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
182 const FilterModelConfig6581* fmc;
183
184public:
186 double WL_snake) :
187 wlSnake(WL_snake),
188#ifdef SLOPE_FACTOR
189 n(1.4),
190#endif
191 nVddt_Vw_2(0),
192 nVddt(fmc->getNormalizedValue(fmc->getVddt())),
193 nVt(fmc->getNormalizedValue(fmc->getVth())),
194 nVmin(fmc->getNVmin()),
195 fmc(fmc) {}
196
197 void setVw(unsigned short Vw) { nVddt_Vw_2 = ((nVddt - Vw) * (nVddt - Vw)) >> 1; }
198
199 int solve(int vi) const override;
200};
201
202} // namespace reSIDfp
203
204#endif
Definition FilterModelConfig6581.h:43
Definition Integrator6581.h:165
Definition Integrator.h:30