summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/core/device.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/core/device.h')
-rw-r--r--src/lib/netlist/core/device.h83
1 files changed, 64 insertions, 19 deletions
diff --git a/src/lib/netlist/core/device.h b/src/lib/netlist/core/device.h
index 33a1bdaac35..5f4a6937f23 100644
--- a/src/lib/netlist/core/device.h
+++ b/src/lib/netlist/core/device.h
@@ -9,29 +9,35 @@
#define NL_DEVICE_H_
#include "core_device.h"
+#include "logic_family.h"
#include "param.h"
namespace netlist
{
- // -----------------------------------------------------------------------------
+
+ // -------------------------------------------------------------------------
+ // device_t construction parameters
+ // -------------------------------------------------------------------------
+
+ using device_data_t = base_device_data_t;
+ // The type use to pass data on
+ using device_param_t = const device_data_t &;
+
+ // -------------------------------------------------------------------------
// device_t
- // -----------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
- class device_t : public base_device_t,
- public logic_family_t
+ class device_t : public base_device_t, public logic_family_t
{
public:
- device_t(netlist_state_t &owner, const pstring &name);
- device_t(netlist_state_t &owner, const pstring &name,
- const pstring &model);
- // only needed by proxies
- device_t(netlist_state_t &owner, const pstring &name,
- const logic_family_desc_t *desc);
+ using constructor_data_t = device_data_t;
+ using constructor_param_t = device_param_t;
+
+ device_t(device_param_t data);
- device_t(device_t &owner, const pstring &name);
- // pass in a default model - this may be overwritten by PARAM(DEVICE.MODEL, "XYZ(...)")
- device_t(device_t &owner, const pstring &name,
- const pstring &model);
+ device_t(device_param_t data, const pstring &model);
+ // only needed by proxies
+ device_t(device_param_t data, const logic_family_desc_t *desc);
device_t(const device_t &) = delete;
device_t &operator=(const device_t &) = delete;
@@ -42,8 +48,9 @@ namespace netlist
protected:
template <typename T1, typename T2>
- void push_two(T1 &term1, netlist_sig_t newQ1, const netlist_time &delay1,
- T2 &term2, netlist_sig_t newQ2, const netlist_time &delay2) noexcept
+ void push_two(T1 &term1, netlist_sig_t newQ1,
+ const netlist_time &delay1, T2 &term2, netlist_sig_t newQ2,
+ const netlist_time &delay2) noexcept
{
if (delay2 < delay1)
{
@@ -57,13 +64,51 @@ namespace netlist
}
}
-
- //NETLIB_UPDATE_TERMINALSI() { }
+ // NETLIB_UPDATE_TERMINALSI() { }
private:
param_model_t m_model;
};
-} // namespace netlist
+ // -------------------------------------------------------------------------
+ // FIXME: Rename
+ // -------------------------------------------------------------------------
+
+ template <typename CX>
+ struct sub_device_wrapper
+ {
+ using constructor_data_t = typename CX::constructor_data_t;
+ using constructor_param_t = typename CX::constructor_param_t;
+ template <typename... Args>
+ sub_device_wrapper(base_device_t &owner, const pstring &name,
+ Args &&...args)
+ {
+ // m_dev = owner.state().make_pool_object<CX>(owner, name,
+ // std::forward<Args>(args)...);
+ m_dev = owner.state().make_pool_object<CX>(
+ constructor_data_t{owner.state(), owner.name() + "." + name},
+ std::forward<Args>(args)...);
+ owner.state().register_device(m_dev->name(),
+ device_arena::owned_ptr<core_device_t>(m_dev.get(), false));
+ }
+ template <typename... Args>
+ sub_device_wrapper(device_t &owner, const pstring &name, Args &&...args)
+ {
+ // m_dev = owner.state().make_pool_object<CX>(owner, name,
+ // std::forward<Args>(args)...);
+ m_dev = owner.state().make_pool_object<CX>(
+ constructor_data_t{owner.state(), owner.name() + "." + name},
+ std::forward<Args>(args)...);
+ owner.state().register_device(m_dev->name(),
+ device_arena::owned_ptr<core_device_t>(m_dev.get(), false));
+ }
+ CX & operator()() { return *m_dev; }
+ const CX &operator()() const { return *m_dev; }
+
+ private:
+ device_arena::unique_ptr<CX> m_dev;
+ };
+
+} // namespace netlist
#endif // NL_DEVICE_H_