File: 30_mixed.html

package info (click to toggle)
sch-rnd 1.0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,696 kB
  • sloc: ansic: 119,120; awk: 1,502; makefile: 1,421; sh: 1,404; yacc: 905; lex: 172; xml: 160
file content (84 lines) | stat: -rw-r--r-- 3,298 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<html>
<body>
<h1> 30_mixed: analog+digital mixed sim </h1>

<h2> Scope </h2>
<p>
Mixed mode (analog + digital) simulation in the time domain.

<h2> The schematics </h2>
<p>
The input and the output of the circuit are analog, but there is a
section of digital circuitry inbetween (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, rather than simulating
transitions in detail (rising/falling edges).
<p>
There are DAC and ADC converters inserted on the boundary of the
analog and digital systems, using terminal attributes.
<p>
<center>
<a href="30_mixed.rs"><img src="30_mixed.svg" width=400px></a>
<br>Click the image to get the sch-rnd sheet</center>
<p>
More info on the circuit: <a href="https://www.electronics-tutorials.ws/filter/band-stop-filter.html"> www.electronics-tutorials.ws </a>

<h2> Preparing for simulation </h2>
<p>
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 
<a href="../../../user/07_io/export_spice/model.html">spice/model_card</a>
symbol attribute. The spice instance name must start with an 'A' for d_xor,
while for other workflows the name U1 is more practical. This is dealt with
by using the spice/prefix=A attribute.
<p>
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 a 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.
<p>
In the case of ngspice, only one bridge component is placed per model, because
ngspice's bridge components can handle multiple inputs and outputs in a 1:1
mapping.
<p>
(The sch-rnd user manual has more
<a href="../../../user/07_io/export_spice/auto_bridge.html">details on bridging</a>)
<p>
The same bridging is done on the output terminal with model bridge_dac_ttl.
<p>
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.

<h3> Raw spice commands </h3>
<p>
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 an arithmetic
expression, +0.0n.
<pre>
tran 10ms 6s
plot v(input1)+0.04 v(input2)+0.08 v(output) xlimit 0 6s
</pre>

<h2> Export and run ngspice </h2>
<p>
Running ngspice the usual way on the export yields the following graphs:
<p>
<img src="30_mixed.png">

<h2> Using other implementations </h2>
<h3> gnucap </h3>
<p>
Mixed mode simulation is not supported with gnucap.

<h3> xyce </h3>
<p>
TODO