trunk/src/emu/netlist/devices/nld_r2r_dac.c
| r0 | r31137 | |
| 1 | /* |
| 2 | * nld_R2R_dac.c |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | #include "nld_r2r_dac.h" |
| 7 | |
| 8 | NETLIB_START(r2r_dac) |
| 9 | { |
| 10 | NETLIB_NAME(twoterm)::start(); |
| 11 | register_terminal("VOUT", m_P); |
| 12 | register_terminal("VGND", m_N); |
| 13 | register_param("R", m_R, 1.0); |
| 14 | register_param("VIN", m_VIN, 1.0); |
| 15 | register_param("N", m_num, 1); |
| 16 | register_param("VAL", m_val, 1); |
| 17 | } |
| 18 | |
| 19 | NETLIB_RESET(r2r_dac) |
| 20 | { |
| 21 | NETLIB_NAME(twoterm)::reset(); |
| 22 | } |
| 23 | |
| 24 | NETLIB_UPDATE(r2r_dac) |
| 25 | { |
| 26 | NETLIB_NAME(twoterm)::update(); |
| 27 | } |
| 28 | |
| 29 | NETLIB_UPDATE_PARAM(r2r_dac) |
| 30 | { |
| 31 | //printf("updating %s to %f\n", name().cstr(), m_R.Value()); |
| 32 | |
| 33 | update_dev(); |
| 34 | |
| 35 | double V = m_VIN.Value() / (double) (1 << m_num.Value()) * (double) m_val.Value(); |
| 36 | |
| 37 | this->set(1.0 / m_R.Value(), V, 0.0); |
| 38 | } |
| 39 | |
trunk/src/emu/netlist/devices/nld_r2r_dac.h
| r0 | r31137 | |
| 1 | // license:GPL-2.0+ |
| 2 | // copyright-holders:Couriersud |
| 3 | /* |
| 4 | * nld_R2R_DAC.h |
| 5 | * |
| 6 | * DMR2R_DAC: R-2R DAC |
| 7 | * |
| 8 | * Generic R-2R DAC ... This is fast. |
| 9 | * 2R |
| 10 | * Bit n >----RRR----+---------> Vout |
| 11 | * | |
| 12 | * R |
| 13 | * R R |
| 14 | * R |
| 15 | * | |
| 16 | * . |
| 17 | * . |
| 18 | * 2R | |
| 19 | * Bit 2 >----RRR----+ |
| 20 | * | |
| 21 | * R |
| 22 | * R R |
| 23 | * R |
| 24 | * | |
| 25 | * 2R | |
| 26 | * Bit 1 >----RRR----+ |
| 27 | * | |
| 28 | * R |
| 29 | * R 2R |
| 30 | * R |
| 31 | * | |
| 32 | * V0 |
| 33 | * |
| 34 | * Using Thevenin's Theorem, this can be written as |
| 35 | * |
| 36 | * +---RRR-----------> Vout |
| 37 | * | |
| 38 | * V |
| 39 | * V V = VAL / 2^n * Vin |
| 40 | * V |
| 41 | * | |
| 42 | * V0 |
| 43 | * |
| 44 | */ |
| 45 | |
| 46 | #ifndef NLD_R2R_DAC_H_ |
| 47 | #define NLD_R2R_DAC_H_ |
| 48 | |
| 49 | #include "../nl_base.h" |
| 50 | #include "../analog/nld_twoterm.h" |
| 51 | |
| 52 | #define R2R_DAC(_name, _VIN, _R, _N) \ |
| 53 | NET_REGISTER_DEV(r2r_dac, _name) \ |
| 54 | NETDEV_PARAMI(_name, VIN, _VIN) \ |
| 55 | NETDEV_PARAMI(_name, R, _R) \ |
| 56 | NETDEV_PARAMI(_name, N, _N) |
| 57 | |
| 58 | NETLIB_DEVICE_WITH_PARAMS_DERIVED(r2r_dac, twoterm, |
| 59 | netlist_param_double_t m_VIN; |
| 60 | netlist_param_double_t m_R; |
| 61 | netlist_param_int_t m_num; |
| 62 | netlist_param_int_t m_val; |
| 63 | ); |
| 64 | |
| 65 | |
| 66 | #endif /* NLD_R2R_DAC_H_ */ |
trunk/src/emu/netlist/devices/net_lib.c
| r31136 | r31137 | |
| 89 | 89 | ENTRY(D, DIODE, "model") |
| 90 | 90 | ENTRY(VCVS, VCVS, "-") // FIXME: STD parameters ? |
| 91 | 91 | ENTRY(VCCS, VCCS, "-") |
| 92 | ENTRY(CCCS, CCCS, "-") |
| 93 | ENTRY(dummy_input, DUMMY_INPUT, "-") |
| 92 | 94 | ENTRY(QBJT_EB, QBJT_EB, "model") |
| 93 | 95 | ENTRY(QBJT_switch, QBJT_SW, "model") |
| 94 | 96 | ENTRY(ttl_input, TTL_INPUT, "IN") |
| r31136 | r31137 | |
| 129 | 131 | ENTRY(SN74LS629, SN74LS629, "CAP") |
| 130 | 132 | ENTRY(9316, TTL_9316, "+CLK,ENP,ENT,CLRQ,LOADQ,A,B,C,D") |
| 131 | 133 | ENTRY(NE555, NE555, "-") |
| 134 | ENTRY(r2r_dac, R2R_DAC, "+VIN,R,N") |
| 132 | 135 | ENTRY(4020_dip, CD_4020_DIP, "-") |
| 133 | 136 | ENTRY(4066_dip, CD_4066_DIP, "-") |
| 134 | 137 | ENTRY(7400_dip, TTL_7400_DIP, "-") |
trunk/src/emu/netlist/devices/nld_system.h
| r31136 | r31137 | |
| 13 | 13 | #include "../nl_base.h" |
| 14 | 14 | #include "../analog/nld_twoterm.h" |
| 15 | 15 | |
| 16 | | // ---------------------------------------------------------------------------------------- |
| 16 | // ----------------------------------------------------------------------------- |
| 17 | 17 | // Macros |
| 18 | | // ---------------------------------------------------------------------------------------- |
| 18 | // ----------------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | | #define TTL_INPUT(_name, _v) \ |
| 21 | | NET_REGISTER_DEV(ttl_input, _name) \ |
| 20 | #define TTL_INPUT(_name, _v) \ |
| 21 | NET_REGISTER_DEV(ttl_input, _name) \ |
| 22 | 22 | PARAM(_name.IN, _v) |
| 23 | 23 | |
| 24 | | #define ANALOG_INPUT(_name, _v) \ |
| 25 | | NET_REGISTER_DEV(analog_input, _name) \ |
| 24 | #define ANALOG_INPUT(_name, _v) \ |
| 25 | NET_REGISTER_DEV(analog_input, _name) \ |
| 26 | 26 | PARAM(_name.IN, _v) |
| 27 | 27 | |
| 28 | | #define MAINCLOCK(_name, _freq) \ |
| 29 | | NET_REGISTER_DEV(mainclock, _name) \ |
| 28 | #define MAINCLOCK(_name, _freq) \ |
| 29 | NET_REGISTER_DEV(mainclock, _name) \ |
| 30 | 30 | PARAM(_name.FREQ, _freq) |
| 31 | 31 | |
| 32 | | #define CLOCK(_name, _freq) \ |
| 33 | | NET_REGISTER_DEV(clock, _name) \ |
| 32 | #define CLOCK(_name, _freq) \ |
| 33 | NET_REGISTER_DEV(clock, _name) \ |
| 34 | 34 | PARAM(_name.FREQ, _freq) |
| 35 | 35 | |
| 36 | | #define GNDA() \ |
| 36 | #define GNDA() \ |
| 37 | 37 | NET_REGISTER_DEV(gnd, GND) |
| 38 | 38 | |
| 39 | | // ---------------------------------------------------------------------------------------- |
| 39 | #define DUMMY_INPUT(_name) \ |
| 40 | NET_REGISTER_DEV(dummy_input, _name) |
| 41 | |
| 42 | // ----------------------------------------------------------------------------- |
| 40 | 43 | // mainclock |
| 41 | | // ---------------------------------------------------------------------------------------- |
| 44 | // ----------------------------------------------------------------------------- |
| 42 | 45 | |
| 43 | 46 | NETLIB_DEVICE_WITH_PARAMS(mainclock, |
| 44 | 47 | public: |
| r31136 | r31137 | |
| 50 | 53 | ATTR_HOT inline static void mc_update(netlist_logic_net_t &net); |
| 51 | 54 | ); |
| 52 | 55 | |
| 53 | | // ---------------------------------------------------------------------------------------- |
| 56 | // ----------------------------------------------------------------------------- |
| 54 | 57 | // clock |
| 55 | | // ---------------------------------------------------------------------------------------- |
| 58 | // ----------------------------------------------------------------------------- |
| 56 | 59 | |
| 57 | 60 | NETLIB_DEVICE_WITH_PARAMS(clock, |
| 58 | 61 | netlist_ttl_input_t m_feedback; |
| r31136 | r31137 | |
| 63 | 66 | ); |
| 64 | 67 | |
| 65 | 68 | |
| 66 | | // ---------------------------------------------------------------------------------------- |
| 69 | // ----------------------------------------------------------------------------- |
| 67 | 70 | // Special support devices ... |
| 68 | | // ---------------------------------------------------------------------------------------- |
| 71 | // ----------------------------------------------------------------------------- |
| 69 | 72 | |
| 70 | 73 | NETLIB_DEVICE_WITH_PARAMS(ttl_input, |
| 71 | 74 | netlist_ttl_output_t m_Q; |
| r31136 | r31137 | |
| 79 | 82 | netlist_param_double_t m_IN; |
| 80 | 83 | ); |
| 81 | 84 | |
| 82 | | // ---------------------------------------------------------------------------------------- |
| 85 | // ----------------------------------------------------------------------------- |
| 83 | 86 | // nld_gnd |
| 84 | | // ---------------------------------------------------------------------------------------- |
| 87 | // ----------------------------------------------------------------------------- |
| 85 | 88 | |
| 86 | | class nld_gnd : public netlist_device_t |
| 89 | class NETLIB_NAME(gnd) : public netlist_device_t |
| 87 | 90 | { |
| 88 | 91 | public: |
| 89 | | ATTR_COLD nld_gnd() |
| 92 | ATTR_COLD NETLIB_NAME(gnd)() |
| 90 | 93 | : netlist_device_t(GND) { } |
| 91 | 94 | |
| 92 | | ATTR_COLD virtual ~nld_gnd() {} |
| 95 | ATTR_COLD virtual ~NETLIB_NAME(gnd)() {} |
| 93 | 96 | |
| 94 | 97 | protected: |
| 95 | 98 | |
| r31136 | r31137 | |
| 112 | 115 | |
| 113 | 116 | }; |
| 114 | 117 | |
| 118 | // ----------------------------------------------------------------------------- |
| 119 | // nld_dummy_input |
| 120 | // ----------------------------------------------------------------------------- |
| 115 | 121 | |
| 116 | | // ---------------------------------------------------------------------------------------- |
| 122 | class NETLIB_NAME(dummy_input) : public netlist_device_t |
| 123 | { |
| 124 | public: |
| 125 | ATTR_COLD NETLIB_NAME(dummy_input)() |
| 126 | : netlist_device_t(DUMMY) { } |
| 127 | |
| 128 | ATTR_COLD virtual ~NETLIB_NAME(dummy_input)() {} |
| 129 | |
| 130 | protected: |
| 131 | |
| 132 | ATTR_COLD void start() |
| 133 | { |
| 134 | register_input("I", m_I); |
| 135 | } |
| 136 | |
| 137 | ATTR_COLD void reset() |
| 138 | { |
| 139 | } |
| 140 | |
| 141 | ATTR_HOT ATTR_ALIGN void update() |
| 142 | { |
| 143 | } |
| 144 | |
| 145 | private: |
| 146 | netlist_analog_input_t m_I; |
| 147 | |
| 148 | }; |
| 149 | |
| 150 | |
| 151 | // ----------------------------------------------------------------------------- |
| 117 | 152 | // netdev_a_to_d |
| 118 | | // ---------------------------------------------------------------------------------------- |
| 153 | // ----------------------------------------------------------------------------- |
| 119 | 154 | |
| 120 | 155 | class nld_a_to_d_proxy : public netlist_device_t |
| 121 | 156 | { |
| r31136 | r31137 | |
| 155 | 190 | |
| 156 | 191 | }; |
| 157 | 192 | |
| 158 | | // ---------------------------------------------------------------------------------------- |
| 193 | // ----------------------------------------------------------------------------- |
| 159 | 194 | // nld_base_d_to_a_proxy |
| 160 | | // ---------------------------------------------------------------------------------------- |
| 195 | // ----------------------------------------------------------------------------- |
| 161 | 196 | |
| 162 | 197 | class nld_base_d_to_a_proxy : public netlist_device_t |
| 163 | 198 | { |
trunk/src/emu/netlist/analog/nld_fourterm.c
| r31136 | r31137 | |
| 13 | 13 | |
| 14 | 14 | NETLIB_START(VCCS) |
| 15 | 15 | { |
| 16 | | register_param("G", m_G, 1.0); |
| 17 | | register_param("RI", m_RI, 1.0 / netlist().gmin()); |
| 16 | start_internal(1.0 / netlist().gmin()); |
| 17 | m_gfac = 1.0; |
| 18 | } |
| 18 | 19 | |
| 19 | | register_terminal("IP", m_IP); |
| 20 | | register_terminal("IN", m_IN); |
| 21 | | register_terminal("OP", m_OP); |
| 22 | | register_terminal("ON", m_ON); |
| 20 | void NETLIB_NAME(VCCS)::start_internal(const double def_RI) |
| 21 | { |
| 22 | register_param("G", m_G, 1.0); |
| 23 | register_param("RI", m_RI, def_RI); |
| 23 | 24 | |
| 24 | | register_terminal("_OP1", m_OP1); |
| 25 | | register_terminal("_ON1", m_ON1); |
| 25 | register_terminal("IP", m_IP); |
| 26 | register_terminal("IN", m_IN); |
| 27 | register_terminal("OP", m_OP); |
| 28 | register_terminal("ON", m_ON); |
| 26 | 29 | |
| 27 | | m_IP.m_otherterm = &m_IN; // <= this should be NULL and terminal be filtered out prior to solving... |
| 28 | | m_IN.m_otherterm = &m_IP; // <= this should be NULL and terminal be filtered out prior to solving... |
| 30 | register_terminal("_OP1", m_OP1); |
| 31 | register_terminal("_ON1", m_ON1); |
| 29 | 32 | |
| 30 | | m_OP.m_otherterm = &m_IP; |
| 31 | | m_OP1.m_otherterm = &m_IN; |
| 33 | m_IP.m_otherterm = &m_IN; // <= this should be NULL and terminal be filtered out prior to solving... |
| 34 | m_IN.m_otherterm = &m_IP; // <= this should be NULL and terminal be filtered out prior to solving... |
| 32 | 35 | |
| 33 | | m_ON.m_otherterm = &m_IP; |
| 34 | | m_ON1.m_otherterm = &m_IN; |
| 36 | m_OP.m_otherterm = &m_IP; |
| 37 | m_OP1.m_otherterm = &m_IN; |
| 35 | 38 | |
| 36 | | connect(m_OP, m_OP1); |
| 37 | | connect(m_ON, m_ON1); |
| 39 | m_ON.m_otherterm = &m_IP; |
| 40 | m_ON1.m_otherterm = &m_IN; |
| 38 | 41 | |
| 39 | | m_gfac = 1.0; |
| 42 | connect(m_OP, m_OP1); |
| 43 | connect(m_ON, m_ON1); |
| 40 | 44 | } |
| 41 | 45 | |
| 42 | 46 | NETLIB_RESET(VCCS) |
| r31136 | r31137 | |
| 73 | 77 | } |
| 74 | 78 | |
| 75 | 79 | // ---------------------------------------------------------------------------------------- |
| 80 | // nld_CCCS |
| 81 | // ---------------------------------------------------------------------------------------- |
| 82 | |
| 83 | NETLIB_START(CCCS) |
| 84 | { |
| 85 | start_internal(1.0); |
| 86 | m_gfac = 1.0 / m_RI.Value(); |
| 87 | } |
| 88 | |
| 89 | NETLIB_RESET(CCCS) |
| 90 | { |
| 91 | NETLIB_NAME(VCCS)::reset(); |
| 92 | } |
| 93 | |
| 94 | NETLIB_UPDATE_PARAM(CCCS) |
| 95 | { |
| 96 | NETLIB_NAME(VCCS)::update_param(); |
| 97 | } |
| 98 | |
| 99 | NETLIB_UPDATE(CCCS) |
| 100 | { |
| 101 | NETLIB_NAME(VCCS)::update(); |
| 102 | } |
| 103 | |
| 104 | // ---------------------------------------------------------------------------------------- |
| 76 | 105 | // nld_VCVS |
| 77 | 106 | // ---------------------------------------------------------------------------------------- |
| 78 | 107 | |
trunk/src/emu/netlist/analog/nld_fourterm.h
| r31136 | r31137 | |
| 17 | 17 | #define VCCS(_name) \ |
| 18 | 18 | NET_REGISTER_DEV(VCCS, _name) |
| 19 | 19 | |
| 20 | #define CCCS(_name) \ |
| 21 | NET_REGISTER_DEV(CCCS, _name) |
| 22 | |
| 20 | 23 | #define VCVS(_name) \ |
| 21 | 24 | NET_REGISTER_DEV(VCVS, _name) |
| 22 | 25 | |
| 23 | | // ---------------------------------------------------------------------------------------- |
| 24 | | // nld_CCCS |
| 25 | | // ---------------------------------------------------------------------------------------- |
| 26 | 26 | |
| 27 | | /* |
| 28 | | * Current controlled current source |
| 29 | | * |
| 30 | | * IP ---+ +------> OP |
| 31 | | * | | |
| 32 | | * RI I |
| 33 | | * RI => G => I IOut = (V(IP)-V(IN)) / RI * G |
| 34 | | * RI I |
| 35 | | * | | |
| 36 | | * IN ---+ +------< ON |
| 37 | | * |
| 38 | | * G=1 ==> 1A ==> 1A |
| 39 | | * |
| 40 | | * RI = 1 |
| 41 | | * |
| 42 | | * FIXME: This needs extremely high levels of accuracy to work |
| 43 | | * With the current default of 1mv we can only measure |
| 44 | | * currents of 1mA. Therefore not yet implemented. |
| 45 | | * |
| 46 | | */ |
| 47 | | |
| 48 | | |
| 49 | 27 | // ---------------------------------------------------------------------------------------- |
| 50 | 28 | // nld_VCCS |
| 51 | 29 | // ---------------------------------------------------------------------------------------- |
| r31136 | r31137 | |
| 81 | 59 | ATTR_COLD virtual void update_param(); |
| 82 | 60 | ATTR_HOT ATTR_ALIGN void update(); |
| 83 | 61 | |
| 62 | ATTR_COLD void start_internal(const double def_RI); |
| 63 | |
| 84 | 64 | netlist_terminal_t m_OP; |
| 85 | 65 | netlist_terminal_t m_ON; |
| 86 | 66 | |
| r31136 | r31137 | |
| 97 | 77 | }; |
| 98 | 78 | |
| 99 | 79 | // ---------------------------------------------------------------------------------------- |
| 80 | // nld_CCCS |
| 81 | // ---------------------------------------------------------------------------------------- |
| 82 | |
| 83 | /* |
| 84 | * Current controlled current source |
| 85 | * |
| 86 | * IP ---+ +------> OP |
| 87 | * | | |
| 88 | * RI I |
| 89 | * RI => G => I IOut = (V(IP)-V(IN)) / RI * G |
| 90 | * RI I |
| 91 | * | | |
| 92 | * IN ---+ +------< ON |
| 93 | * |
| 94 | * G=1 ==> 1A ==> 1A |
| 95 | * |
| 96 | * RI = 1 |
| 97 | * |
| 98 | * FIXME: This needs extremely high levels of accuracy to work |
| 99 | * With the current default of 1mv we can only measure |
| 100 | * currents of 1mA. |
| 101 | * |
| 102 | */ |
| 103 | |
| 104 | class NETLIB_NAME(CCCS) : public NETLIB_NAME(VCCS) |
| 105 | { |
| 106 | public: |
| 107 | ATTR_COLD NETLIB_NAME(CCCS)() |
| 108 | : NETLIB_NAME(VCCS)(CCCS), m_gfac(1.0) { } |
| 109 | //ATTR_COLD NETLIB_NAME(CCCS)(const family_t afamily) |
| 110 | //: netlist_device_t(afamily), m_gfac(1.0) { } |
| 111 | |
| 112 | protected: |
| 113 | ATTR_COLD virtual void start(); |
| 114 | ATTR_COLD virtual void reset(); |
| 115 | ATTR_COLD virtual void update_param(); |
| 116 | ATTR_HOT ATTR_ALIGN void update(); |
| 117 | |
| 118 | double m_gfac; |
| 119 | }; |
| 120 | |
| 121 | |
| 122 | // ---------------------------------------------------------------------------------------- |
| 100 | 123 | // nld_VCVS |
| 101 | 124 | // ---------------------------------------------------------------------------------------- |
| 102 | 125 | |