blob: be796ab95fd6027f66673fb83aabb17ad675b1b2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// license:GPL-2.0+
// copyright-holders:Couriersud
///
/// \file exec.h
///
#ifndef NL_CORE_EXEC_H_
#define NL_CORE_EXEC_H_
#include "base_objects.h"
#include "state_var.h"
#include "../nltypes.h"
#include "../plib/plists.h"
#include "../plib/pstring.h"
namespace netlist
{
// -----------------------------------------------------------------------------
// netlist_t
// -----------------------------------------------------------------------------
class netlist_t // NOLINT(clang-analyzer-optin.performance.Padding)
{
public:
explicit netlist_t(netlist_state_t &state, const pstring &aname);
PCOPYASSIGNMOVE(netlist_t, delete)
virtual ~netlist_t() noexcept = default;
// run functions
const netlist_time_ext &time() const noexcept { return m_time; }
void process_queue(netlist_time_ext delta) noexcept;
void abort_current_queue_slice() noexcept
{
if (!NL_USE_QUEUE_STATS || !m_use_stats)
m_queue.retime<false>(detail::queue_t::entry_t(m_time, nullptr));
else
m_queue.retime<true>(detail::queue_t::entry_t(m_time, nullptr));
}
const detail::queue_t &queue() const noexcept { return m_queue; }
template<typename... Args>
void qpush(Args&&...args) noexcept
{
#if (!NL_USE_QUEUE_STATS)
m_queue.emplace<false>(std::forward<Args>(args)...); // NOLINT(performance-move-const-arg)
#else
if (!m_use_stats)
m_queue.emplace<false>(std::forward<Args>(args)...); // NOLINT(performance-move-const-arg)
else
m_queue.emplace<true>(std::forward<Args>(args)...); // NOLINT(performance-move-const-arg)
#endif
}
template <class R>
void qremove(const R &elem) noexcept
{
#if (!NL_USE_QUEUE_STATS)
m_queue.remove<false>(elem);
#else
if (!m_use_stats)
m_queue.remove<false>(elem);
else
m_queue.remove<true>(elem);
#endif
}
// Control functions
void stop();
void reset();
// only used by nltool to create static c-code
devices::nld_solver *solver() const noexcept { return m_solver; }
// force late type resolution
template <typename X = devices::nld_solver>
nl_fptype gmin(X *solv = nullptr) const noexcept
{
plib::unused_var(solv);
return static_cast<X *>(m_solver)->gmin();
}
netlist_state_t &nlstate() noexcept { return m_state; }
const netlist_state_t &nlstate() const noexcept { return m_state; }
log_type & log() noexcept { return m_state.log(); }
const log_type &log() const noexcept { return m_state.log(); }
void print_stats() const;
bool use_stats() const { return m_use_stats; }
bool stats_enabled() const noexcept { return m_use_stats; }
void enable_stats(bool val) noexcept { m_use_stats = val; }
private:
template <bool KEEP_STATS>
void process_queue_stats(netlist_time_ext delta) noexcept;
netlist_state_t & m_state;
devices::nld_solver * m_solver;
// mostly rw
//PALIGNAS(16)
netlist_time_ext m_time;
devices::nld_mainclock * m_mainclock;
//PALIGNAS_CACHELINE()
//PALIGNAS(16)
detail::queue_t m_queue;
bool m_use_stats;
// performance
plib::pperftime_t<true> m_stat_mainloop;
plib::pperfcount_t<true> m_perf_out_processed;
};
} // namespace netlist
#endif // NL_CORE_EXEC_H_
|