Integrator6581.h
/*
* This file is part of libsidplayfp, a SID player engine.
*
* Copyright 2011-2023 Leandro Nini <drfiemost@users.sourceforge.net>
* Copyright 2007-2010 Antti Lankila
* Copyright 2004, 2010 Dag Lem <resid@nimrod.no>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef INTEGRATOR6581_H
#define INTEGRATOR6581_H
#include "Integrator.h"
#include "FilterModelConfig6581.h"
#include <stdint.h>
#include <cassert>
// uncomment to enable use of the slope factor
// in the EKV model
// actually produces worse results, needs investigation
//#define SLOPE_FACTOR
#include "siddefs-fp.h"
namespace reSIDfp
{
class Integrator6581 : public Integrator
{
private:
const double wlSnake;
#ifdef SLOPE_FACTOR
// Slope factor n = 1/k
// where k is the gate coupling coefficient
// k = Cox/(Cox+Cdep) ~ 0.7 (depends on gate voltage)
mutable double n;
#endif
unsigned int nVddt_Vw_2;
const unsigned short nVddt;
const unsigned short nVt;
const unsigned short nVmin;
FilterModelConfig6581& fmc;
public:
Integrator6581(FilterModelConfig6581& fmc) :
wlSnake(fmc.getWL_snake()),
#ifdef SLOPE_FACTOR
n(1.4),
#endif
nVddt_Vw_2(0),
nVddt(fmc.getNormalizedValue(fmc.getVddt())),
nVt(fmc.getNormalizedValue(fmc.getVth())),
nVmin(fmc.getNVmin()),
fmc(fmc) {}
void setVw(unsigned short Vw) { nVddt_Vw_2 = ((nVddt - Vw) * (nVddt - Vw)) >> 1; }
int solve(int vi) const override;
};
} // namespace reSIDfp
#endif
reSIDfp::FilterModelConfig6581
Definition FilterModelConfig6581.h:43
reSIDfp::Integrator6581
Definition Integrator6581.h:165
reSIDfp::Integrator
Definition Integrator.h:30