netlist: add current controlled voltage source (CCVS). [Couriersud]

This commit is contained in:
couriersud 2020-01-26 21:25:33 +01:00
parent d980e7d6ab
commit fa27a02b0d
5 changed files with 79 additions and 3 deletions

View File

@ -23,6 +23,9 @@
#define VCVS(name) \
NET_REGISTER_DEV(VCVS, name)
#define CCVS(name) \
NET_REGISTER_DEV(CCVS, name)
#define LVCCS(name) \
NET_REGISTER_DEV(LVCCS, name)

View File

@ -108,12 +108,26 @@ NETLIB_RESET(VCVS)
m_ON2.set_conductivity(m_gfac);
}
// ----------------------------------------------------------------------------------------
// nld_CCVS
// ----------------------------------------------------------------------------------------
NETLIB_RESET(CCVS)
{
m_gfac = plib::reciprocal(m_RO());
NETLIB_NAME(VCCS)::reset();
m_OP2.set_conductivity(m_gfac);
m_ON2.set_conductivity(m_gfac);
}
} //namespace analog
namespace devices {
NETLIB_DEVICE_IMPL_NS(analog, VCVS, "VCVS", "")
NETLIB_DEVICE_IMPL_NS(analog, VCCS, "VCCS", "")
NETLIB_DEVICE_IMPL_NS(analog, CCCS, "CCCS", "")
NETLIB_DEVICE_IMPL_NS(analog, CCVS, "CCVS", "")
NETLIB_DEVICE_IMPL_NS(analog, LVCCS, "LVCCS", "")
} // namespace devices
} // namespace netlist

View File

@ -36,9 +36,9 @@ namespace analog {
NETLIB_OBJECT(VCCS)
{
public:
NETLIB_CONSTRUCTOR(VCCS)
NETLIB_CONSTRUCTOR_EX(VCCS, nl_fptype ari = nlconst::magic(1e9))
, m_G(*this, "G", nlconst::one())
, m_RI(*this, "RI", nlconst::magic(1e9))
, m_RI(*this, "RI", ari)
, m_OP(*this, "OP", &m_IP)
, m_ON(*this, "ON", &m_IP)
, m_IP(*this, "IP", &m_IN) // <= this should be NULL and terminal be filtered out prior to solving...
@ -126,7 +126,7 @@ namespace analog {
NETLIB_OBJECT_DERIVED(CCCS, VCCS)
{
public:
NETLIB_CONSTRUCTOR_DERIVED(CCCS, VCCS)
NETLIB_CONSTRUCTOR_DERIVED_PASS(CCCS, VCCS, nlconst::one())
{
m_gfac = plib::reciprocal(m_RI());
}
@ -191,6 +191,57 @@ namespace analog {
};
// ----------------------------------------------------------------------------------------
// nld_CCVS
// ----------------------------------------------------------------------------------------
//
// Voltage controlled voltage source
//
// Parameters:
// G Default: 1
// RO Default: 1 (would be typically 50 for an op-amp
//
// IP ---+ +--+---- OP
// | | |
// RI I RO
// RI => G => I RO V(OP) - V(ON) = (V(IP)-V(IN)) / RI * G
// RI I RO
// | | |
// IN ---+ +--+---- ON
//
// G=1 ==> 1A ==> 1V
//
// RI = 1
//
// Internal GI = G / RO
//
NETLIB_OBJECT_DERIVED(CCVS, VCCS)
{
public:
NETLIB_CONSTRUCTOR_DERIVED_PASS(CCVS, VCCS, nlconst::one())
, m_RO(*this, "RO", nlconst::one())
, m_OP2(*this, "_OP2", &m_ON2)
, m_ON2(*this, "_ON2", &m_OP2)
{
connect(m_OP2, m_OP1);
connect(m_ON2, m_ON1);
}
NETLIB_RESETI();
param_fp_t m_RO;
private:
//NETLIB_UPDATEI();
//NETLIB_UPDATE_PARAMI();
terminal_t m_OP2;
terminal_t m_ON2;
};
} // namespace analog
} // namespace netlist

View File

@ -38,6 +38,7 @@ namespace devices
LIB_ENTRY(VCVS)
LIB_ENTRY(VCCS)
LIB_ENTRY(CCCS)
LIB_ENTRY(CCVS)
LIB_ENTRY(LVCCS)
LIB_ENTRY(opamp)
LIB_ENTRY(nc_pin)

View File

@ -62,11 +62,18 @@ class NETLIB_NAME(name) : public device_t
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \
: NETLIB_NAME(pclass)(owner, name)
// FIXME: Only used by diode
#define NETLIB_CONSTRUCTOR_DERIVED_EX(cname, pclass, ...) \
private: detail::family_setter_t m_famsetter; \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name, __VA_ARGS__) \
: NETLIB_NAME(pclass)(owner, name)
#define NETLIB_CONSTRUCTOR_DERIVED_PASS(cname, pclass, ...) \
private: detail::family_setter_t m_famsetter; \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \
: NETLIB_NAME(pclass)(owner, name, __VA_ARGS__)
/// \brief Used to define the constructor of a netlist device.
/// Use this to define the constructor of a netlist device. Please refer to
/// #NETLIB_OBJECT for an example.