# HP ADS 1.5 User-defined Models User Manual

Brand: HP, Pages: 216, PDF Size: 1.33 MB

### Page 161 from 216

The Frequency-Domain Defined Device 6-11

Creating Output Harmonics

If you are creating a model with the capability to output a large number of

harmonics, the _harm variable can be used with the FDD to develop a such a model.

The _harm variable, unlike most of the functions described in this chapter, is not

restricted to use in FDDs only.

Using the _harm variable, voltage and current source harmonic values can be

parametrically defined. Anytime the large signal voltage or current is defined with an

expression using _harm, the device will automatically index the value of _harm from

0 to the maximum value needed for the present analysis. The expression is then

re-evaluated for each value of _harm to determine the spectral content at a frequency

equal to _harm*frequency determined by the parameter indices.

The variable _harm is used in the function below, which implements a pulse source:

parameters VPEAK=1 V DUTYCYCLE=30 FREQ=1 GHz HARMONICS=16

ivs:CMP79 1 2 freq=Freq v[1]=A(_harm)

Blackman(n,M) = (0.42 + 0.50*cos(PI*n/M) + 0.08*cos(2*PI*n/M))*step(M-n)

A(k)=2*VPEAK*DUTYCYCLE/100*sinc(k*pi*DUTYCYCLE/100)*(-1)^k \

* Blackman(k,Harmonics+1)*step(_harm)

The variable _harm has no set maximum harmonic limitation. The value of _harm

will automatically be incremented out to the maximum value available for the

present analysis.

This automatic indexing also works in baseband envelope and transient. The variable

is incremented until it either reaches 1000 or until its amplitude has become

insignificant for several consecutive harmonics.

In non-baseband envelope, the maximum harmonic will also be limited if the source's

harmonic falls outside the envelope bandwidth. For example, if the analysis

fundamental is 1MHz with a timestep of 1msec (+/-500Hz envelope bandwidth) and

the source fundamental frequency is 1MHZ + 100Hz, then the 6th harmonic falls

outside the envelope bandwidth and the spectrum is truncated, even if the analysis

order is 31. Also, anytime a spectrum is truncated in harmonic balance, it remains

truncated even if higher order spectral tones may exist, for example, if another

fundamental existed at 10MHz+1kHz, the spectral source would not add energy

there even though it is at the 10th harmonic of the source.

### Page 162 from 216

6-12 The Frequency-Domain Defined Device

Custom Modeling with Frequency-Domain Defined Devices

Note that the frequency value is determined by the frequency defined in the

parameter indices. In the above case, for example, v[1,2] = A(_harm) would have

defined a pulse waveform whose fundamental frequency is the second harmonic of

Freq. The equation v[0,1,2] = A(_harm) will define a waveform whose fundamental

frequency is (1 *_freq1 + 2*_freq2) where the _freqN variables are the fundamental

frequencies defined by the analysis. At the netlist level, multiple different spectrum

can be defined in one source, but each one will add the DC (_harm=0) value.

Limitations

In general, you should avoid using a fundamental frequency of 0 Hz. The _harm

parameter is not supported for the small signal spectral parameters.

There is no simulator variable available to determine what the maximum number of

harmonics is for a particular case. This can make windowing a little difficult, since a

parameter must be used or passed to the model to set the window bandwidth.

Defining an FDD Spectrum

The parametric definition of output spectrum using the _harm index also works with

the FDD. This example defines a VCO:

parameters Kv=1khz FUND=1 Rout=50 ohm PFUND=0 dBm Harmonic=

fdd:CMP2 _NET00005 0 out 0 i[1,0]=0

i[2,f1,f2,f3]=a*Harmonic*exp(j*_harm*b)*step

(_harm)

a = -dbmtoa(PFUND, a_Rout)

a_Rout = max(Rout,0.1)

b = 1000*_sv_d(1,timestep,0)-pi/2

f1 = if (FUND = 1) then 1 else 0 endif

f2 = if (FUND = 2) then 1 else 0 endif

f3 = if (FUND = 3) then 1 else 0 endif

C:CMP3 0 _NET00005 C=1/(2*pi*Kv)

vco_harm:CMP1 vin vout Kv=1khz FUND=1 Rout=50 ohm PFUND=0 dBm

Harmonic=fharm

fharm = sinc(_harm*pi*.25)/sinc(pi*.25)

### Page 163 from 216

The Frequency-Domain Defined Device 6-13

In this example, the user has entered the equation for the spectrum of a 25% duty

cycle square wave using the _harm index, which can generate as many harmonics as

can be supported by the present analysis. The fundamental power is still separately

defined so this spectrum is relative to that and the value for _harm=1 should be 1.0.

This method of harmonic indexing in the FDD is meant primarily for defining

multiple spectral outputs dependent on the same spectral input. But the _harm index

can also be used to change which spectral input is used for each spectral output. An

example is i[2,1]=_sv(2,_harm)/50, which adds a 50 ohm load at all the harmonics of

fund1, including DC. Note that this example is to illustrate the capability, it is

inefficient compared to using a resistor. Another example is i[2,1] =

_sv(1,0,_harm)/mag(_sv(1,0,1)+tinyreal)/Rout, which outputs an entire fund1

spectrum at port 2, based on the port 1 fund2 spectrum, and limits each spectral

component by the fund2 fundamental magnitude.

Note there is no capability in the FDD to allow automatic outputting of all spectral

tones. The _harm index is essentially limited to harmonics of the frequency specified

by the parameter indices. Additional parameters and equations have to be used to

cover additional fundamentals and intermods. An example of this is in the section

“Mixer” on page 6-31.

### Page 164 from 216

6-14 The Frequency-Domain Defined Device

Custom Modeling with Frequency-Domain Defined Devices

Using Arrays

Sometimes you may want a flexible number of spectral tones, but no simple equation

is available for this. Arrays can be used in this case, and unlike the harmlist

parameter, a separate parameter with separate supporting code is not required. Care

must be taken to avoid having the indexes exceed the array bounds, or an error will

occur. For this reason, a length() function is available to return the length of an array.

The following VCO example shows a possible usage. Also, note that the Harmonics

input parameter is a list of complex numbers representing the relative level of all the

desired harmonics, for example, list(.1, .02_j*.01).

parameters Kv=1khz Freq=1GHz P=-j*dbmtow(0) Rout=50 Ohm Delay=timestep

Harmonics=

; Y_Port is used as voltage to current converter

Y_Port:CMP1 in 0 _NET00005 0 Y[2,1]=-.001

; This capacitor performs the integration function

C:CMP3 0 _NET00005 C=1/(2*pi*Kv)

; This switch resets the integrating capacitor voltage to 0 at time = 0

ResetSwitch:CMP4 0 _NET00005

; This FDD is a programmable harmonic current source with a phase modulation

input

FDD:CMP2 _NET00005 0 out 0 I[1,0]=0 I[2,-1]=a*exp(j*b)

I[2,-1]=if (_harm > 1 and _harm <= Hmax+1) then

a*Harmonics[_harm-1]*exp(j*_ha

rm*b)

else 0.0 endif Freq[1]=Freq

Hmax = length(Harmonics)

Pdbm=30.0 + 10.0*log(mag(P) + tinyreal)

a = -dbmtoa(Pdbm, Rout)*exp(j*phaserad(P))

b = 1000*_sv_d(1,Delay,0)

R:CMP5 out 0 R=Rout

### Page 165 from 216

The Frequency-Domain Defined Device 6-15

In this case, the model was hard-coded to expect an array. A more general solution

might use the above VCO example, but this would require the user to limit the array

bounds access, since accessing out of bounds will cause an error.

vcodata=makearray(0,1,2,.5,.25*j,.125,-.0625,-j*.03125,.015625)

xyz = if (_harm < length(vcodata) then vcodata[_harm] else 0.0 endif

vco_harm:CMP1 vin vout Kv=1khz FUND=1 Rout=50 ohm PFUND=0 dBm

Harmonic=xyz

While this could be used to simplify the harmlist implementation, harmlist may be

more efficient.