2022-02-21 03:58:31 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2022 KiCad Developers, see AUTHORS.TXT for contributors.
|
|
|
|
*
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <qa_utils/wx_utils/unit_test_utils.h>
|
2022-08-05 15:37:20 +00:00
|
|
|
#include <sim/sim_model_ngspice.h>
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
class TEST_SIM_MODEL_NGSPICE_FIXTURE : public SIM_MODEL_NGSPICE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TEST_SIM_MODEL_NGSPICE_FIXTURE() : SIM_MODEL_NGSPICE( TYPE::NONE ) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_FIXTURE_TEST_SUITE( SimModelNgspice, TEST_SIM_MODEL_NGSPICE_FIXTURE )
|
2022-02-21 03:58:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE( Models )
|
|
|
|
{
|
|
|
|
// Count the total number of model and instance parameters for each model so that there will be
|
|
|
|
// an error if someone accidentally removes a parameter.
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
for( MODEL_TYPE type : MODEL_TYPE_ITERATOR() )
|
2022-02-21 03:58:31 +00:00
|
|
|
{
|
2022-08-05 15:37:20 +00:00
|
|
|
unsigned modelParamCount = ModelInfo( type ).modelParams.size();
|
|
|
|
unsigned instanceParamCount = ModelInfo( type ).instanceParams.size();
|
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
switch( type )
|
|
|
|
{
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::NONE:
|
|
|
|
case MODEL_TYPE::_ENUM_END:
|
2022-02-21 03:58:31 +00:00
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
/*case MODEL_TYPE::RESISTOR:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 22 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 25 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::CAPACITOR:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 19 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 22 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::INDUCTOR:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 9 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 20 );
|
2022-05-08 09:54:35 +00:00
|
|
|
break;*/
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
/*case MODEL_TYPE::LTRA:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 18 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 9 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::TRANLINE:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 0 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 17 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::URC:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 7 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 5 );
|
2022-05-31 02:55:48 +00:00
|
|
|
break;*/
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
/*case MODEL_TYPE::TRANSLINE:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 6 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 3 );
|
2022-03-09 01:40:59 +00:00
|
|
|
break;*/
|
2022-04-12 14:37:06 +00:00
|
|
|
|
2022-08-28 12:51:03 +00:00
|
|
|
/*case MODEL_TYPE::SWITCH:
|
2022-04-12 14:37:06 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 7 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 8 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::CSWITCH:
|
2022-04-12 14:37:06 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 7 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 7 );
|
2022-08-28 12:51:03 +00:00
|
|
|
break;*/
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::DIODE:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 76 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 30 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::BJT:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 152 );
|
2022-04-12 14:37:06 +00:00
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 53 );
|
2022-02-21 03:58:31 +00:00
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::VBIC:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 117 );
|
2022-04-12 14:37:06 +00:00
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 45 );
|
2022-02-21 03:58:31 +00:00
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::HICUM2:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 149 );
|
2022-04-12 14:37:06 +00:00
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 61 );
|
2022-02-21 03:58:31 +00:00
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::JFET:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 28 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 28 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::JFET2:
|
2022-05-31 02:55:48 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 46 );
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 30 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::MES:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 22 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 25 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::MESA:
|
2022-05-31 02:55:48 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 71 );
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 30 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::HFET1:
|
2022-05-31 02:55:48 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 68 );
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 28 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::HFET2:
|
2022-05-31 02:55:48 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 40 );
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 28 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::MOS1:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 35 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 76 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::MOS2:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 42 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 76 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::MOS3:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 48 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 81 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::BSIM1:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 81 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 14 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::BSIM2:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 137 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 14 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::MOS6:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 42 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 78 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::BSIM3:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 429 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 46 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::MOS9:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 48 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 81 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::B4SOI:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 915 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 74 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::BSIM4:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 892 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 84 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::B3SOIFD:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 393 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 27 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::B3SOIDD:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 393 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 27 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::B3SOIPD:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 470 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 36 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::HISIM2:
|
2022-02-21 03:58:31 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 486 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 59 );
|
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::HISIMHV1:
|
2022-05-31 02:55:48 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 610 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 72 );
|
2022-02-21 03:58:31 +00:00
|
|
|
break;
|
|
|
|
|
2022-08-05 15:37:20 +00:00
|
|
|
case MODEL_TYPE::HISIMHV2:
|
2022-05-31 02:55:48 +00:00
|
|
|
BOOST_CHECK_EQUAL( modelParamCount, 730 );
|
|
|
|
BOOST_CHECK_EQUAL( instanceParamCount, 74 );
|
2022-02-21 03:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
BOOST_FAIL( wxString::Format(
|
|
|
|
"Unhandled type: %d "
|
|
|
|
"(if you created a new type you need to handle it in this switch statement)",
|
|
|
|
type ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|