Exemplo n.º 1
0
            //#define ENTRYY(n, m, s)    case (n * 100 + m): \
            //    { using xtype = netlist_factory_truthtable_t<n, m>; \
            //        ret = plib::palloc<xtype>(desc.name, desc.classname, desc.def_param, s); } break

            //#define ENTRY(n, s) ENTRYY(n, 1, s); ENTRYY(n, 2, s); ENTRYY(n, 3, s); \
            //                    ENTRYY(n, 4, s); ENTRYY(n, 5, s); ENTRYY(n, 6, s); \
            //                    ENTRYY(n, 7, s); ENTRYY(n, 8, s)

            public static void tt_factory_create(setup_t setup, tt_desc desc, string sourcefile)
            {
                netlist_base_factory_truthtable_t ret;

                //switch (desc.ni * 100 + desc.no)
                //{
                //    ENTRY(1, sourcefile);
                //    ENTRY(2, sourcefile);
                //    ENTRY(3, sourcefile);
                //    ENTRY(4, sourcefile);
                //    ENTRY(5, sourcefile);
                //    ENTRY(6, sourcefile);
                //    ENTRY(7, sourcefile);
                //    ENTRY(8, sourcefile);
                //    ENTRY(9, sourcefile);
                //    ENTRY(10, sourcefile);
                //    ENTRY(11, sourcefile);
                //    ENTRY(12, sourcefile);
                //    default:
                //        pstring msg = plib::pfmt("unable to create truthtable<{1},{2}>")(desc.ni)(desc.no);
                //        nl_assert_always(false, msg);
                //}

                // re-write of the above case statement
                if (desc.ni >= 1 && desc.ni <= 12 &&
                    desc.no >= 1 && desc.no <= 8)
                {
                    ret = new netlist_factory_truthtable_t(desc.ni, desc.no, desc.name, desc.classname, desc.def_param, sourcefile);
                }
                else
                {
                    string msg = new plib.pfmt("unable to create truthtable<{0},{1}>").op(desc.ni, desc.no);
                    nl_base_global.nl_assert_always(false, msg);
                    ret = new netlist_factory_truthtable_t(0, 0, null, null, null, null);
                }


                ret.desc = desc.desc;
                if (desc.family != "")
                {
                    ret.family = setup.family_from_model(desc.family);
                }

                setup.factory().register_device(ret);  //std::unique_ptr<netlist_base_factory_truthtable_t>(ret));
            }
Exemplo n.º 2
0
        public void netlist_state_t_after_ctor(string name, plib.plog_delegate logger)
        {
            m_log           = new log_type(logger);
            m_dummy_version = 1;

            m_setup = new setup_t(this);           //m_setup = plib::make_unique<setup_t, host_arena>(*this);
            // create the run interface
            m_netlist = new netlist_t(this, name); //m_netlist = plib::make_unique<netlist_t>(m_pool, *this, name);

            // Make sure save states are invalidated when a new version is deployed

            m_state.save_item(this, m_dummy_version, "V" + version());

            // Initialize factory
            netlist.devices.net_lib_global.initialize_factory(m_setup.parser().factory_());

            // Add default include file
            string content =
                "#define RES_R(res) (res)            \n" +
                "#define RES_K(res) ((res) * 1e3)    \n" +
                "#define RES_M(res) ((res) * 1e6)    \n" +
                "#define CAP_U(cap) ((cap) * 1e-6)   \n" +
                "#define CAP_N(cap) ((cap) * 1e-9)   \n" +
                "#define CAP_P(cap) ((cap) * 1e-12)  \n" +
                "#define IND_U(ind) ((ind) * 1e-6)   \n" +
                "#define IND_N(ind) ((ind) * 1e-9)   \n" +
                "#define IND_P(ind) ((ind) * 1e-12)  \n";

            m_setup.parser().add_include(new plib.psource_str_t("netlist/devices/net_lib.h", content));  //m_setup->parser().add_include<plib::psource_str_t>("netlist/devices/net_lib.h", content);

            // This is for core macro libraries
            m_setup.parser().add_include(new plib.psource_str_t("devices/net_lib.h", content)); //m_setup->parser().add_include<plib::psource_str_t>("devices/net_lib.h", content);

            netlist_base_lib(m_setup.parser());                                                 //NETLIST_NAME(base_lib)(m_setup->parser());

            //throw new emu_unimplemented();
#if false
            m_setup->parser().register_source <source_pattern_t>("src/lib/netlist/macro/nlm_{1}.cpp", true);
            m_setup->parser().register_source <source_pattern_t>("src/lib/netlist/generated/nlm_{1}.cpp", true);
            m_setup->parser().register_source <source_pattern_t>("src/lib/netlist/macro/modules/nlmod_{1}.cpp", true);
            m_setup->parser().include("base_lib");
#endif
        }
Exemplo n.º 3
0
 public library_element_t(setup_t setup, string name, string classname, string def_param, string source)
     : base(name, classname, def_param, source)
 {
 }
Exemplo n.º 4
0
 public list_t(setup_t setup)
 {
     m_setup = setup;
 }
Exemplo n.º 5
0
 /// \brief prior to running free no longer needed resources
 ///
 public void free_setup_resources()
 {
     m_setup = null;
 }
Exemplo n.º 6
0
        /* Does not have pin 3 connected */
        //#define POT2(name, p_R)                                                        \
        //        NET_REGISTER_DEV(POT2, name)                                           \
        //        NETDEV_PARAMI(name, R, p_R)


        //#define CAP(name, p_C)                                                         \
        //        NET_REGISTER_DEV(CAP, name)                                            \
        //        NETDEV_PARAMI(name, C, p_C)
        public static void CAP(setup_t setup, string name, double p_C)
        {
            nl_setup_global.NET_REGISTER_DEV(setup, "CAP", name);
            nl_setup_global.NETDEV_PARAMI(setup, name, "C", p_C);
        }
Exemplo n.º 7
0
 //#define POT(name, p_R)                                                         \
 //        NET_REGISTER_DEV(POT, name)                                            \
 //        NETDEV_PARAMI(name, R, p_R)
 public static void POT(setup_t setup, string name, int p_R)
 {
     nl_setup_global.NET_REGISTER_DEV(setup, "POT", name);
     nl_setup_global.NETDEV_PARAMI(setup, name, "R", p_R);
 }
Exemplo n.º 8
0
 //#define SOLVER(name, freq)                                                  \
 //        NET_REGISTER_DEV(SOLVER, name)                                      \
 //        PARAM(name.FREQ, freq)
 public static void SOLVER(setup_t setup, string name, int freq)
 {
     nl_setup_global.NET_REGISTER_DEV(setup, "SOLVER", name);
     nl_setup_global.PARAM(setup, name + ".FREQ", freq);
 }
Exemplo n.º 9
0
            //#define MAINCLOCK(name, freq)                                                   \
            //        NET_REGISTER_DEV(MAINCLOCK, name)                                       \
            //        PARAM(name.FREQ, freq)

            //#define CLOCK(name, freq)                                                       \
            //        NET_REGISTER_DEV(CLOCK, name)                                           \
            //        PARAM(name.FREQ, freq)

            //#define EXTCLOCK(name, freq, pattern)                                           \
            //        NET_REGISTER_DEV(EXTCLOCK, name)                                        \
            //        PARAM(name.FREQ, freq)                                                  \
            //        PARAM(name.PATTERN, pattern)

            //#define GNDA()                                                                  \
            //        NET_REGISTER_DEV(GNDA, GND)

            //#define DUMMY_INPUT(name)                                                       \
            //        NET_REGISTER_DEV(DUMMY_INPUT, name)
            public static void DUMMY_INPUT(setup_t setup, string name)
            {
                nl_setup_global.NET_REGISTER_DEV(setup, "DUMMY_INPUT", name);
            }
Exemplo n.º 10
0
            //#define LOGIC_INPUT(name, v, family)                                            \
            //        NET_REGISTER_DEV(LOGIC_INPUT, name)                                     \
            //        PARAM(name.IN, v)                                                       \
            //        PARAM(name.FAMILY, family)

            //#define ANALOG_INPUT(name, v)                                                   \
            //        NET_REGISTER_DEV(ANALOG_INPUT, name)                                    \
            //        PARAM(name.IN, v)
            public static void ANALOG_INPUT(setup_t setup, string name, int v)
            {
                nl_setup_global.NET_REGISTER_DEV(setup, "ANALOG_INPUT", name);
                nl_setup_global.PARAM(setup, name + ".IN", v);
            }