summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/core/logic.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/core/logic.h')
-rw-r--r--src/lib/netlist/core/logic.h82
1 files changed, 42 insertions, 40 deletions
diff --git a/src/lib/netlist/core/logic.h b/src/lib/netlist/core/logic.h
index 51ddf0b9d18..ef567398c84 100644
--- a/src/lib/netlist/core/logic.h
+++ b/src/lib/netlist/core/logic.h
@@ -2,7 +2,7 @@
// copyright-holders:Couriersud
///
-/// \file param.h
+/// \file logic.h
///
#ifndef NL_CORE_LOGIC_H_
@@ -22,44 +22,46 @@
namespace netlist
{
- // -----------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// logic_t
- // -----------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
- class logic_t : public detail::core_terminal_t, public logic_family_t
+ class logic_t
+ : public detail::core_terminal_t
+ , public logic_family_t
{
public:
- logic_t(device_t &dev, const pstring &aname,
- state_e terminal_state, nldelegate delegate);
+ logic_t(device_t &dev, const pstring &aname, state_e terminal_state,
+ nl_delegate delegate);
- logic_net_t & net() noexcept
+ logic_net_t &net() noexcept
{
return plib::downcast<logic_net_t &>(core_terminal_t::net());
}
- const logic_net_t & net() const noexcept
+ constexpr const logic_net_t &net() const noexcept
{
return plib::downcast<const logic_net_t &>(core_terminal_t::net());
}
};
- // -----------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// logic_input_t
- // -----------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
class logic_input_t : public logic_t
{
public:
logic_input_t(device_t &dev, const pstring &aname,
- nldelegate delegate);
+ nl_delegate delegate);
- const netlist_sig_t &operator()() const noexcept
+ // const netlist_sig_t &operator()() const noexcept
+ constexpr netlist_sig_t operator()() const noexcept
{
gsl_Expects(terminal_state() != STATE_INP_PASSIVE);
- #if NL_USE_COPY_INSTEAD_OF_REFERENCE
- return m_Q;
- #else
- return net().Q();
- #endif
+ if constexpr (config::use_copy_instead_of_reference::value)
+ return m_Q_CIR;
+ else
+ return net().Q();
}
void inactivate() noexcept
@@ -99,14 +101,13 @@ namespace netlist
}
};
- // -----------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// logic_output_t
- // -----------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
class logic_output_t : public logic_t
{
public:
-
/// \brief logic output constructor
///
/// The third parameter does nothing. It is provided only for
@@ -114,20 +115,21 @@ namespace netlist
///
/// \param dev Device owning this output
/// \param aname The name of this output
- /// \param dummy Dummy parameter to allow construction like tristate output
+ /// \param dummy Dummy parameter to allow construction like tristate
+ /// output
///
logic_output_t(device_t &dev, const pstring &aname, bool dummy = false);
void initial(netlist_sig_t val) noexcept;
- void push(const netlist_sig_t &newQ, const netlist_time &delay) noexcept
+ void push(netlist_sig_t newQ, const netlist_time &delay) noexcept
{
gsl_Expects(delay >= netlist_time::zero());
m_my_net.set_Q_and_push(newQ, delay); // take the shortcut
}
- void set_Q_time(const netlist_sig_t &newQ, const netlist_time_ext &at) noexcept
+ void set_Q_time(netlist_sig_t newQ, const netlist_time_ext &at) noexcept
{
m_my_net.set_Q_time(newQ, at); // take the shortcut
}
@@ -140,19 +142,21 @@ namespace netlist
///
/// This function terminates if actually called.
///
- [[noreturn]] static void set_tristate(netlist_sig_t v,
- netlist_time ts_off_on, netlist_time ts_on_off)
+ [[noreturn]] static void set_tristate([[maybe_unused]] netlist_sig_t v,
+ [[maybe_unused]] netlist_time ts_off_on,
+ [[maybe_unused]] netlist_time ts_on_off)
{
- plib::unused_var(v, ts_off_on, ts_on_off);
- plib::terminate("set_tristate on logic_output should never be called!");
+ plib::terminate(
+ "set_tristate on logic_output should never be called!");
}
+
private:
logic_net_t m_my_net;
};
- // -----------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// tristate_output_t
- // -----------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
/// \brief Tristate output
///
@@ -170,8 +174,8 @@ namespace netlist
class tristate_output_t : public logic_output_t
{
public:
-
- tristate_output_t(device_t &dev, const pstring &aname, bool force_logic);
+ tristate_output_t(device_t &dev, const pstring &aname,
+ bool force_logic);
void push(netlist_sig_t newQ, netlist_time delay) noexcept
{
@@ -180,31 +184,29 @@ namespace netlist
m_last_logic = newQ;
}
- void set_tristate(netlist_sig_t v,
- netlist_time ts_off_on, netlist_time ts_on_off) noexcept
+ void set_tristate(netlist_sig_t v, netlist_time ts_off_on,
+ netlist_time ts_on_off) noexcept
{
if (!m_force_logic)
if (v != m_tristate)
{
- logic_output_t::push((v != 0) ? OUT_TRISTATE() : m_last_logic, v ? ts_off_on : ts_on_off);
+ logic_output_t::push((v != 0) ? OUT_TRISTATE()
+ : m_last_logic,
+ v ? ts_off_on : ts_on_off);
m_tristate = v;
}
}
- bool is_force_logic() const noexcept
- {
- return m_force_logic;
- }
+ bool is_force_logic() const noexcept { return m_force_logic; }
private:
using logic_output_t::initial;
using logic_output_t::set_Q_time;
state_var<netlist_sig_t> m_last_logic;
state_var<netlist_sig_t> m_tristate;
- bool m_force_logic;
+ bool m_force_logic;
};
} // namespace netlist
-
#endif // NL_CORE_LOGIC_H_