Index: trunk/doc/tutorial/simulation/index.html =================================================================== --- trunk/doc/tutorial/simulation/index.html (revision 7875) +++ trunk/doc/tutorial/simulation/index.html (revision 7876) @@ -129,5 +129,19 @@ TODO sch-rnd: 2-slot opamp - + + 30_mixed + yes + N/S + TODO + TODO + sch-rnd: ADC/DC bridging from terminal attributes +
sim: mixed analog+digital +

+Legend: +

Index: trunk/doc/tutorial/simulation/raw/30_mixed.html =================================================================== --- trunk/doc/tutorial/simulation/raw/30_mixed.html (nonexistent) +++ trunk/doc/tutorial/simulation/raw/30_mixed.html (revision 7876) @@ -0,0 +1,82 @@ + + +

Model from the library

+ +

Scope

+

+Mixed mode (analog + digital) simulation in time domain. + +

The schematics

+

+The input and the output of the circuit are analog, but there is a +section of digital circuity in between (a xor gate). The simulator +runs the analog sections in the normal fixed time stepping manner +while the digital section is simulated based on events. This makes +large digital circuits simulate much faster at the expense of tracking +digital lines only using low/high/unknown states, not simulating +transitions in details (rising/falling edges). +

+There are DAC and ADC converters inserted on the boundary of the +analog and digital systems, using terminal attributes. +

+

+ +
Click the image to get the sch-rnd sheet
+

+More info on the circuit: www.electronics-tutorials.ws + +

Preparing for simulation

+

+The xor gate is going to use ngspice's internal model called d_xor. The whole +model card is specified within the symbol, using the +spice/model_card +symbol attribute. +

+ADC converters are installed on the input terminals of the xor gate by +setting the terminal attribute spice/bridge/model to bridge_adc_ttl, which +is an sch-rnd stock spice model for TTL levels. Whenever spice/bridge/model +is set on a terminal, target_spice will cut the original network connection +of the terminal to insert a bridge component there. This component is +not visible on the schematics, as it's specified in an attribute, but shows +up in the abstract model for any view using target_spice. +

+In case of ngspice, only one bridge component is placed per model, because +ngspice's bridge components can handle multiple inputs and outputs in an 1:1 +mapping. +

+(The sch-rnd user manual has more +details on bridging) +

+The same bridging is done on the output terminal with model brirdge_dac_ttl. +

+On the input, two pulses V1 and V2 are installed to generate trapezoid +signals with slow rising and falling edges. This is to demonstrate how ADC +goes from low to undefined to high. On the output a resistor is used +to provide a DC path from the terminal to the ground - spice usually +requires a DC path to the ground. + +

Raw spice commands

+

+This example executes a normal transient simulation. Since most signals +are either low or high most of the time, they would overlap on the plot. +To avoid confusion, slight y offsets are introduced using arithmetics, ++0.0n. +

+tran 10ms 6s
+plot v(input1)+0.04 v(input2)+0.08 v(output) xlimit 0 6s
+
+ +

Export and run ngspice

+

+Running ngspice the usual way on the export yields the following graphs: +

+ + +

Using other implementations

+

gnucap

+

+Mixed mode simulation is not supported with gnucap. + +

xyce

+

+TODO Index: trunk/doc/tutorial/simulation/raw/30_mixed.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: trunk/doc/tutorial/simulation/raw/30_mixed.png =================================================================== --- trunk/doc/tutorial/simulation/raw/30_mixed.png (nonexistent) +++ trunk/doc/tutorial/simulation/raw/30_mixed.png (revision 7876) Property changes on: trunk/doc/tutorial/simulation/raw/30_mixed.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: trunk/doc/tutorial/simulation/raw/30_mixed.rs =================================================================== --- trunk/doc/tutorial/simulation/raw/30_mixed.rs (revision 7875) +++ trunk/doc/tutorial/simulation/raw/30_mixed.rs (revision 7876) @@ -58,7 +58,7 @@ } ha:group.13 { uuid=39gOSGd8aSMOm1wdWfIAAAAF; - x=96000; y=124000; + x=44000; y=96000; li:objects { ha:group.1 { uuid=39gOSGd8aSMOm1wdWfIAAAAG; src_uuid=9bwyX4hVlbhQseMSDAAAAAAD; @@ -121,7 +121,7 @@ } ha:group.14 { uuid=mHn79ppCTFm1QBmauQ0AAAAp; src_uuid=iNOQfJpO6hT/HFDFGjoAAABx; - x=56000; y=108000; rot=270.000000; mirx=1; + x=16000; y=80000; rot=270.000000; mirx=1; li:objects { ha:arc.1 { cx=10000; cy=0; r=6000; sang=0.000000; dang=360.000000; stroke=sym-decor; } ha:arc.2 { cx=8000; cy=0; r=2000; sang=0.000000; dang=180.000000; stroke=sym-decor; } @@ -157,7 +157,7 @@ -sym-license-dist=GPLv2+ -sym-license-use=Public Domain -sym-source=sch-rnd default symbol lib - name=X1 + name=V1 li:portmap { {P->spice/pinnum=1} {N->spice/pinnum=2} @@ -169,7 +169,7 @@ } ha:group.15 { uuid=mHn79ppCTFm1QBmauQ0AAAAs; src_uuid=LnNTcUkV1CIzG7F2EXUAAAAZ; - x=16000; y=0; + x=-24000; y=-28000; li:objects { ha:line.1 { x1=40000; y1=88000; x2=40000; y2=80000; stroke=wire; } } @@ -177,15 +177,9 @@ ha:role = { value=wire-net; prio=0; } } } - ha:connection.16 { - li:conn { - /2/15/1 - /2/14/4/1 - } - } ha:group.17 { uuid=mHn79ppCTFm1QBmauQ0AAAAt; src_uuid=iNOQfJpO6hT/HFDFGjoAAABm; - x=56000; y=80000; + x=16000; y=52000; li:objects { ha:group.1 { uuid=mHn79ppCTFm1QBmauQ0AAAAu; src_uuid=iNOQfJpO6hT/HFDFGjoAAABn; @@ -213,15 +207,9 @@ role=symbol } } - ha:connection.18 { - li:conn { - /2/17/1/1 - /2/15/1 - } - } ha:group.19 { uuid=mHn79ppCTFm1QBmauQ0AAAAv; src_uuid=iNOQfJpO6hT/HFDFGjoAAABx; - x=76000; y=108000; rot=270.000000; mirx=1; + x=36000; y=80000; rot=270.000000; mirx=1; li:objects { ha:arc.1 { cx=10000; cy=0; r=6000; sang=0.000000; dang=360.000000; stroke=sym-decor; } ha:arc.2 { cx=8000; cy=0; r=2000; sang=0.000000; dang=180.000000; stroke=sym-decor; } @@ -257,7 +245,7 @@ -sym-license-dist=GPLv2+ -sym-license-use=Public Domain -sym-source=sch-rnd default symbol lib - name=X2 + name=V2 li:portmap { {P->spice/pinnum=1} {N->spice/pinnum=2} @@ -269,7 +257,7 @@ } ha:group.20 { uuid=mHn79ppCTFm1QBmauQ0AAAAy; src_uuid=LnNTcUkV1CIzG7F2EXUAAAAZ; - x=36000; y=0; + x=-4000; y=-28000; li:objects { ha:line.1 { x1=40000; y1=88000; x2=40000; y2=80000; stroke=wire; } } @@ -277,15 +265,9 @@ ha:role = { value=wire-net; prio=0; } } } - ha:connection.21 { - li:conn { - /2/20/1 - /2/19/4/1 - } - } ha:group.22 { uuid=mHn79ppCTFm1QBmauQ0AAAAz; src_uuid=iNOQfJpO6hT/HFDFGjoAAABm; - x=76000; y=80000; + x=36000; y=52000; li:objects { ha:group.1 { uuid=mHn79ppCTFm1QBmauQ0AAAA0; src_uuid=iNOQfJpO6hT/HFDFGjoAAABn; @@ -313,18 +295,13 @@ role=symbol } } - ha:connection.23 { - li:conn { - /2/22/1/1 - /2/20/1 - } - } ha:group.24 { uuid=mHn79ppCTFm1QBmauQ0AAAA1; + x=-40000; y=-28000; li:objects { ha:line.1 { x1=76000; y1=108000; x2=76000; y2=116000; stroke=wire; } - ha:line.2 { x1=76000; y1=116000; x2=96000; y2=116000; stroke=wire; } - ha:text.3 { x1=80000; y1=116000; dyntext=1; stroke=wire; text=%../A.name%; floater=1; } + ha:line.2 { x1=76000; y1=116000; x2=84000; y2=116000; stroke=wire; } + ha:text.3 { x1=76000; y1=116000; dyntext=1; stroke=wire; text=%../A.name%; floater=1; } } ha:attrib { name=input2 @@ -331,24 +308,13 @@ ha:role = { value=wire-net; prio=0; } } } - ha:connection.25 { - li:conn { - /2/24/1 - /2/19/5/1 - } - } - ha:connection.26 { - li:conn { - /2/24/2 - /2/13/2/1 - } - } ha:group.27 { uuid=mHn79ppCTFm1QBmauQ0AAAA2; + x=-40000; y=-28000; li:objects { ha:line.1 { x1=56000; y1=108000; x2=56000; y2=124000; stroke=wire; } - ha:line.2 { x1=56000; y1=124000; x2=96000; y2=124000; stroke=wire; } - ha:text.3 { x1=80000; y1=124000; dyntext=1; stroke=wire; text=%../A.name%; floater=1; } + ha:line.2 { x1=56000; y1=124000; x2=84000; y2=124000; stroke=wire; } + ha:text.3 { x1=76000; y1=124000; dyntext=1; stroke=wire; text=%../A.name%; floater=1; } } ha:attrib { name=input1 @@ -355,23 +321,12 @@ ha:role = { value=wire-net; prio=0; } } } - ha:connection.28 { - li:conn { - /2/27/1 - /2/14/5/1 - } - } - ha:connection.29 { - li:conn { - /2/27/2 - /2/13/1/1 - } - } ha:group.30 { uuid=mHn79ppCTFm1QBmauQ0AAAA3; + x=-52000; y=-28000; li:objects { - ha:line.1 { x1=120000; y1=120000; x2=132000; y2=120000; stroke=wire; } - ha:text.2 { x1=132000; y1=120000; dyntext=1; stroke=wire; text=%../A.name%; floater=1; } + ha:line.1 { x1=120000; y1=120000; x2=124000; y2=120000; stroke=wire; } + ha:text.2 { x1=124000; y1=120000; dyntext=1; stroke=wire; text=%../A.name%; floater=1; } } ha:attrib { name=output @@ -378,15 +333,9 @@ ha:role = { value=wire-net; prio=0; } } } - ha:connection.31 { - li:conn { - /2/30/1 - /2/13/3/1 - } - } ha:group.32 { uuid=Xb4Ih/E1Q5gK2yySOvUAAAAz; src_uuid=TeGEOMuew6iCb2kzckAAAAAD; - x=36000; y=144000; + x=16000; y=116000; li:objects { ha:text.1 { x1=2000; y1=-4000; dyntext=0; stroke=sym-decor; text=raw spice; } ha:text.2 { x1=2000; y1=-8000; dyntext=0; stroke=sym-decor; text=command; } @@ -414,7 +363,7 @@ } ha:group.33 { uuid=GtwUPhB2CW+7+ykXMBQAAAAc; src_uuid=iNOQfJpO6hT/HFDFGjoAAABC; - x=132000; y=120000; rot=270.000000; + x=72000; y=92000; rot=270.000000; li:objects { ha:group.1 { uuid=GtwUPhB2CW+7+ykXMBQAAAAd; src_uuid=iNOQfJpO6hT/HFDFGjoAAABD; @@ -462,15 +411,9 @@ value=100k } } - ha:connection.34 { - li:conn { - /2/33/2/1 - /2/30/1 - } - } ha:group.35 { uuid=GtwUPhB2CW+7+ykXMBQAAAAh; src_uuid=iNOQfJpO6hT/HFDFGjoAAABm; - x=132000; y=80000; + x=72000; y=52000; li:objects { ha:group.1 { uuid=GtwUPhB2CW+7+ykXMBQAAAAi; src_uuid=iNOQfJpO6hT/HFDFGjoAAABn; @@ -500,6 +443,7 @@ } ha:group.36 { uuid=GtwUPhB2CW+7+ykXMBQAAAAj; + x=-60000; y=-28000; li:objects { ha:line.1 { x1=132000; y1=100000; x2=132000; y2=80000; stroke=wire; } } @@ -507,13 +451,73 @@ ha:role = { value=wire-net; prio=0; } } } - ha:connection.37 { + ha:connection.42 { li:conn { + /2/15/1 + /2/14/4/1 + } + } + ha:connection.43 { + li:conn { + /2/17/1/1 + /2/15/1 + } + } + ha:connection.44 { + li:conn { + /2/20/1 + /2/19/4/1 + } + } + ha:connection.45 { + li:conn { + /2/22/1/1 + /2/20/1 + } + } + ha:connection.46 { + li:conn { + /2/24/1 + /2/19/5/1 + } + } + ha:connection.48 { + li:conn { + /2/27/1 + /2/14/5/1 + } + } + ha:connection.54 { + li:conn { + /2/13/1/1 + /2/27/2 + } + } + ha:connection.55 { + li:conn { + /2/13/2/1 + /2/24/2 + } + } + ha:connection.60 { + li:conn { + /2/30/1 + /2/13/3/1 + } + } + ha:connection.61 { + li:conn { + /2/33/2/1 + /2/30/1 + } + } + ha:connection.62 { + li:conn { /2/36/1 /2/33/1/1 } } - ha:connection.38 { + ha:connection.63 { li:conn { /2/36/1 /2/35/1/1 @@ -521,8 +525,6 @@ } } ha:attrib { - drawing_min_height=200000 - drawing_min_width=287000 maintainer= page= print_page=A/4 Index: trunk/doc/tutorial/simulation/raw/30_mixed.svg =================================================================== --- trunk/doc/tutorial/simulation/raw/30_mixed.svg (nonexistent) +++ trunk/doc/tutorial/simulation/raw/30_mixed.svg (revision 7876) @@ -0,0 +1,665 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +