コード例 #1
0
 bool already_processed(analog_net_t n)
 {
     if (n.isRailNet())
     {
         return(true);
     }
     foreach (var grp in groups)
     {
         if (grp.Contains(n))  //plib::container::contains(grp, n))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #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();
            }