Fix a bug in connecting nets. This bug surfaced during introduction of a "closer to reality" ttl output proxy. No WN

This commit is contained in:
Couriersud 2014-01-26 17:24:55 +00:00
parent e40590c72a
commit ec0aab6d74
5 changed files with 65 additions and 9 deletions

View File

@ -11,6 +11,7 @@
#include "../nl_setup.h"
#include "../nl_base.h"
#include "../analog/nld_twoterm.h"
// ----------------------------------------------------------------------------------------
// Macros
@ -155,7 +156,7 @@ protected:
};
// ----------------------------------------------------------------------------------------
// DIODE_to_a
// nld_base_d_to_a_proxy
// ----------------------------------------------------------------------------------------
class nld_base_d_to_a_proxy : public netlist_device_t
@ -183,7 +184,7 @@ protected:
private:
};
#if 1
class nld_d_to_a_proxy : public nld_base_d_to_a_proxy
{
public:
@ -219,5 +220,53 @@ protected:
private:
netlist_analog_output_t m_Q;
};
#else
class nld_d_to_a_proxy : public nld_base_d_to_a_proxy
{
public:
ATTR_COLD nld_d_to_a_proxy(netlist_output_t &out_proxied)
: nld_base_d_to_a_proxy(out_proxied)
{
}
ATTR_COLD virtual ~nld_d_to_a_proxy() {}
protected:
ATTR_COLD void start()
{
nld_base_d_to_a_proxy::start();
register_sub(m_R, "R");
register_output("_Q", m_Q);
register_subalias("Q", m_R.m_N);
connect(m_Q, m_R.m_P);
m_Q.initial(0);
m_R.set_R(m_family_desc->m_R_low);
}
ATTR_COLD void reset()
{
m_Q.initial(0);
m_R.set_R(m_family_desc->m_R_low);
}
ATTR_COLD virtual netlist_core_terminal_t &out()
{
return m_R.m_N;
}
ATTR_HOT ATTR_ALIGN void update()
{
m_R.set_R(INPLOGIC(m_I) ? m_family_desc->m_R_high : m_family_desc->m_R_low);
OUTANALOG(m_Q, INPLOGIC(m_I) ? m_family_desc->m_high_V : m_family_desc->m_low_V, NLTIME_FROM_NS(1));
}
private:
netlist_analog_output_t m_Q;
nld_R_base m_R;
};
#endif
#endif /* NLD_SYSTEM_H_ */

View File

@ -40,6 +40,7 @@ NETLISTOBJS+= \
$(NETLISTOBJ)/devices/nld_7420.o \
$(NETLISTOBJ)/devices/nld_7425.o \
$(NETLISTOBJ)/devices/nld_7427.o \
$(NETLISTOBJ)/devices/nld_7430.o \
$(NETLISTOBJ)/devices/nld_7448.o \
$(NETLISTOBJ)/devices/nld_7450.o \
$(NETLISTOBJ)/devices/nld_7474.o \

View File

@ -17,6 +17,8 @@ netlist_logic_family_desc_t netlist_family_ttl =
2.0, // m_high_thresh_V
0.3, // m_low_V - these depend on sinked/sourced current. Values should be suitable for typical applications.
3.4, // m_high_V
10.0, // m_g_low;
130.0, // m_g_high;
};
// ----------------------------------------------------------------------------------------

View File

@ -260,6 +260,8 @@ struct netlist_logic_family_desc_t
double m_high_thresh_V;
double m_low_V;
double m_high_V;
double m_R_low;
double m_R_high;
};
/* Terminals inherit the family description from the netlist_device

View File

@ -392,7 +392,8 @@ void netlist_setup_t::connect_input_output(netlist_input_t &in, netlist_output_t
{
nld_base_d_to_a_proxy *proxy = get_d_a_proxy(out);
proxy->out().net().register_con(in);
connect_terminals(proxy->out(), in);
//proxy->out().net().register_con(in);
}
else
{
@ -440,17 +441,13 @@ void netlist_setup_t::connect_terminal_output(netlist_terminal_t &in, netlist_ou
out.net().merge_net(&in.net());
else
out.net().register_con(in);
}
else if (out.isFamily(netlist_terminal_t::LOGIC))
{
NL_VERBOSE_OUT(("connect_terminal_output: connecting proxy\n"));
nld_base_d_to_a_proxy *proxy = get_d_a_proxy(out);
if (in.has_net())
proxy->out().net().merge_net(&in.net());
else
proxy->out().net().register_con(in);
connect_terminals(proxy->out(), in);
}
else
{
@ -494,6 +491,7 @@ void netlist_setup_t::connect_terminals(netlist_core_terminal_t &t1, netlist_cor
void netlist_setup_t::connect(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2)
{
NL_VERBOSE_OUT(("Connecting %s to %s\n", t1.name().cstr(), t2.name().cstr()));
// FIXME: amend device design so that warnings can be turned into errors
// Only variable inputs have this issue
if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::INPUT))
@ -577,11 +575,13 @@ void netlist_setup_t::resolve_inputs()
for (netlist_net_t * const * pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
(*pn)->late_save_register();
pstring errstr("");
NL_VERBOSE_OUT(("looking for terminals not connected ...\n"));
for (tagmap_terminal_t::entry_t *entry = m_terminals.first(); entry != NULL; entry = m_terminals.next(entry))
{
if (!entry->object()->has_net())
netlist().error("Found terminal %s without a net\n",
errstr += pstring::sprintf("Found terminal %s without a net\n",
entry->object()->name().cstr());
// FIXME: need a warning callback ....
#if 0
@ -590,6 +590,8 @@ void netlist_setup_t::resolve_inputs()
entry->object()->name().cstr());
#endif
}
if (errstr != "")
netlist().error("%s", errstr.cstr());
NL_VERBOSE_OUT(("looking for two terms connected to rail nets ...\n"));