Beispiel #1
0
            void process_net(netlist_state_t nlstate, analog_net_t n)
            {
                // ignore empty nets. FIXME: print a warning message
                nlstate.log().verbose.op("Net {0}", n.name());
                if (!nlstate.core_terms(n).empty())
                {
                    // add the net
                    groupspre.back().push_back(n);
                    // process all terminals connected to this net
                    foreach (var term in nlstate.core_terms(n))
                    {
                        nlstate.log().verbose.op("Term {0} {1}", term.name(), (int)term.type());
                        // only process analog terminals
                        if (term.is_type(detail.terminal_type.TERMINAL))
                        {
                            var pt = (terminal_t)term;  //auto &pt = dynamic_cast<terminal_t &>(*term);
                            // check the connected terminal
                            var connected_terminals = nlstate.setup().get_connected_terminals(pt);
                            foreach (var ct in connected_terminals)  //for (auto ct = connected_terminals->begin(); *ct != nullptr; ct++)
                            {
                                if (ct == default)
                                {
                                    continue;
                                }

                                analog_net_t connected_net = ct.net();
                                nlstate.log().verbose.op("  Connected net {0}", connected_net.name());
                                if (!check_if_processed_and_join(connected_net))
                                {
                                    process_net(nlstate, connected_net);
                                }
                            }
                        }
                    }
                }
            }
Beispiel #2
0
            /* return number of floating point operations for solve */
            //std::size_t ops() { return m_ops; }


            protected void setup_base(analog_net_t_list_t nets)
            {
                log().debug.op("New solver setup\n");

                m_nets.clear();
                m_terms.clear();

                foreach (var net in nets)
                {
                    m_nets.push_back(net);
                    m_terms.push_back(new terms_for_net_t());
                    m_rails_temp.push_back(new terms_for_net_t());
                }

                for (UInt32 k = 0; k < nets.size(); k++)
                {
                    analog_net_t net = nets[k];

                    log().debug.op("setting up net\n");

                    net.set_solver(this);

                    foreach (var p in net.core_terms)
                    {
                        log().debug.op("{0} {1} {2}\n", p.name(), net.name(), net.isRailNet());

                        switch (p.type())
                        {
                        case detail.terminal_type.TERMINAL:
                            if (p.device().is_timestep())
                            {
                                if (!m_step_devices.Contains(p.device()))      //(!plib::container::contains(m_step_devices, &p->device()))
                                {
                                    m_step_devices.push_back(p.device());
                                }
                            }

                            if (p.device().is_dynamic())
                            {
                                if (!m_dynamic_devices.Contains(p.device()))      //if (!plib::container::contains(m_dynamic_devices, &p->device()))
                                {
                                    m_dynamic_devices.push_back(p.device());
                                }
                            }

                            {
                                terminal_t pterm = (terminal_t)p;
                                add_term(k, pterm);
                            }

                            log().debug.op("Added terminal {0}\n", p.name());
                            break;

                        case detail.terminal_type.INPUT:
                        {
                            proxied_analog_output_t net_proxy_output = null;
                            foreach (var input in m_inps)
                            {
                                if (input.proxied_net == p.net())
                                {
                                    net_proxy_output = input;
                                    break;
                                }
                            }

                            if (net_proxy_output == null)
                            {
                                string nname = this.name() + "." + new plib.pfmt("m{0}").op(m_inps.size());
                                var    net_proxy_output_u = new proxied_analog_output_t(this, nname);
                                net_proxy_output = net_proxy_output_u;
                                m_inps.push_back(net_proxy_output_u);
                                nl_base_global.nl_assert(p.net().is_analog());
                                net_proxy_output.proxied_net = (analog_net_t)p.net();
                            }

                            net_proxy_output.net().add_terminal(p);

                            // FIXME: repeated calling - kind of brute force
                            net_proxy_output.net().rebuild_list();

                            log().debug.op("Added input\n");
                        }
                        break;

                        case detail.terminal_type.OUTPUT:
                            log().fatal.op(nl_errstr_global.MF_1_UNHANDLED_ELEMENT_1_FOUND, p.name());
                            break;
                        }
                    }

                    log().debug.op("added net with {0} populated connections\n", net.core_terms.size());
                }

                /* now setup the matrix */
                setup_matrix();
            }