Previous 199869 Revisions Next

r26840 Tuesday 31st December, 2013 at 15:35:08 UTC by Couriersud
Enhanced the netlist parser and cleaned pong.c. Also added a folder nl_examples which contains standalone netlist examples. [couriersud]

The examples have a ".c" suffix. In eclipse, I get automatic syntax parsing and error notifications. The parser treats "#" preprocessor defines/includes just as comments.

All of these examples can be run through nltool:

./nltool -f nl_examples/opamp.c -t 1 -l OUT

runs the opamp example for 1 second of emulation time and logs the terminal named "OUT" to "netlist_log_OUT.log".

I'll post a simple script to the list to visualize those logs using gnuplot.
[nl_examples]7400_astable.c* ne555_astable.c* opamp.c*
[src/emu/netlist]nl_parser.c nl_parser.h nl_setup.c nl_setup.h
[src/mame/drivers]pong.c
[src/tools]nltool.c

trunk/src/emu/netlist/nl_parser.c
r26839r26840
1414// A netlist parser
1515// ----------------------------------------------------------------------------------------
1616
17ATTR_COLD void netlist_parser::error(const char *format, ...)
18{
19    va_list ap;
20    va_start(ap, format);
21
22    pstring errmsg1 =pstring(format).vprintf(ap);
23    va_end(ap);
24
25    char buf[300];
26    int bufp = 0;
27    const char *p = m_line_ptr;
28    while (*p && *p != 10)
29        buf[bufp++] = *p++;
30    buf[bufp] = 0;
31
32    m_setup.netlist().xfatalerror("line %d: error: %s\n\t\t%s\n", m_line, errmsg1.cstr(), buf);
33
34    //throw error;
35}
36
37
1738void netlist_parser::parse(const char *buf)
1839{
1940   m_px = buf;
41   m_line_ptr = buf;
42   m_line = 1;
2043
2144   while (!eof())
2245   {
r26839r26840
4164         netdev_device(n, "model", true);
4265      else if ((n == "NETDEV_TTL_CONST") || (n == "NETDEV_ANALOG_CONST"))
4366         netdev_const(n);
67      else if (n == "NETLIST_START")
68          netdev_netlist_start();
69        else if (n == "NETLIST_END")
70            netdev_netlist_end();
4471      else
4572         netdev_device(n);
4673   }
4774}
4875
76void netlist_parser::netdev_netlist_start()
77{
78    // don't do much
79    skipws();
80    /*pstring dummyname = */ getname(')');
81    //check_char(')');
82}
83
84void netlist_parser::netdev_netlist_end()
85{
86    // don't do much
87    check_char(')');
88}
89
4990void netlist_parser::net_alias()
5091{
5192   pstring alias;
r26839r26840
196237      case 10:
197238      case 13:
198239         break;
240      case '#':
241          skipeol(); // treat preprocessor defines as comments
242          break;
199243      case '/':
200244         c = getc();
201245         if (c == '/')
r26839r26840
205249         else if (c == '*')
206250         {
207251            int f=0;
208            while ((c = getc()) != 0 )
252            while (!eof() )
209253            {
254                c = getc();
210255               if (f == 0 && c == '*')
211256                  f=1;
212257               else if (f == 1 && c== '/' )
r26839r26840
225270
226271pstring netlist_parser::getname(char sep)
227272{
228   char buf[300];
229   char *p1 = buf;
230   char c;
231
232   while ((c=getc()) != sep)
233      *p1++ = c;
234   *p1 = 0;
235   return pstring(buf);
273   pstring ret = getname2(sep, 0);
274   getc(); // undo the undo ...
275   return ret;
236276}
237277
238278pstring netlist_parser::getname2(char sep1, char sep2)
239279{
240   char buf[300];
241   char *p1 = buf;
242   char c=getc();
280    static const char *allowed = "0123456789_.ABCDEFGHIJKLMNOPQRSTUVWXYZ";
281    return getname2_ext(sep1, sep2, allowed);
282}
243283
244   while ((c != sep1) && (c != sep2))
245   {
246      *p1++ = c;
247      c = getc();
248   }
249   *p1 = 0;
250   ungetc();
251   return pstring(buf);
284pstring netlist_parser::getname2_ext(char sep1, char sep2, const char *allowed)
285{
286    char buf[300];
287    char *p1 = buf;
288    char c=getc();
289
290    while ((c != sep1) && (c != sep2))
291    {
292        char cU = toupper(c);
293        if (strchr(allowed, cU) != NULL)
294            *p1++ = c;
295        else
296        {
297            *p1 = 0;
298            error("illegal character <%c> in name ...\n", c);
299        }
300        c = getc();
301    }
302    *p1 = 0;
303    ungetc();
304    return pstring(buf);
252305}
253
254306void netlist_parser::check_char(char ctocheck)
255307{
256308   skipws();
r26839r26840
259311   {
260312      return;
261313   }
262   m_setup.netlist().xfatalerror("Parser: expected '%c' found '%c'\n", ctocheck, c);
314   error("expected '%c' found '%c'\n", ctocheck, c);
263315}
264316
265317double netlist_parser::eval_param()
266318{
267319   static const char *macs[6] = {"", "RES_K(", "RES_M(", "CAP_U(", "CAP_N(", "CAP_P("};
320   static const char *allowed = "RESKMUNPAC_0123456789E+-.";
268321   static double facs[6] = {1, 1e3, 1e6, 1e-6, 1e-9, 1e-12};
269322   int i;
270323   int f=0;
271324   bool e;
272325   double ret;
273326
274   pstring s = getname2(')',',');
327   pstring s = getname2_ext(')',',', allowed);
275328
276329   for (i=1; i<6;i++)
277330      if (strncmp(s.cstr(), macs[i], strlen(macs[i])) == 0)
278331         f = i;
279332   ret = s.substr(strlen(macs[f])).as_double(&e);
280333   if ((f>0) && e)
281      m_setup.netlist().xfatalerror("Parser: Error with parameter ...\n");
334      error("Error with parameter ...\n");
282335   if (f>0)
283336      check_char(')');
284337   return ret * facs[f];
r26839r26840
286339
287340unsigned char netlist_parser::getc()
288341{
342    if (*m_px == 10)
343    {
344        m_line++;
345        m_line_ptr = m_px + 1;
346    }
289347   if (*m_px)
290348      return *(m_px++);
291349   else
trunk/src/emu/netlist/nl_setup.c
r26839r26840
1616static NETLIST_START(base)
1717   NETDEV_TTL_CONST(ttlhigh, 1)
1818   NETDEV_TTL_CONST(ttllow, 0)
19    NETDEV_ANALOG_CONST(GND, 0)
1920
2021   NET_MODEL(".model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)")
2122   NET_MODEL(".model 1N4148 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)")
2223   NET_MODEL(".MODEL BC237B NPN(IS=1.8E-14 ISE=5.0E-14 ISC=1.72E-13 XTI=3 BF=400 BR=35.5 IKF=0.14 IKR=0.03 XTB=1.5 VAF=80 VAR=12.5 VJE=0.58 VJC=0.54 RE=0.6 RC=0.25 RB=0.56 CJE=13E-12 CJC=4E-12 XCJC=0.75 FC=0.5 NF=0.9955 NR=1.005 NE=1.46 NC=1.27 MJE=0.33 MJC=0.33 TF=0.64E-9 TR=50.72E-9 EG=1.11 KF=0 AF=1 VCEO=45V ICRATING=100M MFG=ZETEX)")
2324
24NETLIST_END
25NETLIST_END()
2526
2627
2728// ----------------------------------------------------------------------------------------
trunk/src/emu/netlist/nl_parser.h
r26839r26840
1515   NETLIST_PREVENT_COPYING(netlist_parser)
1616public:
1717   netlist_parser(netlist_setup_t &setup)
18   : m_setup(setup) {}
18   : m_line(1), m_line_ptr(NULL), m_px(NULL), m_setup(setup) {}
1919
2020   void parse(const char *buf);
2121   void net_alias();
r26839r26840
2424   void netdev_const(const pstring &dev_name);
2525   void netdev_device(const pstring &dev_type);
2626   void netdev_device(const pstring &dev_type, const pstring &default_param, bool isString = false);
27    void netdev_netlist_start();
28    void netdev_netlist_end();
2729
30    void error(const char *format, ...);
2831private:
2932
3033   void skipeol();
3134   void skipws();
3235   pstring getname(char sep);
3336   pstring getname2(char sep1, char sep2);
37    pstring getname2_ext(char sep1, char sep2, const char *allowed);
3438   void check_char(char ctocheck);
3539   double eval_param();
3640
r26839r26840
3842   void ungetc();
3943   bool eof() { return *m_px == 0; }
4044
45   int m_line;
46   const char * m_line_ptr;
4147   const char * m_px;
4248   netlist_setup_t &m_setup;
4349};
trunk/src/emu/netlist/nl_setup.h
r26839r26840
4444#define NETDEV_PARAM(_name, _val)                                                   \
4545      netlist.register_param(# _name, _val);
4646
47#define NETDEV_PARAMI(_name, _param, _val)                                          \
47#define NETDEV_PARAMI(_name, _param, _val)                                          \
4848      netlist.register_param(# _name "." # _param, _val);
4949
5050#define NETLIST_NAME(_name) netlist ## _ ## _name
5151
52#define NETLIST_START(_name) \
53ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &netlist) \
52#define NETLIST_START(_name)                                                        \
53ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &netlist)                        \
5454{
55#define NETLIST_END  }
5655
56#define NETLIST_END()  }
57
5758#define NETLIST_INCLUDE(_name)                                                      \
5859      NETLIST_NAME(_name)(netlist);
5960
trunk/src/mame/drivers/pong.c
r26839r26840
8282};
8383
8484static NETLIST_START(pong_schematics)
85    NETDEV_SOLVER(Solver)
86    NETDEV_PARAM(Solver.FREQ, 48000)
87    NETDEV_ANALOG_CONST(V5, 5)
88
8589   NETDEV_TTL_CONST(high, 1)
8690   NETDEV_TTL_CONST(low, 0)
91
8792#if 1
8893#if 0
8994   /* this is the clock circuit in schematics. */
r26839r26840
562567
563568   NET_ALIAS(videomix, RV3.2)
564569
565   NETDEV_SOLVER(Solver)
566   NETDEV_PARAM(Solver.FREQ, 48000)
567   NETDEV_ANALOG_CONST(V5, 5)
568   NETDEV_ANALOG_CONST(V1, 1)
569   NETDEV_ANALOG_CONST(GND, 0)
570NETLIST_END()
570571
571#if 0
572   NETDEV_R(R1, 10)
573   NETDEV_R(R2, 10)
574   NETDEV_R(R3, 10)
575   NET_C(V5,R1.1)
576   NET_C(R1.2, R2.1)
577   NET_C(R2.2, R3.1)
578   NET_C(R3.2, GND)
579#endif
580#if 0
581   NETDEV_R(R4, 1000)
582   NETDEV_C(C1, 1e-6)
583   NET_C(V5,R4.1)
584   NET_C(R4.2, C1.1)
585   NET_C(C1.2, GND)
586   //NETDEV_LOG(log1, C1.1)
587#endif
588
589#define tt(_n) \
590   NETDEV_R(R ## _n, 1000) \
591   NETDEV_D(D ## _n) \
592   NET_C(V5, R ## _n.1) \
593   NET_C(R ## _n.2, D ## _n.A) \
594   NET_C(D ## _n.K, GND)
595
596/*    tt(20)
597    tt(21)
598    tt(22)
599    tt(23)
600    tt(24)
601    tt(25)
602    tt(26)
603    tt(27)
604    tt(28)
605    tt(29)
606*/
607
608#if 0
609   NETDEV_R(R5, 1000)
610   NETDEV_1N914(D1)
611   NET_C(V5, R5.1)
612   NET_C(R5.2, D1.A)
613   NET_C(D1.K, GND)
614   //NETDEV_LOG(log1, D1.A)
615#endif
616
617#if 0
618   // astable NAND Multivibrator
619   NETDEV_R(R1, 1000)
620   NETDEV_C(C1, 1e-6)
621   TTL_7400_NAND(n1,R1.1,R1.1)
622   TTL_7400_NAND(n2,R1.2,R1.2)
623   NET_C(n1.Q, R1.2)
624   NET_C(n2.Q, C1.1)
625   NET_C(C1.2, R1.1)
626   //NETDEV_LOG(log2, C1.2)
627   //NETDEV_LOG(log2, n1.Q)
628   //NETDEV_LOG(log3, n2.Q)
629#endif
630
631#if 0
632   // astable NE555, 1.13 ms period
633   NETDEV_R(RA, 5000)
634   NETDEV_R(RB, 3000)
635   NETDEV_C(C, 0.15e-6)
636   NETDEV_NE555(555)
637
638   NET_C(GND, 555.GND)
639   NET_C(V5, 555.VCC)
640
641   NET_C(RA.1, 555.VCC)
642   NET_C(RA.2, 555.DISCH)
643
644   NET_C(RB.1, 555.DISCH)
645   NET_C(RB.2, 555.TRIG)
646
647   NET_C(RB.2, 555.THRESH)
648
649   NET_C(555.TRIG, C.1)
650   NET_C(C.2, GND)
651   //NETDEV_LOG(log2, C.1)
652   //NETDEV_LOG(log3, 555.OUT)
653#endif
654
655#if 0
656   NETDEV_BC238B(Q)
657   NETDEV_R(RB, 1000)
658   NETDEV_R(RC, 1000)
659
660   NET_C(RC.1, V5)
661   NET_C(RC.2, Q.C)
662   NET_C(RB.1, 128H)
663   NET_C(RB.2, Q.B)
664   NET_C(Q.E, GND)
665   //NETDEV_LOG(logB, Q.B)
666   //NETDEV_LOG(logC, Q.C)
667#endif
668
669#if 0
670   NETDEV_VCVS(VV)
671   NETDEV_R(R1, 1000)
672   NETDEV_R(R2, 10000)
673
674   NET_C(V5, R1.1)
675   NET_C(R1.2, VV.IN)
676   NET_C(R2.1, VV.OP)
677   NET_C(R2.2, VV.IN)
678   NET_C(VV.ON, GND)
679   NET_C(VV.IP, GND)
680   NETDEV_LOG(logX, VV.OP)
681
682#endif
683
684#if 0
685   NETDEV_VCCS(VV)
686   NETDEV_PARAM(VV.G, 100000)  // typical OP-AMP amplification
687   NETDEV_R(R1, 1000)
688   NETDEV_R(R2, 1)
689   NETDEV_R(R3, 10000)
690
691   NET_C(4V, R1.1)
692   NET_C(R1.2, VV.IN)
693   NET_C(R2.1, VV.OP)
694   NET_C(R3.1, VV.IN)
695   NET_C(R3.2, VV.OP)
696   NET_C(R2.2, GND)
697   NET_C(VV.ON, GND)
698   NET_C(VV.IP, GND)
699   //NETDEV_LOG(logX, VV.OP)
700   //NETDEV_LOG(logY, 4V)
701
702#endif
703
704#if 0
705   NETDEV_VCVS(VV)
706   NETDEV_PARAM(VV.G, 100000)  // typical OP-AMP amplification
707   NETDEV_PARAM(VV.RO, 50)  // typical OP-AMP amplification
708   NETDEV_R(R1, 1000)
709   NETDEV_R(R3, 10000) // ==> 10x amplification (inverting)
710
711   NET_C(4V, R1.1)
712   NET_C(R1.2, VV.IN)
713   NET_C(R3.1, VV.IN)
714   NET_C(R3.2, VV.OP)
715   NET_C(VV.ON, GND)
716   NET_C(VV.IP, GND)
717   NETDEV_LOG(logX, VV.OP)
718   NETDEV_LOG(logY, 4V)
719
720#endif
721
722#if 0
723   // Impedance converter with resistor
724   NETDEV_VCVS(VV)
725   NETDEV_PARAM(VV.G, 100000)  // typical OP-AMP amplification
726   NETDEV_PARAM(VV.RO, 50)  // typical OP-AMP amplification
727   NETDEV_R(R3, 10000)
728
729   NET_C(4V, VV.IP)
730   NET_C(R3.1, VV.IN)
731   NET_C(R3.2, VV.OP)
732   NET_C(VV.ON, GND)
733   NETDEV_LOG(logX, VV.OP)
734   NETDEV_LOG(logY, 4V)
735
736#endif
737
738#if 0
739   // Impedance converter without resistor
740   NETDEV_VCVS(VV)
741   NETDEV_PARAM(VV.G, 100000)  // typical OP-AMP amplification
742   NETDEV_PARAM(VV.RO, 50)  // typical OP-AMP amplification
743
744   NET_C(4V, VV.IP)
745   NET_C(VV.IN, VV.OP)
746   NET_C(VV.ON, GND)
747   NETDEV_LOG(logX, VV.OP)
748   NETDEV_LOG(logY, 4V)
749
750#endif
751
752#if 0
753   /* Impedance converter current source opamp model from
754    *
755    * http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel1.htm
756    *
757    * Bandwidth 10Mhz
758    *
759    */
760   NETDEV_VCCS(G1)
761   NETDEV_PARAM(G1.G, 100)  // typical OP-AMP amplification 100 * 1000 = 100000
762   NETDEV_R(RP1, 1000)
763   NETDEV_C(CP1, 1.59e-6)   // <== change to 1.59e-3 for 10Khz bandwidth
764   NETDEV_VCVS(EBUF)
765   NETDEV_PARAM(EBUF.RO, 50)
766   NETDEV_PARAM(EBUF.G, 1)
767
768   NET_C(G1.IP, 4V)
769   NET_C(G1.IN, EBUF.OP)
770   NET_C(EBUF.ON, GND)
771
772   NET_C(G1.ON, GND)
773   NET_C(RP1.2, GND)
774   NET_C(CP1.2, GND)
775   NET_C(EBUF.IN, GND)
776
777   NET_C(RP1.1, G1.OP)
778   NET_C(CP1.1, RP1.1)
779   NET_C(EBUF.IP, RP1.1)
780
781   //NETDEV_LOG(logX, EBUF.OP)
782   //NETDEV_LOG(logY, 4V)
783
784#endif
785
786NETLIST_END
787
788572class pong_state : public driver_device
789573{
790574public:
r26839r26840
838622
839623   NETDEV_ANALOG_CALLBACK(sound_cb, sound, pong_state, sound_cb, "")
840624   NETDEV_ANALOG_CALLBACK(video_cb, videomix, fixedfreq_device, update_vid, "fixfreq")
841NETLIST_END
625NETLIST_END()
842626
843627static NETLIST_START(pong_fast)
844628
r26839r26840
847631   NETDEV_ANALOG_CALLBACK(sound_cb, sound, pong_state, sound_cb, "")
848632    NETDEV_ANALOG_CALLBACK(video_cb, videomix, fixedfreq_device, update_vid, "fixfreq")
849633
850NETLIST_END
634NETLIST_END()
851635
852636void pong_state::machine_start()
853637{
trunk/src/tools/nltool.c
r26839r26840
1616#include "sha1.h"
1717#include "netlist/nl_base.h"
1818#include "netlist/nl_setup.h"
19#include "netlist/nl_util.h"
1920#include "options.h"
2021
2122/***************************************************************************
r26839r26840
5859
5960struct options_entry oplist[] =
6061{
61   { "time_to_run;ttr", "1.0", OPTION_FLOAT,   "time to run the emulation (seconds)" },
62   { "time_to_run;t",   "1.0", OPTION_FLOAT,   "time to run the emulation (seconds)" },
63    { "logs;l",          "",    OPTION_STRING,  "colon separated list of terminals to log" },
6264   { "f",               "-",   OPTION_STRING,  "file to process (default is stdin)" },
6365   { "help;h",          "0",   OPTION_BOOLEAN, "display help" },
6466   { NULL }
r26839r26840
9193      long fsize = ftell(f);
9294      fseek(f, 0, SEEK_SET);
9395
94      char *buf = (char *) malloc(fsize);
96      char *buf = (char *) malloc(fsize + 1);
9597      fread(buf, fsize, 1, f);
9698      buf[fsize] = 0;
9799      fclose(f);
r26839r26840
104106public:
105107
106108   netlist_tool_t()
107   : netlist_base_t(), m_setup(NULL)
109   : netlist_base_t(), m_logs(""), m_setup(NULL)
108110   {
109111   }
110112
r26839r26840
120122      //m_setup_func(*m_setup);
121123
122124      m_setup->parse(buffer);
125      log_setup();
123126
124127      // start devices
125128      m_setup->start_devices();
r26839r26840
128131      this->reset();
129132   }
130133
134    void log_setup()
135    {
136        NL_VERBOSE_OUT(("Creating dynamic logs ...\n"));
137        nl_util::pstring_list ll = nl_util::split(m_logs, ":");
138        for (int i=0; i < ll.count(); i++)
139        {
140            netlist_device_t *nc = m_setup->factory().new_device_by_classname("nld_log", *m_setup);
141            pstring name = "log_" + ll[i];
142            m_setup->register_dev(nc, name);
143            m_setup->register_link(name + ".I", ll[i]);
144        }
145    }
146
147    pstring m_logs;
131148protected:
132149
133150   void vfatalerror(const char *format, va_list ap) const
r26839r26840
140157   netlist_setup_t *m_setup;
141158};
142159
160
143161void usage(core_options &opts)
144162{
145163   astring buffer;
r26839r26840
178196      return 1;
179197   }
180198
199   nt.m_logs = opts.value("l");
181200   nt.read_netlist(filetobuf(opts.value("f")));
182   double ttr = opts.float_value("ttr");
201   double ttr = opts.float_value("t");
183202
184203   printf("startup time ==> %5.3f\n", (double) (osd_ticks() - t) / (double) osd_ticks_per_second() );
185204   printf("runnning ...\n");
trunk/nl_examples/7400_astable.c
r0r26840
1/*
2 * 7400_astable.c
3 *
4 */
5
6#include "netlist/devices/net_lib.h"
7
8NETLIST_START(7400_astable)
9
10    /*
11     * Astable multivibrator using two 7400 gates (or inverters)
12     *
13     */
14
15    /* Standard stuff */
16
17    NETDEV_SOLVER(Solver)
18    NETDEV_PARAM(Solver.FREQ, 48000)
19
20    // astable NAND Multivibrator
21    NETDEV_R(R1, 1000)
22    NETDEV_C(C1, 1e-6)
23    TTL_7400_NAND(n1,R1.1,R1.1)
24    TTL_7400_NAND(n2,R1.2,R1.2)
25    NET_C(n1.Q, R1.2)
26    NET_C(n2.Q, C1.1)
27    NET_C(C1.2, R1.1)
28
29    NETDEV_LOG(log2, C1.2)
30    //NETDEV_LOG(log2, n1.Q)
31    NETDEV_LOG(log3, n2.Q)
32
33NETLIST_END()
Property changes on: trunk/nl_examples/7400_astable.c
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/nl_examples/opamp.c
r0r26840
1/*
2 * opamp.c
3 *
4 */
5
6
7#include "netlist/devices/net_lib.h"
8
9NETLIST_START(opamp)
10
11    /* Opamp model from
12     *
13     * http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel1.htm
14     *
15     * Bandwidth 10Mhz
16     *
17     * This one is connected as a impedance changer
18     */
19
20    /* Standard stuff */
21
22    NETDEV_CLOCK(clk)
23    NETDEV_PARAM(clk.FREQ, 1000) // 1000 Hz
24    NETDEV_SOLVER(Solver)
25    NETDEV_PARAM(Solver.FREQ, 48000)
26
27    /* Wiring up the opamp */
28
29    NET_C(PLUS, clk)
30    NET_C(MINUS, OUT)
31
32    /* The opamp model */
33
34    NETDEV_VCCS(G1)
35    NETDEV_PARAM(G1.G, 100)  // typical OP-AMP amplification 100 * 1000 = 100000
36    NETDEV_R(RP1, 1000)
37    NETDEV_C(CP1, 1.59e-6)   // <== change to 1.59e-3 for 10Khz bandwidth
38    NETDEV_VCVS(EBUF)
39    NETDEV_PARAM(EBUF.RO, 50)
40    NETDEV_PARAM(EBUF.G, 1)
41
42    NET_ALIAS(PLUS, G1.IP) // Positive input
43    NET_ALIAS(MINUS, G1.IN) // Negative input
44    NET_ALIAS(OUT, EBUF.OP) // Opamp output ...
45
46    NET_C(EBUF.ON, GND)
47
48    NET_C(G1.ON, GND)
49    NET_C(RP1.2, GND)
50    NET_C(CP1.2, GND)
51    NET_C(EBUF.IN, GND)
52
53    NET_C(RP1.1, G1.OP)
54    NET_C(CP1.1, RP1.1)
55    NET_C(EBUF.IP, RP1.1)
56
57    //NETDEV_LOG(logX, OUT)
58    //NETDEV_LOG(logY, 4V)
59NETLIST_END()
Property changes on: trunk/nl_examples/opamp.c
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/nl_examples/ne555_astable.c
r0r26840
1/*
2 * ne555_astable.c
3 *
4 */
5
6#include "netlist/devices/net_lib.h"
7
8NETLIST_START(ne555_astable)
9
10    /*
11     * Astable ne555
12     *
13     */
14
15    /* Standard stuff */
16
17    NETDEV_SOLVER(Solver)
18    NETDEV_PARAM(Solver.FREQ, 48000)
19
20    NETDEV_ANALOG_CONST(V5, 5)  // 5V
21
22    /* Wiring up the ne555 */
23
24    // astable NE555, 1.13 ms period
25
26    NETDEV_R(RA, 5000)
27    NETDEV_R(RB, 3000)
28    NETDEV_C(C, 0.15e-6)
29    NETDEV_NE555(555)
30
31    NET_C(GND, 555.GND)
32    NET_C(V5, 555.VCC)
33    NET_C(V5, 555.RESET)
34
35    NET_C(RA.1, 555.VCC)
36    NET_C(RA.2, 555.DISCH)
37
38    NET_C(RB.1, 555.DISCH)
39    NET_C(RB.2, 555.TRIG)
40
41    NET_C(RB.2, 555.THRESH)
42
43    NET_C(555.TRIG, C.1)
44    NET_C(C.2, GND)
45
46    NETDEV_LOG(log2, C.1)
47    NETDEV_LOG(log3, 555.OUT)
48
49NETLIST_END()
Property changes on: trunk/nl_examples/ne555_astable.c
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Previous 199869 Revisions Next


© 1997-2024 The MAME Team