Implemented CD4066 device - Quad Bilateral Switch. [Couriersud]

This commit is contained in:
Couriersud 2014-03-02 20:23:53 +00:00
parent 3e4d318b79
commit 4fcf7b5bcf
7 changed files with 204 additions and 0 deletions

3
.gitattributes vendored
View File

@ -362,6 +362,7 @@ nl_examples/7400_astable.c svneol=native#text/plain
nl_examples/bjt.c svneol=native#text/plain
nl_examples/bjt_eb.c svneol=native#text/plain
nl_examples/bjt_eb_pnp.c svneol=native#text/plain
nl_examples/cd4066.c svneol=native#text/plain
nl_examples/msx_mixer_stage.c svneol=native#text/plain
nl_examples/ne555_astable.c svneol=native#text/plain
nl_examples/opamp.c svneol=native#text/plain
@ -2210,6 +2211,8 @@ src/emu/netlist/analog/nld_twoterm.c svneol=native#text/plain
src/emu/netlist/analog/nld_twoterm.h svneol=native#text/plain
src/emu/netlist/devices/net_lib.c svneol=native#text/plain
src/emu/netlist/devices/net_lib.h svneol=native#text/plain
src/emu/netlist/devices/nld_4066.c svneol=native#text/plain
src/emu/netlist/devices/nld_4066.h svneol=native#text/plain
src/emu/netlist/devices/nld_7400.c svneol=native#text/plain
src/emu/netlist/devices/nld_7400.h svneol=native#text/plain
src/emu/netlist/devices/nld_7402.c svneol=native#text/plain

44
nl_examples/cd4066.c Normal file
View File

@ -0,0 +1,44 @@
/*
* bjt.c
*
*/
#include "netlist/devices/net_lib.h"
NETLIST_START(cd4066)
/* Standard stuff */
CLOCK(clk, 1000) // 1000 Hz
SOLVER(Solver, 48000)
ANALOG_INPUT(V5, 5)
CD_4066_DIP(SW)
RES(R1, 1000)
NET_C(SW.7, GND)
NET_C(SW.14, V5)
NET_C(SW.13, clk)
NET_C(SW.1, V5)
NET_C(SW.2, R1.1)
NET_C(R1.2, GND)
// ground anything else
NET_C(SW.3, GND)
NET_C(SW.4, GND)
NET_C(SW.5, GND)
NET_C(SW.6, GND)
NET_C(SW.8, GND)
NET_C(SW.9, GND)
NET_C(SW.10, GND)
NET_C(SW.11, GND)
NET_C(SW.12, GND)
LOG(logB, clk)
LOG(logC, R1.1)
NETLIST_END()

View File

@ -122,6 +122,7 @@ void netlist_factory_t::initialize()
ENTRY(SN74LS629, SN74LS629, "CAP")
ENTRY(9316, TTL_9316, "+CLK,ENP,ENT,CLRQ,LOADQ,A,B,C,D")
ENTRY(NE555, NE555, "-")
ENTRY(4066_dip, CD_4066_DIP, "-")
ENTRY(7400_dip, TTL_7400_DIP, "-")
ENTRY(7402_dip, TTL_7402_DIP, "-")
ENTRY(7404_dip, TTL_7404_DIP, "-")

View File

@ -54,6 +54,7 @@
#include "nld_signal.h"
#include "nld_system.h"
#include "nld_4066.h"
#include "nld_7400.h"
#include "nld_7402.h"
#include "nld_7404.h"

View File

@ -0,0 +1,94 @@
/*
* nld_4066.c
*
*/
#include "nld_4066.h"
NETLIB_START(vdd_vss)
{
}
NETLIB_RESET(vdd_vss)
{
}
NETLIB_UPDATE(vdd_vss)
{
}
NETLIB_START(4066)
{
register_input("CTL", m_control);
register_sub(m_R, "R");
}
NETLIB_RESET(4066)
{
m_R.do_reset();
}
NETLIB_UPDATE(4066)
{
double sup = (supply->vdd() - supply->vss());
double low = 0.45 * sup;
double high = 0.55 * sup;
double in = INPANALOG(m_control) - supply->vss();
double rON = 270.0 * 5.0 / sup;
if (in < low)
{
m_R.set_R(1.0 / NETLIST_GMIN);
m_R.update_dev();
}
else if (in > high)
{
m_R.set_R(rON);
m_R.update_dev();
}
}
NETLIB_START(4066_dip)
{
register_sub(supply, "supply");
m_A.supply = m_B.supply = m_C.supply = m_D.supply = &supply;
register_sub(m_A, "A");
register_sub(m_B, "B");
register_sub(m_C, "C");
register_sub(m_D, "D");
register_subalias("1", m_A.m_R.m_P);
register_subalias("2", m_A.m_R.m_N);
register_subalias("3", m_B.m_R.m_P);
register_subalias("4", m_B.m_R.m_N);
register_subalias("5", m_B.m_control);
register_subalias("6", m_C.m_control);
register_input("7", supply.m_vss);
register_subalias("8", m_C.m_R.m_P);
register_subalias("9", m_C.m_R.m_N);
register_subalias("10", m_D.m_R.m_P);
register_subalias("11", m_D.m_R.m_N);
register_subalias("12", m_D.m_control);
register_subalias("13", m_A.m_control);
register_input("14", supply.m_vdd);
}
NETLIB_RESET(4066_dip)
{
m_A.do_reset();
m_B.do_reset();
m_C.do_reset();
m_D.do_reset();
}
NETLIB_UPDATE(4066_dip)
{
/* only called during startup */
m_A.update_dev();
m_B.update_dev();
m_C.update_dev();
m_D.update_dev();
}

View File

@ -0,0 +1,60 @@
// license:GPL-2.0+
// copyright-holders:Couriersud
/*
* nld_4066.h
*
* CD4066: Quad Bilateral Switch
*
* +--------------+
* INOUTA |1 ++ 14| VDD
* OUTINA |2 13| CONTROLA
* OUTINB |3 12| CONTROLD
* INOUTB |4 4066 11| INOUTD
* CONTROLB |5 10| OUTIND
* CONTROLC |6 9| OUTINC
* VSS |7 8| INOUTC
* +--------------+
*
* FIXME: These devices are slow (~125 ns). THis is currently not reflected
*
* Naming conventions follow National semiconductor datasheet
*
*/
#ifndef NLD_4066_H_
#define NLD_4066_H_
#include "../nl_base.h"
#include "../analog/nld_twoterm.h"
#define CD_4066_DIP(_name) \
NET_REGISTER_DEV(4066_dip, _name)
NETLIB_SUBDEVICE(vdd_vss,
netlist_analog_input_t m_vdd;
netlist_analog_input_t m_vss;
public:
ATTR_HOT inline double vdd() { return INPANALOG(m_vdd); }
ATTR_HOT inline double vss() { return INPANALOG(m_vss); }
);
NETLIB_SUBDEVICE(4066,
public:
netlist_analog_input_t m_control;
NETLIB_NAME(R) m_R;
NETLIB_NAME(vdd_vss) *supply;
);
NETLIB_DEVICE(4066_dip,
NETLIB_NAME(4066) m_A;
NETLIB_NAME(4066) m_B;
NETLIB_NAME(4066) m_C;
NETLIB_NAME(4066) m_D;
NETLIB_NAME(vdd_vss) supply;
);
#endif /* NLD_4066_H_ */

View File

@ -33,6 +33,7 @@ NETLISTOBJS+= \
$(NETLISTOBJ)/analog/nld_solver.o \
$(NETLISTOBJ)/analog/nld_switches.o \
$(NETLISTOBJ)/analog/nld_twoterm.o \
$(NETLISTOBJ)/devices/nld_4066.o \
$(NETLISTOBJ)/devices/nld_7400.o \
$(NETLISTOBJ)/devices/nld_7402.o \
$(NETLISTOBJ)/devices/nld_7404.o \