summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/netlist/analog/nld_fourterm.c
blob: 301aca9a4e77eabc85f0d6dff0447393f3901f4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
 * nld_fourterm.c
 *
 */

#include "nld_fourterm.h"
#include "../nl_setup.h"
#include "nld_solver.h"

// ----------------------------------------------------------------------------------------
// nld_VCCS
// ----------------------------------------------------------------------------------------

NETLIB_START(VCCS)
{
    register_param("G", m_G, 1.0);
    register_param("RI", m_RI, 1.0 / netlist().gmin());

    register_terminal("IP", m_IP);
    register_terminal("IN", m_IN);
    register_terminal("OP", m_OP);
    register_terminal("ON", m_ON);

    register_terminal("_OP1", m_OP1);
    register_terminal("_ON1", m_ON1);

    m_IP.m_otherterm = &m_IN; // <= this should be NULL and terminal be filtered out prior to solving...
    m_IN.m_otherterm = &m_IP; // <= this should be NULL and terminal be filtered out prior to solving...

    m_OP.m_otherterm = &m_IP;
    m_OP1.m_otherterm = &m_IN;

    m_ON.m_otherterm = &m_IP;
    m_ON1.m_otherterm = &m_IN;

    connect(m_OP, m_OP1);
    connect(m_ON, m_ON1);

    m_gfac = 1.0;
}

NETLIB_RESET(VCCS)
{
    const double m_mult = m_G.Value() * m_gfac; // 1.0 ==> 1V ==> 1A
    const double GI = 1.0 / m_RI.Value();

    m_IP.set(GI);
    m_IN.set(GI);

    m_OP.set(m_mult, 0.0);
    m_OP1.set(-m_mult, 0.0);

    m_ON.set(-m_mult, 0.0);
    m_ON1.set(m_mult, 0.0);
}

NETLIB_UPDATE_PARAM(VCCS)
{
}

NETLIB_UPDATE(VCCS)
{
    /* only called if connected to a rail net ==> notify the solver to recalculate */
    /* Big FIXME ... */
    if (!m_IP.net().isRailNet())
        m_IP.net().solve();
    else if (!m_IN.net().isRailNet())
        m_IN.net().solve();
    else if (!m_OP.net().isRailNet())
        m_OP.net().solve();
    else if (!m_ON.net().isRailNet())
        m_ON.net().solve();
}

// ----------------------------------------------------------------------------------------
// nld_VCVS
// ----------------------------------------------------------------------------------------

NETLIB_START(VCVS)
{
    NETLIB_NAME(VCCS)::start();

    register_param("RO", m_RO, 1.0);

    register_terminal("_OP2", m_OP2);
    register_terminal("_ON2", m_ON2);

    m_OP2.m_otherterm = &m_ON2;
    m_ON2.m_otherterm = &m_OP2;

    connect(m_OP2, m_OP1);
    connect(m_ON2, m_ON1);
}

NETLIB_RESET(VCVS)
{
    m_gfac = 1.0 / m_RO.Value();
    NETLIB_NAME(VCCS)::reset();

    m_OP2.set(1.0 / m_RO.Value());
    m_ON2.set(1.0 / m_RO.Value());
}

NETLIB_UPDATE_PARAM(VCVS)
{
}