23.01.2015 Views

Download - Wolfram Research

Download - Wolfram Research

Download - Wolfram Research

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.3 Circuits and Subcircuits 69<br />

{VC, {"B", "E", "C", "E"}, beta / RB}<br />

So why should we use translation rules at all The answer is that parameter value translations can<br />

also be specified by means of delayed rules, i.e. the RuleDelayed lhs :> rhs instead of the Rule<br />

lhs −> rhs. Since delayed rules are left unevaluated until the very moment they are needed, their<br />

right-hand sides also contain calls to external functions which perform calculations depending on<br />

the model parameter values. For instance, let’s define a function which, given values for beta and<br />

RB, calculates the transconductance of a transistor by solving the formula gm RB ⩵ beta numerically<br />

for gm, using gm ⩵ as initial guess.<br />

In[30]:= Transconductance[b_Real, r_Real] :=<br />

Module[ {g},<br />

Print["Computing gm for beta = ", b, " and RB = ", r];<br />

g /. FindRoot[g * r == b, {g, 1.0}]<br />

]<br />

By means of a delayed translation rule for gm we can instruct Mathematica not to execute the function<br />

call at the time the transistor model is defined but to wait until the rule is used to compute gm for a<br />

particular subcircuit instance.<br />

In[31]:= Circuit[<br />

Model[<br />

Name −> NPNTransistor,<br />

Selector −> ACgm,<br />

Scope −> Global,<br />

Ports −> {"B", "C", "E"},<br />

Parameters −> {RB, beta},<br />

Translation −> {gm :> Transconductance[beta, RB]},<br />

Definition −><br />

Netlist[<br />

{RB, {"B", "E"}, RB},<br />

{VC, {"B", "E", "C", "E"}, gm}<br />

]<br />

]<br />

] // ExpandSubcircuits;<br />

If we had used an immediate rule above, gm −> Transconductance[beta, RB], Mathematica would<br />

have already called Transconductance with the symbolic arguments beta and RB at the time<br />

of model definition. On the other hand, the delayed rule permits Analog Insydes to replace the<br />

arguments with instance-specific values before making the function call. This is done once per<br />

subcircuit instance as can be seen from the following output:<br />

In[32]:= ExpandSubcircuits[darlNumParams] // DisplayForm<br />

Computing gm for beta = 150. and RB = 400.<br />

Computing gm for beta = 50. and RB = 100.<br />

Out[32]//DisplayForm=<br />

Netlist Flat, 6 Entries:<br />

I1, 0, 1, 1<br />

RB$Q1, 1, 3, 400.<br />

VC$Q1, 1, 3, 2, 3, 0.375<br />

RB$Q2, 3, 0, 100.<br />

VC$Q2, 3, 0, 2, 0, 0.5<br />

Load, 0, 2, Type Resistor, Value RL, Pattern Impedance

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!