mirror of
https://github.com/holub/mame
synced 2025-07-03 00:56:03 +03:00
Code maintenance and bug fixes. (nw)
Rewrote and simplified tiny bits. Fixed inappropriate use of netlist_sig_t for non-boolean values.
This commit is contained in:
parent
09553c51a4
commit
0f0e8853f3
@ -29,7 +29,7 @@ namespace netlist
|
||||
logic_input_t m_CLK;
|
||||
logic_output_t m_Q;
|
||||
logic_output_t m_QQ;
|
||||
state_var<unsigned> m_nextD;
|
||||
state_var<netlist_sig_t> m_nextD;
|
||||
|
||||
inline void newstate(const netlist_sig_t stateQ, const netlist_sig_t stateQQ);
|
||||
|
||||
|
@ -89,8 +89,8 @@ namespace netlist
|
||||
|
||||
NETLIB_UPDATE(7483)
|
||||
{
|
||||
netlist_sig_t a = (m_A1() << 0) | (m_A2() << 1) | (m_A3() << 2) | (m_A4() << 3);
|
||||
netlist_sig_t b = (m_B1() << 0) | (m_B2() << 1) | (m_B3() << 2) | (m_B4() << 3);
|
||||
unsigned a = (m_A1() << 0) | (m_A2() << 1) | (m_A3() << 2) | (m_A4() << 3);
|
||||
unsigned b = (m_B1() << 0) | (m_B2() << 1) | (m_B3() << 2) | (m_B4() << 3);
|
||||
|
||||
unsigned r = a + b + m_C0();
|
||||
|
||||
|
@ -63,7 +63,7 @@ namespace netlist
|
||||
|
||||
state_var_sig m_reset;
|
||||
state_var_sig m_a;
|
||||
state_var_sig m_bcd;
|
||||
state_var_u8 m_bcd;
|
||||
|
||||
logic_input_t m_CLKA;
|
||||
logic_input_t m_CLKB;
|
||||
|
@ -160,7 +160,8 @@ namespace netlist
|
||||
for (std::size_t i = 0; i < m_NI; i++)
|
||||
{
|
||||
m_I[i].activate();
|
||||
nstate |= (m_I[i]() ? (1 << i) : 0);
|
||||
//nstate |= (m_I[i]() ? (1 << i) : 0);
|
||||
nstate |= (m_I[i]() << i);
|
||||
mt = std::max(this->m_I[i].net().time(), mt);
|
||||
}
|
||||
else
|
||||
@ -168,7 +169,8 @@ namespace netlist
|
||||
{
|
||||
if ((ign & 1))
|
||||
m_I[i].activate();
|
||||
nstate |= (m_I[i]() ? (1 << i) : 0);
|
||||
//nstate |= (m_I[i]() ? (1 << i) : 0);
|
||||
nstate |= (m_I[i]() << i);
|
||||
ign >>= 1;
|
||||
}
|
||||
}
|
||||
@ -177,12 +179,14 @@ namespace netlist
|
||||
if (!doOUT)
|
||||
for (std::size_t i = 0; i < m_NI; i++)
|
||||
{
|
||||
nstate |= (m_I[i]() ? (1 << i) : 0);
|
||||
//nstate |= (m_I[i]() ? (1 << i) : 0);
|
||||
nstate |= (m_I[i]() << i);
|
||||
mt = std::max(this->m_I[i].net().time(), mt);
|
||||
}
|
||||
else
|
||||
for (std::size_t i = 0; i < m_NI; i++)
|
||||
nstate |= (m_I[i]() ? (1 << i) : 0);
|
||||
//nstate |= (m_I[i]() ? (1 << i) : 0);
|
||||
nstate |= (m_I[i]() << i);
|
||||
}
|
||||
|
||||
const type_t outstate(m_ttp.m_outs[nstate]);
|
||||
|
@ -313,7 +313,7 @@ void netlist_t::start()
|
||||
}
|
||||
}
|
||||
|
||||
log().debug("Searching for mainclock and solver ...\n");
|
||||
log().debug("Searching for solver and parameters ...\n");
|
||||
|
||||
m_solver = get_single_device<devices::NETLIB_NAME(solver)>("solver");
|
||||
m_params = get_single_device<devices::NETLIB_NAME(netlistparams)>("parameter");
|
||||
@ -784,7 +784,6 @@ detail::net_t::net_t(netlist_t &nl, const pstring &aname, core_terminal_t *mr)
|
||||
, m_new_Q(*this, "m_new_Q", 0)
|
||||
, m_cur_Q (*this, "m_cur_Q", 0)
|
||||
, m_in_queue(*this, "m_in_queue", QS_DELIVERED)
|
||||
, m_active(*this, "m_active", 0)
|
||||
, m_time(*this, "m_time", netlist_time::zero())
|
||||
, m_railterminal(mr)
|
||||
{
|
||||
@ -797,10 +796,9 @@ detail::net_t::~net_t()
|
||||
|
||||
void detail::net_t::inc_active(core_terminal_t &term) NL_NOEXCEPT
|
||||
{
|
||||
const bool was_empty = m_list_active.empty();
|
||||
m_list_active.push_front(&term);
|
||||
++m_active;
|
||||
nl_assert(m_active <= static_cast<int>(num_cons()));
|
||||
if (m_active == 1)
|
||||
if (was_empty)
|
||||
{
|
||||
railterminal().device().do_inc_active();
|
||||
if (m_in_queue == QS_DELAYED_DUE_TO_INACTIVE)
|
||||
@ -821,10 +819,8 @@ void detail::net_t::inc_active(core_terminal_t &term) NL_NOEXCEPT
|
||||
|
||||
void detail::net_t::dec_active(core_terminal_t &term) NL_NOEXCEPT
|
||||
{
|
||||
--m_active;
|
||||
nl_assert(m_active >= 0);
|
||||
m_list_active.remove(&term);
|
||||
if (m_active == 0)
|
||||
if (m_list_active.empty())
|
||||
railterminal().device().do_dec_active();
|
||||
}
|
||||
|
||||
@ -832,15 +828,12 @@ void detail::net_t::rebuild_list()
|
||||
{
|
||||
/* rebuild m_list */
|
||||
|
||||
int cnt = 0;
|
||||
m_list_active.clear();
|
||||
for (auto & term : m_core_terms)
|
||||
if (term->state() != logic_t::STATE_INP_PASSIVE)
|
||||
{
|
||||
m_list_active.push_back(term);
|
||||
cnt++;
|
||||
}
|
||||
m_active = cnt;
|
||||
}
|
||||
|
||||
void detail::net_t::process(const unsigned &mask)
|
||||
@ -883,7 +876,6 @@ void detail::net_t::update_devs() NL_NOEXCEPT
|
||||
void detail::net_t::reset()
|
||||
{
|
||||
m_time = netlist_time::zero();
|
||||
m_active = 0;
|
||||
m_in_queue = QS_DELIVERED;
|
||||
|
||||
m_new_Q = 0;
|
||||
@ -898,14 +890,12 @@ void detail::net_t::reset()
|
||||
|
||||
m_list_active.clear();
|
||||
for (core_terminal_t *ct : m_core_terms)
|
||||
m_list_active.push_back(ct);
|
||||
if (ct->state() != logic_t::STATE_INP_PASSIVE)
|
||||
m_list_active.push_back(ct);
|
||||
|
||||
for (core_terminal_t *ct : m_core_terms)
|
||||
ct->reset();
|
||||
|
||||
for (core_terminal_t *ct : m_core_terms)
|
||||
if (ct->state() != logic_t::STATE_INP_PASSIVE)
|
||||
m_active++;
|
||||
}
|
||||
|
||||
void detail::net_t::add_terminal(detail::core_terminal_t &terminal)
|
||||
@ -918,9 +908,6 @@ void detail::net_t::add_terminal(detail::core_terminal_t &terminal)
|
||||
terminal.set_net(this);
|
||||
|
||||
m_core_terms.push_back(&terminal);
|
||||
|
||||
if (terminal.state() != logic_t::STATE_INP_PASSIVE)
|
||||
m_active++;
|
||||
}
|
||||
|
||||
void detail::net_t::remove_terminal(detail::core_terminal_t &terminal)
|
||||
@ -933,8 +920,6 @@ void detail::net_t::remove_terminal(detail::core_terminal_t &terminal)
|
||||
else
|
||||
netlist().log().fatal(MF_2_REMOVE_TERMINAL_1_FROM_NET_2, terminal.name(),
|
||||
this->name());
|
||||
if (terminal.state() != logic_t::STATE_INP_PASSIVE)
|
||||
m_active--;
|
||||
}
|
||||
|
||||
void detail::net_t::move_connections(detail::net_t &dest_net)
|
||||
@ -942,7 +927,6 @@ void detail::net_t::move_connections(detail::net_t &dest_net)
|
||||
for (auto &ct : m_core_terms)
|
||||
dest_net.add_terminal(*ct);
|
||||
m_core_terms.clear();
|
||||
m_active = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
@ -28,7 +28,11 @@
|
||||
// Type definitions
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
/*! netlist_sig_t is the type used for logic signals. */
|
||||
/*! @brief netlist_sig_t is the type used for logic signals.
|
||||
*
|
||||
* This may be any of bool, uint8_t, uint16_t, uin32_t and uint64_t.
|
||||
* The choice has little to no impact on performance.
|
||||
*/
|
||||
using netlist_sig_t = std::uint32_t;
|
||||
|
||||
//============================================================
|
||||
@ -649,7 +653,7 @@ namespace netlist
|
||||
nldelegate delegate = nldelegate());
|
||||
virtual ~logic_input_t();
|
||||
|
||||
netlist_sig_t operator()() const NL_NOEXCEPT
|
||||
inline netlist_sig_t operator()() const NL_NOEXCEPT
|
||||
{
|
||||
return Q();
|
||||
}
|
||||
@ -757,7 +761,6 @@ namespace netlist
|
||||
state_var<netlist_sig_t> m_new_Q;
|
||||
state_var<netlist_sig_t> m_cur_Q;
|
||||
state_var<queue_status> m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */
|
||||
state_var_s32 m_active;
|
||||
|
||||
state_var<netlist_time> m_time;
|
||||
|
||||
@ -775,7 +778,7 @@ namespace netlist
|
||||
logic_net_t(netlist_t &nl, const pstring &aname, detail::core_terminal_t *mr = nullptr);
|
||||
virtual ~logic_net_t();
|
||||
|
||||
netlist_sig_t Q() const NL_NOEXCEPT { return m_cur_Q; }
|
||||
inline netlist_sig_t Q() const NL_NOEXCEPT { return m_cur_Q; }
|
||||
void initial(const netlist_sig_t val) NL_NOEXCEPT { m_cur_Q = m_new_Q = val; }
|
||||
|
||||
void set_Q_and_push(const netlist_sig_t newQ, const netlist_time &delay) NL_NOEXCEPT
|
||||
@ -1431,7 +1434,7 @@ namespace netlist
|
||||
if (is_queued())
|
||||
netlist().queue().remove(this);
|
||||
m_time = netlist().time() + delay;
|
||||
m_in_queue = (m_active > 0) ? QS_QUEUED : QS_DELAYED_DUE_TO_INACTIVE; /* queued ? */
|
||||
m_in_queue = (!m_list_active.empty()) ? QS_QUEUED : QS_DELAYED_DUE_TO_INACTIVE; /* queued ? */
|
||||
if (m_in_queue == QS_QUEUED)
|
||||
netlist().queue().push(queue_t::entry_t(m_time, this));
|
||||
}
|
||||
|
@ -95,15 +95,9 @@
|
||||
//#define nl_double float
|
||||
//#define NL_FCONST(x) (x ## f)
|
||||
|
||||
//#define nl_double double
|
||||
#define NL_FCONST(x) x
|
||||
using nl_double = double;
|
||||
|
||||
/* The following option determines how object::update is called.
|
||||
* If set to 1, a virtual call is used. If it is left undefined, the best
|
||||
* approach will be automatically selected.
|
||||
*/
|
||||
|
||||
//============================================================
|
||||
// WARNINGS
|
||||
//============================================================
|
||||
|
Loading…
Reference in New Issue
Block a user