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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef SIM_MODEL_IBIS_H
21#define SIM_MODEL_IBIS_H
22
23#include <sim/kibis/kibis.h>
24#include <sim/sim_model.h>
25#include <sim/spice_generator.h>
26#include <project.h>
27
29class REPORTER;
30class SCHEMATIC;
31
33{
34public:
36
37 std::string ModelName( const SPICE_ITEM& aItem ) const override;
38 std::string ModelLine( const SPICE_ITEM& aItem ) const override;
39 std::vector<std::string> CurrentNames( const SPICE_ITEM& aItem ) const override;
40
41 std::string IbisDevice( const SPICE_ITEM& aItem, SCHEMATIC* aSchematic,
42 const wxString& aCacheDir, REPORTER& aReporter ) const;
43};
44
45enum class IBIS_IO_MODE
46{
47 SINGLE_ENDED, // GND + signal pin
48 DIFFERENTIAL, // GND + positive + negative
49 SERIES // PIN_A + PIN_B, no GND port
50};
51
52
54{
55 friend class SIM_LIBRARY_IBIS;
56
57public:
58 SIM_MODEL_IBIS( TYPE aType );
59
60 // @brief Special copy constructor
61 // creates a a model with aType, but tries to match parameters from aSource.
62 SIM_MODEL_IBIS( TYPE aType, const SIM_MODEL_IBIS& aSource );
63
64 std::vector<std::pair<std::string, std::string>> GetIbisPins() const
65 {
66 return m_sourceModel ? m_sourceModel->GetIbisPins() : m_ibisPins;
67 }
68
69 std::vector<std::string> GetIbisModels() const { return m_ibisModels; };
70
71 std::string GetComponentName() const
72 {
73 return m_sourceModel ? m_sourceModel->GetComponentName() : m_componentName;
74 }
75
76
77 const PARAM& GetParam( unsigned aParamIndex ) const override
78 {
79 return m_params.at( aParamIndex );
80 };
81
85 bool ChangePin( const SIM_LIBRARY_IBIS& aLib, const std::string& aPinNumber );
86
88 bool SetIbisModel( const SIM_LIBRARY_IBIS& aLib, const std::string& aPinNumber,
89 const std::string& aModelName );
90
91 void SetBaseModel( const SIM_MODEL& aBaseModel ) override;
92
93 void SwitchSingleEndedDiff( bool aDiff ) override;
94
95 void SetIOMode( IBIS_IO_MODE aMode );
96
97 IBIS_IO_MODE GetIOMode() const { return m_ioMode; }
98 bool IsSeries() const { return m_ioMode == IBIS_IO_MODE::SERIES; }
99 bool CanDifferential() const { return m_enableDiff; } ;
100
101 const std::string& GetSeriesPartnerPin() const { return m_partnerPin; }
102
104
105private:
106 bool requiresSpiceModelLine( const SPICE_ITEM& aItem ) const override { return true; }
107
108 void addSwitchStateParam();
110
111 static std::vector<PARAM::INFO> makeParamInfos( TYPE aType );
112 static std::vector<PARAM::INFO> makeDcWaveformParamInfos();
113 static std::vector<PARAM::INFO> makeRectWaveformParamInfos();
114 static std::vector<PARAM::INFO> makePrbsWaveformParamInfos();
115
117 std::vector<std::string> m_ibisModels;
118 std::vector<std::pair<std::string, std::string>> m_ibisPins;
119 std::string m_componentName;
121 std::string m_partnerPin;
122};
123
124#endif // SIM_MODEL_KIBIS_H
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
Holds all the data relating to one schematic.
Definition schematic.h:90
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:532
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:54
IBIS_IO_MODE