summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/solver/nld_solver.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/solver/nld_solver.h')
-rw-r--r--src/lib/netlist/solver/nld_solver.h141
1 files changed, 7 insertions, 134 deletions
diff --git a/src/lib/netlist/solver/nld_solver.h b/src/lib/netlist/solver/nld_solver.h
index 06a98d063c6..6d08e0bbb73 100644
--- a/src/lib/netlist/solver/nld_solver.h
+++ b/src/lib/netlist/solver/nld_solver.h
@@ -48,134 +48,7 @@ struct solver_parameters_t
};
-class terms_t
-{
- P_PREVENT_COPYING(terms_t)
-
- public:
- ATTR_COLD terms_t() : m_railstart(0)
- {}
-
- ATTR_COLD void clear()
- {
- m_term.clear();
- m_net_other.clear();
- m_gt.clear();
- m_go.clear();
- m_Idr.clear();
- m_other_curanalog.clear();
- }
-
- ATTR_COLD void add(terminal_t *term, int net_other, bool sorted);
-
- ATTR_HOT inline unsigned count() { return m_term.size(); }
-
- ATTR_HOT inline terminal_t **terms() { return m_term.data(); }
- ATTR_HOT inline int *net_other() { return m_net_other.data(); }
- ATTR_HOT inline nl_double *gt() { return m_gt.data(); }
- ATTR_HOT inline nl_double *go() { return m_go.data(); }
- ATTR_HOT inline nl_double *Idr() { return m_Idr.data(); }
- ATTR_HOT inline nl_double **other_curanalog() { return m_other_curanalog.data(); }
-
- ATTR_COLD void set_pointers();
-
- unsigned m_railstart;
-
- pvector_t<unsigned> m_nz; /* all non zero for multiplication */
- pvector_t<unsigned> m_nzrd; /* non zero right of the diagonal for elimination */
- pvector_t<unsigned> m_nzbd; /* non zero below of the diagonal for elimination */
-private:
- pvector_t<terminal_t *> m_term;
- pvector_t<int> m_net_other;
- pvector_t<nl_double> m_go;
- pvector_t<nl_double> m_gt;
- pvector_t<nl_double> m_Idr;
- pvector_t<nl_double *> m_other_curanalog;
-};
-
-class matrix_solver_t : public device_t
-{
-public:
- typedef pvector_t<matrix_solver_t *> list_t;
- typedef core_device_t::list_t dev_list_t;
-
- enum eSolverType
- {
- GAUSSIAN_ELIMINATION,
- GAUSS_SEIDEL
- };
-
- ATTR_COLD matrix_solver_t(const eSolverType type, const solver_parameters_t *params);
- virtual ~matrix_solver_t();
-
- virtual void vsetup(analog_net_t::list_t &nets) = 0;
-
- template<class C>
- void solve_base(C *p);
-
- ATTR_HOT nl_double solve();
-
- ATTR_HOT inline bool is_dynamic() { return m_dynamic_devices.size() > 0; }
- ATTR_HOT inline bool is_timestep() { return m_step_devices.size() > 0; }
-
- ATTR_HOT void update_forced();
- ATTR_HOT inline void update_after(const netlist_time after)
- {
- m_Q_sync.net().reschedule_in_queue(after);
- }
-
- /* netdevice functions */
- ATTR_HOT virtual void update() override;
- virtual void start() override;
- virtual void reset() override;
-
- ATTR_COLD int get_net_idx(net_t *net);
-
- inline eSolverType type() const { return m_type; }
- plog_base<NL_DEBUG> &log() { return netlist().log(); }
-
- virtual void log_stats();
-
-protected:
-
- ATTR_COLD void setup(analog_net_t::list_t &nets);
- ATTR_HOT void update_dynamic();
-
- // should return next time step
- ATTR_HOT virtual nl_double vsolve() = 0;
-
- virtual void add_term(int net_idx, terminal_t *term) = 0;
-
- pvector_t<analog_net_t *> m_nets;
- pvector_t<analog_output_t *> m_inps;
-
- int m_stat_calculations;
- int m_stat_newton_raphson;
- int m_stat_vsolver_calls;
- int m_iterative_fail;
- int m_iterative_total;
-
- const solver_parameters_t &m_params;
-
- ATTR_HOT inline nl_double current_timestep() { return m_cur_ts; }
-private:
-
- netlist_time m_last_step;
- nl_double m_cur_ts;
- dev_list_t m_step_devices;
- dev_list_t m_dynamic_devices;
-
- logic_input_t m_fb_sync;
- logic_output_t m_Q_sync;
-
- ATTR_HOT void step(const netlist_time delta);
-
- ATTR_HOT void update_inputs();
-
- const eSolverType m_type;
-};
-
-
+class matrix_solver_t;
class NETLIB_NAME(solver) : public device_t
{
@@ -188,13 +61,13 @@ public:
ATTR_COLD void post_start();
ATTR_COLD void stop() override;
- ATTR_HOT inline nl_double gmin() { return m_gmin.Value(); }
+ inline nl_double gmin() { return m_gmin.Value(); }
protected:
- ATTR_HOT void update() override;
- ATTR_HOT void start() override;
- ATTR_HOT void reset() override;
- ATTR_HOT void update_param() override;
+ void update() override;
+ void start() override;
+ void reset() override;
+ void update_param() override;
logic_input_t m_fb_step;
logic_output_t m_Q_step;
@@ -217,7 +90,7 @@ protected:
param_logic_t m_log_stats;
- matrix_solver_t::list_t m_mat_solvers;
+ pvector_t<matrix_solver_t *> m_mat_solvers;
private:
solver_parameters_t m_params;