KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_model_ibis.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * https://www.gnu.org/licenses/gpl-3.0.html
19 * or you may search the http://www.gnu.org website for the version 3 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef SIM_MODEL_IBIS_H
25#define SIM_MODEL_IBIS_H
26
27#include <sim/kibis/kibis.h>
28#include <sim/sim_model.h>
29#include <sim/spice_generator.h>
30#include <project.h>
31
33class REPORTER;
34class SCHEMATIC;
35
37{
38public:
40
41 std::string ModelName( const SPICE_ITEM& aItem ) const override;
42 std::string ModelLine( const SPICE_ITEM& aItem ) const override;
43 std::vector<std::string> CurrentNames( const SPICE_ITEM& aItem ) const override;
44
45 std::string IbisDevice( const SPICE_ITEM& aItem, SCHEMATIC* aSchematic,
46 const wxString& aCacheDir, REPORTER& aReporter ) const;
47};
48
49enum class IBIS_IO_MODE
50{
51 SINGLE_ENDED, // GND + signal pin
52 DIFFERENTIAL, // GND + positive + negative
53 SERIES // PIN_A + PIN_B, no GND port
54};
55
56
58{
59 friend class SIM_LIBRARY_IBIS;
60
61public:
62 SIM_MODEL_IBIS( TYPE aType );
63
64 // @brief Special copy constructor
65 // creates a a model with aType, but tries to match parameters from aSource.
66 SIM_MODEL_IBIS( TYPE aType, const SIM_MODEL_IBIS& aSource );
67
68 std::vector<std::pair<std::string, std::string>> GetIbisPins() const
69 {
70 return m_sourceModel ? m_sourceModel->GetIbisPins() : m_ibisPins;
71 }
72
73 std::vector<std::string> GetIbisModels() const { return m_ibisModels; };
74
75 std::string GetComponentName() const
76 {
77 return m_sourceModel ? m_sourceModel->GetComponentName() : m_componentName;
78 }
79
80
81 const PARAM& GetParam( unsigned aParamIndex ) const override
82 {
83 return m_params.at( aParamIndex );
84 };
85
89 bool ChangePin( const SIM_LIBRARY_IBIS& aLib, const std::string& aPinNumber );
90
92 bool SetIbisModel( const SIM_LIBRARY_IBIS& aLib, const std::string& aPinNumber,
93 const std::string& aModelName );
94
95 void SetBaseModel( const SIM_MODEL& aBaseModel ) override;
96
97 void SwitchSingleEndedDiff( bool aDiff ) override;
98
99 void SetIOMode( IBIS_IO_MODE aMode );
100
101 IBIS_IO_MODE GetIOMode() const { return m_ioMode; }
102 bool IsSeries() const { return m_ioMode == IBIS_IO_MODE::SERIES; }
103 bool CanDifferential() const { return m_enableDiff; } ;
104
105 const std::string& GetSeriesPartnerPin() const { return m_partnerPin; }
106
108
109private:
110 bool requiresSpiceModelLine( const SPICE_ITEM& aItem ) const override { return true; }
111
112 void addSwitchStateParam();
114
115 static std::vector<PARAM::INFO> makeParamInfos( TYPE aType );
116 static std::vector<PARAM::INFO> makeDcWaveformParamInfos();
117 static std::vector<PARAM::INFO> makeRectWaveformParamInfos();
118 static std::vector<PARAM::INFO> makePrbsWaveformParamInfos();
119
121 std::vector<std::string> m_ibisModels;
122 std::vector<std::pair<std::string, std::string>> m_ibisPins;
123 std::string m_componentName;
125 std::string m_partnerPin;
126};
127
128#endif // SIM_MODEL_KIBIS_H
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:75
Holds all the data relating to one schematic.
Definition schematic.h:89
SIM_MODEL_IBIS(TYPE aType)
static std::vector< PARAM::INFO > makeDcWaveformParamInfos()
void removeSwitchStateParam()
std::vector< std::pair< std::string, std::string > > m_ibisPins
friend class SIM_LIBRARY_IBIS
std::vector< std::string > m_ibisModels
static std::vector< PARAM::INFO > makeRectWaveformParamInfos()
IBIS_IO_MODE m_ioMode
bool SetIbisModel(const SIM_LIBRARY_IBIS &aLib, const std::string &aPinNumber, const std::string &aModelName)
Bind to a KIBIS model, set IO mode from its type, manage sw_state.
const PARAM & GetParam(unsigned aParamIndex) const override
static std::vector< PARAM::INFO > makePrbsWaveformParamInfos()
std::string m_partnerPin
std::vector< std::pair< std::string, std::string > > GetIbisPins() const
void SwitchSingleEndedDiff(bool aDiff) override
IBIS_IO_MODE GetIOMode() const
bool IsSeries() const
const SIM_MODEL_IBIS * m_sourceModel
bool CanDifferential() const
const std::string & GetSeriesPartnerPin() const
std::vector< std::string > GetIbisModels() const
void SetIOMode(IBIS_IO_MODE aMode)
std::string m_componentName
void SetBaseModel(const SIM_MODEL &aBaseModel) override
bool ChangePin(const SIM_LIBRARY_IBIS &aLib, const std::string &aPinNumber)
update the list of available models based on the pin number.
static std::vector< PARAM::INFO > makeParamInfos(TYPE aType)
bool requiresSpiceModelLine(const SPICE_ITEM &aItem) const override
std::string GetComponentName() const
SIM_MODEL()=delete
std::vector< PARAM > m_params
Definition sim_model.h:535
std::string IbisDevice(const SPICE_ITEM &aItem, SCHEMATIC *aSchematic, const wxString &aCacheDir, REPORTER &aReporter) const
std::vector< std::string > CurrentNames(const SPICE_ITEM &aItem) const override
SPICE_GENERATOR(const SIM_MODEL &aModel)
std::string ModelLine(const SPICE_ITEM &aItem) const override
std::string ModelName(const SPICE_ITEM &aItem) const override
SPICE_GENERATOR(const SIM_MODEL &aModel)
SIM_MODEL::TYPE TYPE
Definition sim_model.cpp:58
IBIS_IO_MODE