2016-08-11 12:41:07 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 CERN
|
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2016-08-11 12:41:43 +00:00
|
|
|
* as published by the Free Software Foundation; either version 3
|
2016-08-11 12:41:07 +00:00
|
|
|
* 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:
|
2016-08-11 12:41:43 +00:00
|
|
|
* https://www.gnu.org/licenses/gpl-3.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 3 license,
|
2016-08-11 12:41:07 +00:00
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2016-08-11 12:41:01 +00:00
|
|
|
|
2016-08-11 12:41:07 +00:00
|
|
|
#ifndef NGSPICE_H
|
|
|
|
#define NGSPICE_H
|
2016-08-11 12:41:01 +00:00
|
|
|
|
2016-08-11 12:41:07 +00:00
|
|
|
#include "spice_simulator.h"
|
|
|
|
|
2016-08-12 13:56:51 +00:00
|
|
|
#include <ngspice/sharedspice.h>
|
|
|
|
|
2016-08-11 12:41:07 +00:00
|
|
|
class wxDynamicLibrary;
|
|
|
|
|
|
|
|
class NGSPICE : public SPICE_SIMULATOR {
|
2016-08-11 12:41:01 +00:00
|
|
|
|
|
|
|
public:
|
2016-08-11 12:41:07 +00:00
|
|
|
NGSPICE();
|
|
|
|
virtual ~NGSPICE();
|
|
|
|
|
2016-08-11 12:42:17 +00:00
|
|
|
///> @copydoc SPICE_SIMULATOR::Init()
|
2016-08-11 12:41:17 +00:00
|
|
|
void Init() override;
|
2016-08-11 12:42:17 +00:00
|
|
|
|
|
|
|
///> @copydoc SPICE_SIMULATOR::LoadNetlist()
|
2016-08-11 12:41:17 +00:00
|
|
|
bool LoadNetlist( const std::string& aNetlist ) override;
|
2016-08-11 12:42:17 +00:00
|
|
|
|
|
|
|
///> @copydoc SPICE_SIMULATOR::Run()
|
2016-08-11 12:41:17 +00:00
|
|
|
bool Run() override;
|
2016-08-11 12:42:17 +00:00
|
|
|
|
|
|
|
///> @copydoc SPICE_SIMULATOR::Stop()
|
2016-08-11 12:41:19 +00:00
|
|
|
bool Stop() override;
|
2016-08-11 12:42:17 +00:00
|
|
|
|
|
|
|
///> @copydoc SPICE_SIMULATOR::IsRunning()
|
2016-08-11 12:41:19 +00:00
|
|
|
bool IsRunning() override;
|
2016-08-11 12:42:17 +00:00
|
|
|
|
|
|
|
///> @copydoc SPICE_SIMULATOR::Command()
|
2016-08-11 12:41:17 +00:00
|
|
|
bool Command( const std::string& aCmd ) override;
|
2016-08-11 12:42:17 +00:00
|
|
|
|
|
|
|
///> @copydoc SPICE_SIMULATOR::GetXAxis()
|
2016-08-11 12:41:51 +00:00
|
|
|
std::string GetXAxis( SIM_TYPE aType ) const override;
|
2016-08-11 12:41:31 +00:00
|
|
|
|
2016-08-11 12:42:17 +00:00
|
|
|
///> @copydoc SPICE_SIMULATOR::GetPlot()
|
2016-08-11 12:41:31 +00:00
|
|
|
std::vector<COMPLEX> GetPlot( const std::string& aName, int aMaxLen = -1 ) override;
|
2016-08-11 12:42:17 +00:00
|
|
|
|
|
|
|
///> @copydoc SPICE_SIMULATOR::GetRealPlot()
|
2016-08-11 12:41:31 +00:00
|
|
|
std::vector<double> GetRealPlot( const std::string& aName, int aMaxLen = -1 ) override;
|
2016-08-11 12:42:17 +00:00
|
|
|
|
|
|
|
///> @copydoc SPICE_SIMULATOR::GetImagPlot()
|
2016-08-11 12:41:31 +00:00
|
|
|
std::vector<double> GetImagPlot( const std::string& aName, int aMaxLen = -1 ) override;
|
2016-08-11 12:42:17 +00:00
|
|
|
|
|
|
|
///> @copydoc SPICE_SIMULATOR::GetMagPlot()
|
2016-08-11 12:41:31 +00:00
|
|
|
std::vector<double> GetMagPlot( const std::string& aName, int aMaxLen = -1 ) override;
|
2016-08-11 12:42:17 +00:00
|
|
|
|
|
|
|
///> @copydoc SPICE_SIMULATOR::GetPhasePlot()
|
2016-08-11 12:41:31 +00:00
|
|
|
std::vector<double> GetPhasePlot( const std::string& aName, int aMaxLen = -1 ) override;
|
2016-08-11 12:41:07 +00:00
|
|
|
|
2018-03-03 16:36:26 +00:00
|
|
|
///> @copydoc SPICE_SIMULATOR::GetNetlist()
|
|
|
|
virtual const std::string GetNetlist() const override;
|
|
|
|
|
2016-08-11 12:41:07 +00:00
|
|
|
private:
|
2016-08-15 11:52:13 +00:00
|
|
|
void init();
|
2016-08-11 12:41:01 +00:00
|
|
|
|
2016-10-13 11:25:06 +00:00
|
|
|
///> Executes commands from a file
|
|
|
|
bool loadSpinit( const std::string& aFileName );
|
|
|
|
|
|
|
|
///> Checks a few different locations for codemodel files and returns one
|
|
|
|
///> if it exists
|
|
|
|
std::string findCmPath() const;
|
|
|
|
|
|
|
|
///> Loads codemodel files from a directory
|
|
|
|
bool loadCodemodels( const std::string& aPath );
|
|
|
|
|
2016-08-11 12:42:17 +00:00
|
|
|
// Callback functions
|
2016-08-11 12:41:07 +00:00
|
|
|
static int cbSendChar( char* what, int id, void* user );
|
|
|
|
static int cbSendStat( char* what, int id, void* user );
|
2016-08-11 12:41:19 +00:00
|
|
|
static int cbBGThreadRunning( bool is_running, int id, void* user );
|
2016-08-11 12:42:17 +00:00
|
|
|
static int cbControlledExit( int status, bool immediate, bool exit_upon_quit, int id, void* user );
|
2016-08-11 12:41:17 +00:00
|
|
|
|
|
|
|
void dump();
|
2016-08-18 16:10:00 +00:00
|
|
|
|
|
|
|
///> NGspice should be initialized only once
|
|
|
|
static bool m_initialized;
|
2018-03-03 16:36:26 +00:00
|
|
|
|
|
|
|
///> current netlist
|
|
|
|
std::string m_netlist;
|
2016-08-11 12:41:01 +00:00
|
|
|
};
|
|
|
|
|
2016-08-11 12:41:07 +00:00
|
|
|
#endif /* NGSPICE_H */
|