Frequency Domain Modeling and Simulation

Ernst Christen christen@analogy.com


1. Introduction

The purpose of this paper is to define support for small-signal frequency domain concepts in VHDL 1076.1. The paper addresses small-signal frequency domain modeling and simulation as well as small-signal noise modeling and simulation.

The table of contents of this document is available here.


2. Frequency Domain Modeling and Simulation


2.1 The Small-Signal Model

[after LRM 7.5-683]

7.6 Linear Forms

The equivalent function EF of an expression E with respect to the name N of a value bearing object that appears in E is defined as follows:

function EF (N: <typeofN>) return <typeofE> is
begin
	return E;
end EF;
 

where EF is a name unique to the expression and the name, <typeofN> is the type of the value denoted by the name N, and <typeofE> is the type of expression E. Given an expression E, of a base type with the subtraction ("-") operation defined on it, an increment function INCF can be defined with respect to the name N of a value bearing object in E, at a value V for N, as follows:

function INCF (N, V: <typeofN>) return <typeofE> is
	definition of EF;
begin
	return EF(N) - EF(V);
end INCF;
 

where V has the same type as N and other names are as given above. The partial derivative function, PDF, of an expression E with respect to the name N of a value bearing object in expression E, at a value V for N, where the base type of E has the subtraction ("-") and division ("/") operations defined, may be defined as follows:

function PDF (N, V: <typeofN>) return <typeofE> is
	definition of INCF;
begin
	implement PDF;
end PDF;
 

where "implement PDF" is any reasonable numerical algorithm that returns the limit of the following expression:

INCF(N, V) / (N - V)

as the value of N approaches the value of V, INCF is formed from the expression as above, and other names are as above.

An expression E is said to be linear with respect to the name N of a value bearing object in E if the value of PDF(N, V) is the same for any value of V in its subtype. An expression is linear in a set of names if it is linear with respect to each name in the set. An expression is independent of the name if the value of the expression does not change regardless of the value of the name.

The linearized form of any expression with respect to the quantity names N0, ..., Nm in that expression at the values V0, ..., Vm is the following expression:

PDF0(N0, V0)*N0 + PDF1(N1, V1)*N1 + ... + PDFm(Nm, Vm)*Nm

where the PDF's for each name in the expression is constructed as above. This expression is linear in all its quantities.


2.2 Domains

[In package STANDARD]

type DOMAIN_TYPE is (INITIALIZATION_DOMAIN, TIME_DOMAIN, FREQUENCY_DOMAIN);

signal DOMAIN: DOMAIN_TYPE;


2.3 Small-Signal Frequency Domain and Noise Stimulus

[At 1076.1 LRM 4.1.3.6-538]

quantity_declaration ::= free_quantity_declaration | branch_quantity_declaration | source_quantity_declaration

[At 1076.1 LRM 4.3.1.6-544]

source_quantity_declaration ::= quantity identifier_list : subtype_indication source_aspect ;

[At 1076.1 LRM 4.3.1.6-550]

source_aspect ::= spectrum magnitude_simple_expression , phase_simple_expression | noise magnitude_simple_expression

[At 1076.1 LRM 4.3.1.6-553]

A source quantity declaration declares a source quantity. A source quantity whose source aspect includes the reserved word spectrum is a spectral source quantity. A source quantity whose source aspect includes the reserved word noise is a noise source quantity.

[At 1076.1 LRM 4.3.1.6-576]

The tolerance group of each scalar subelement of a source quantity is the tolerance group of the corresponding scalar subelement of its subtype.

[At 1076.1 LRM 4.3.1.6-591]

The type of the magnitude simple expression and phase simple expression in a source aspect must be that of the source quantity. It is an error if the name of a source quantity appears in an expression in a source aspect.

[In package STANDARD]

-- a function that returns the current simulation frequency function FREQUENCY return REAL;

[At ???]

The predefined function FREQUENCY returns the value of the current simulation frequency if the value of the predefined signal DOMAIN is FREQUENCY_DOMAIN; it returns 0.0 otherwise. It is an error if a call to the FREQUENCY function appears in an expression that is not part of a source aspect.


2.4 Small-Signal Frequency Domain Calculation

  1. Execute the initialization phase and the simulation cycle described in Initialization until the value of the implicit DOMAIN signal is FREQUENCY_DOMAIN after step d).
  2. Set the simulation frequency to the desired value.
  3. Replace each characteristic expression in the basic set by its linearized form with respect to all quantities, at the current values for the quantities.
  4. Determine the values of all expressions in the frequency domain augmentation set.
  5. Augment the linearized form of the characteristic expressions of the basic set with the frequency domain augmentation set.
  6. Solve the resulting (linear) system of equations.


2.5 Small-Signal Noise Calculation

  1. Execute the initialization phase and the simulation cycle described in Initialization until the value of the implicit DOMAIN signal is FREQUENCY_DOMAIN after step d).
  2. Set the simulation frequency to the desired value.
  3. Replace each characteristic expression in the basic set by its linearized form with respect to all quantities, at the current values for the quantities.
  4. Determine the values of all expressions in the noise augmentation set and the values of the magnitude simple expressions in all noise quantity declarations.
  5. Augment the linearized form of the characteristic expressions of the basic set with the noise augmentation set.
  6. In the noise kernel create, for each scalar quantity in the model, one variable of the base type of the corresponding quantity, and initialize each variable to 0.0.
  7. For each scalar subelement Q of each noise source quantity in the model:
    1. Replace its characteristic expression by the expression Q - magnitude where magnitude is the value of the corresponding scalar subelement of the magnitude simple expression evaluated in step 5.
    2. Solve the resulting (linear) system of equations.
    3. Restore the original characteristic expression replaced in step 7.a)
    4. Add to each variable created in step 6 the square of the magnitude of the value of its corresponding scalar quantity.
  8. Set the value of each quantity to the square root of its corresponding variable.


3. Special Quantities


3.1 Zero Order Hold

[In section 14]

Q'ZOH(T, INITIAL_DELAY)

Kind :
Quantity
Prefix :
Any quantity denoted by the static name Q.
Parameter :
T: A static expression of type REAL that evaluates to a positive value: sampling period
INITIAL_DELAY: A static expression of type REAL that evaluates to a nonnegative value: first sampling after INITIAL_DELAY sec. If omitted, it defaults to 0.0.
Result Type :
The type of Q.
Result :
The value of Q sampled initially at INITIAL_DELAY sec and then periodically every T sec and held between the sampling points. Its functionality is described formally by the following equivalent block.
use ieee.math_real.all;
 
block
	generic (t: real; initial_delay: real := 0.0);
	generic map (t => t, initial_delay => initial_delay);
	port (quantity q: in <type_of_q>;
	      quantity zoh: out <type_of_q>);
	port map (q => q, zoh => q'Zoh(t, initial_delay));
	signal s: <type_of_q> := 0.0;
 
begin
	process begin
		wait on DOMAIN;
		if initial_delay > 0.0 then
			wait for initial_delay;	-- needs real timeout clause
		end if;
		loop
			s <= q;
			break when s /= q;
			wait for t;		-- requires real timeout clause
		end loop;
	end process;
 
	if DOMAIN = FREQUENCY_DOMAIN use
		if FREQUENCY = 0.0 use
			zoh == q;
		else
			zoh == q'Delayed(0.5 * t) * 
				sin(FREQUENCY*math_pi*t) / (FREQUENCY*math_pi*t);
		end use;
	elsif DOMAIN'Delayed = INITIALIZATION_DOMAIN use
		if initial_delay = 0.0 use
			zoh == q;		-- follow q during initialization
		else
			zoh == 0.0;
		end use;
	else					-- time domain
		zoh == s;
	end use;
 
end block;
 

Notes

  1. For the purpose of this definition the "/=" and "*" operators are considered to be overloaded as follows.
    • "/=" compares each scalar subelement of its first argument with the corresponding scalar subelement of its second argument. It returns True if any such pair differs.
    • "*" multiplies each scalar subelement of its first argument with the scalar second argument and returns a result of the type of the first argument.
  2. This is not a legal VHDL 1076.1 description although it uses VHDL 1076.1 syntax. The predefined FREQUENCY function cannot be called in a simultaneous statement.


3.2 Transfer Functions

[In package STANDARD]

type REAL_VECTOR is array(NATURAL range <>) of REAL;


3.2.1 Laplace Transfer Function

[In section 14]

Q'LTF(NUM, DEN)

Kind :
Quantity.
Prefix :
Any scalar quantity denoted by the static name Q.
Parameters :
NUM: A static expression of type REAL_VECTOR: numerator coefficients.
DEN: A static expression of type REAL_VECTOR: denominator coefficients.
Result Type :
The type of Q.
Result :
The Laplace transfer function with num as numerator and den as denominator polynomials. Its functionality is described formally by the following equivalent block.
block
	generic (num, den: REAL_VECTOR);
	generic map (num => num, den => den);
	port (quantity q: in <type_of_q>;
	      quantity qtf: out <type_of_q>);
	port map (q => q, qtf => Q'Ltf(num, den));
 
	constant nnum: INTEGER := num'Length-1;
	constant nden: INTEGER := den'Length-1;
	alias b: REAL_VECTOR(0 to nnum) is num;
	alias a: REAL_VECTOR(0 to nden) is den;
	quantity qin: REAL_VECTOR(0 to nnum);
	quantity qout: REAL_VECTOR(0 to nden);
 
	function "*"(v1, v2: REAL_VECTOR) return REAL is
		variable result: REAL := 0.0;
	begin
		for i in v1'Range loop
			result := result + v1(i)*v2(i);
		end loop;
		return result;
	end function "*";
begin
	q == qin(0);
	qin(1 to nnum) == qin(0 to n-1)'Dot;
	qtf == qout(0);
	qout(1 to nden) == qout(0 to nden-1)'Dot;
	qout(0) == (qin * b - qout(1 to nden) * a(1 to nden)) / a(0);
end block;
 
Restrictions :
The first scalar subelement of DEN must not be 0.0.


3.2.2 Z-Domain Transfer Function

Q'ZTF(NUM, DEN, T, INITIAL_DELAY)

Kind :
Quantity.
Prefix :
Any scalar quantity denoted by the static name Q.
Parameters :
NUM: A static expression of type REAL_VECTOR: numerator coefficients.
DEN: A static expression of type REAL_VECTOR: denominator coefficients.
T: A static expression of type REAL that evaluates to a positive value: sampling period.
INITIAL_DELAY: A static expression of type REAL that evaluates to a nonnegative value: first sampling after INITIAL_DELAY sec. If omitted, it defaults to 0.0.
Result Type :
The type of Q.
Result :
The Z-domain transfer function with num as numerator and den as denominator polynomials, T as sampling frequency, and initial_delay specifying the time of the first sampling. Its functionality is described formally by the following equivalent block.
block
	generic (num, den: REAL_VECTOR; t: REAL; 
			initial_delay: REAL := 0.0);
	generic map (num => num, den => den, t => t, 
			initial_delay => initial_delay);
	port (quantity q: in <type_of_q>;
	      quantity qtf: out <type_of_q>);
	port map (q => q, qtf => Q'Ztf(num, den, T, initial_delay));
 
	constant nnum: INTEGER := num'Length-1;
	constant nden: INTEGER := den'Length-1;
	alias b: REAL_VECTOR(0 to nnum) IS num;
	alias a: REAL_VECTOR(0 to nden) is den;
	quantity qin: REAL_VECTOR(0 to nnum);
	quantity qout: REAL_VECTOR(0 to nden);
 
	function "*"(v1, v2: REAL_VECTOR) return REAL is
		variable result: REAL := 0.0;
	begin
		for i in v1'Range loop
			result := result + v1(i)*v2(i);
		end loop;
		return result;
	end function "*";
begin
	qin(0) == q'Zoh(T, initial_delay);
	qin(1 to nnum) == qin(0 to n-1)'Delayed(T);
	qtf == qout(0);
	qout(1 to nden) == qout(0 to nden-1)'Delayed(T);
	qout(0) == (qin * b - qout(1 to nden) * a(1 to nden)) / a(0);
end block;
 
Restrictions :
The first scalar subelement of DEN must not be 0.0.


4. Rationale


4.1 The Small-Signal Model


4.1.1 Mathematical Background

Given a system model described by the equations

	F(x, dx/dt, t) = 0
 

and a solution x0, dx0/dt at t0. The Taylor expansion of F about the solution at t0 is:

	F(x-x0, dx/dt-dx0/dt, t-t0) = F(x0, dx0/dt, t0)
		+ PF(x, dx/dt, t)/Px . (x-x0)
		+ PF(x, dx/dt, t)/P(dx/dt) . (dx/dt-dx0/dt)
		+ PF(x, dx/dt, t)/Pt . (t-t0)
		+ higher order terms
 

where the P indicates partial differential and all partial derivatives are evaluated at the solution x0, dx0/dt. The small-signal model is defined as the linear terms in this expansion. It is a linear incremental model of the form G(x, x0) = F(x-x0) - F(x0) = PF(x)/Px . (x - x0), and we can solve the linear system of equations G(x, x0) = rhs, where rhs is a constant vector formed from the small-signal stimulus applied to the model. We also note that for traditional small-signal analyses the time is held constant and that, by convention, the increment (x-x0) in G is mapped onto x, so the value of an unknown x has to be interpreted differently in large-signal and small-signal simulations.

For a small-signal frequency domain simulation G(x, x0) can be transformed into the frequency domain using the Fourier transform, and rhs will be a complex vector.


4.1.2 Definition

Section 2.1 provides a formal definition for the partial differential PDF of an expression with respect to an object whose name appears in the expression, evaluated at a specified value for the object. With the exception of taking the limit, it is based on the VHDL expression evaluation semantics, i.e. it avoids symbolic manipulations of the expression. The linearized form of the expression, i.e. its total differential, is then defined in terms of the PDFs.

The small signal model is then built by replacing each explicit characteristic expression (CE) by its linear form for small-signal frequency domain calculations and small-signal noise calculations. Additionally, we replace the implicit CEs related to quantities of the form Q'Dot, Q'Integ and Q'Delayed(T) by their respective Fourier transformed forms. Depending on the small-signal simulation we also must replace the implicit CE corresponding to some source quantities; this will be discussed below. We note that nothing needs to be done to the other implicit CEs, because they are linear, so their linearized form is identical to their original form.


4.2 Domains

As a result of discussions in the LDC we distinguish between three domains: initialization, time, and frequency. The domain concept is implemented by a signal DOMAIN whose value is initialized to INITIALIZATION_DOMAIN and changes when the simulation has reached the quiescent point. See Initialization for details.


4.3 Small-Signal Frequency Domain and Noise Stimulus

There are two kinds of stimuli for small-signal analyses: stimulus for a small-signal frequency domain simulation (similar to a SPICE AC analysis), and stimulus for a noise simulation. Although they are treated differently by the respective algorithms they share many common properties.

The common requirements are as follows.

Additionally, the following requirements apply to noise stimulus only.

The definition unify the two kinds of stimuli under the concept of a source quantity. Since the CE of a source quantity Q is Q, its value is equal to zero under most conditions. This allows a source quantity to be used in any VHDL expression, with no effect except in its related small-signal simulation. There, its effect is as expected, due to the definition of the linearized form and the corresponding calculations to obtain small-signal results. For example, an expression of the form f(q) . Q, where Q is a source quantity and q represents other quantities, appears as f(q0) . Q in the linearized form about q0.

Source quantities are declared by a source quantity declaration. This allows a user to give each such quantity a unique name as well as an appropriate type, which can be a composite type. Source quantities come in two kinds. The spectral source quantity implements a stimulus for a small-signal frequency domain (AC) simulation, while the noise source quantity supports noise stimulus. The kind can be determined from the declaration, which uses special syntax. The reserved word spectrum in a source quantity declaration identifies a spectral source quantity, the reserved word noise identifies a noise source quantity. Both declarations take arguments that are expressions of the same type as the source quantity. These expressions are not required to be static, i.e. they can contain the names of quantities and signals. These expressions are used to form characteristic expressions when the simulations related to the source quantity are done. For a spectral source quantity they support the specification of a complex spectrum, for a noise source quantity only the magnitude of the spectrum can be specified.

The predefined function FREQUENCY returns, during frequency domain simulations, the value of the current simulation frequency. Calls to the FREQUENCY function can appear only in expressions that are part of the declaration of source quantities.

Among the noise sources it is an easy task for the analyzer to identify those whose magnitude simple expression is of the form [ expression1 mul_op ] FREQUENCY ** expression2 [ mul_op expression3 ] where mul_op ::= * | /. These are the flicker noise sources. Because of this possibility there is no need to syntactically distinguish between a flicker noise spectrum and other noise spectra.


4.4 Small-Signal Frequency Domain and Noise Calculation

The definitions cover the calculations for a single frequency point. First, the quiescent point is determined, about which the model will be linearized. Then the small-signal model is constructed by replacing

Before the CEs corresponding to the source quantities are handled the desired simulation frequency must be established. For a small-signal frequency domain (AC) simulation the definition of the frequency domain augmentation set guarantees that the CEs corresponding to the spectral source quantities get the complex values specified by the magnitude simple expression and the phase simple expression in its declaration. For a small-signal noise simulation the noise source quantities must be handled one after the other to allow the summing of the noise powers.


4.5 Zero-Order Hold

This is a useful primitive whose frequency domain behavior cannot be described using the VHDL 1076.1 language. This is the reason why it is a predefined quantity. It allows the specification of the sampling period, which must be a static expression with a positive value, and an initial delay after which sampling starts. The delay must also be a static expression. Its value defaults to zero and must not be negative.


4.6 Transfer Functions

The Laplace transfer function implements, in the frequency domain, a ratio of two polynomials in the Laplace operator s. In the time domain this corresponds to a linear ODE with constant coefficients. In the language the Laplace transfer function is defined as an attribute of kind quantity, similar to the quantities Q'Dot or Q'Integ. Its value is defined by a linear ODE with constant coefficients, by means of an equivalent block. This approach resolves a definitional problem related to initial conditions: From the perspective of the text of the model none of the derivatives of Q exist, so an initial condition for say Q'Dot specified in the text of the model does not affect the derivatives appearing in the equivalent block.

The Z transfer function implements a ratio of two polynomials in the variable z**-1, which represents a delay by a constant T. Like the Laplace transfer function, the Z transfer function is defined as an attribute of kind quantity, by means of an equivalent block. The parameter initial_delay allows to specify when the first sampling occurs, after that it occurs at intervals of length T.

In both cases numerator and denominator polynomials are specified as real arrays. They must be constant, to permit an analytical transformation of the resulting characteristic expressions into the frequency domain. Further, the first scalar subelement of the denominator array must be non-zero, to avoid the need for initial conditions.

The transfer functions require the definition of type REAL_VECTOR for the specifications of the polynomial coefficients. This type is defined in package STANDARD as an unconstrained array with a natural index.

Because type REAL_VECTOR is not part of VHDL 1076, it is possible or even likely that it will be also defined somewhere in a package. According to the VHDL visibility rules we have two cases to distinguish if such a package is made visible through a USE clause:

We cannot do much about this problem except to list it in an appendix as a potential portability problem when upgrading from VHDL 1076 to VHDL 1076.1.

Unlike Q'Dot, Q'Integ and Q'Delayed(T), Q'Ltf and Q'Ztf are defined only for scalar quantities. In control system applications matrix transfer functions would make sense, with Q being an array, but this kind of functionality has its problems:

Other forms of transfer functions allowing specification of poles and/or zeros have not been defined here for the following reasons.


5. Alternatives Considered


5.1 Domains

The DOMAIN concept could be implemented as a function. However, this would still require a signal to allow changes in the time domain model when the quiescent point has been reached. As a consequence, some information would be duplicated, as DOMAIN = INITIALIZATION_DOMAIN always implies that the quiescent point has not yet been reached. The current version with DOMAIN as a signal removes this duplication and is therefore cleaner.


5.2 Source Quantities

In earlier versions of this document the source quantities were implicit quantities with names of the form spectrum(mag, phase), noise(mag), and flicker_noise(mag, exp). This caused the following definitional problems.

The separate treatment of flicker noise was removed in favor of a uniform syntactic treatment for all noise source quantities based on the assertion of compiler experts that it is an easy task to analyze the magnitude simple expression in a noise quantity declaration and discover whether it has the form of a flicker noise specification. The uniform treatment avoids an extra reserved word in the language without loss of functionality.


Revision History

0.1 Feb. 15, 1995 Serge Garcia-Sabiro, Raphael Dorado
Original version, summarizing some of the small-signal concepts
0.2 July 30, 1996 Ernst Christen
Complete revision. Added defiinition of small-signal model, frequency domain stimulus, transfer functions, and support for noise
0.3 Sep. 13, 1996 Ernst Christen
Added definition of zero order hold. Modified z-domain transfer function to use ZOH.
0.4 Dec. 30, 1996 Ernst Christen
Changed DOMAIN function to a signal. Included David Barton's definitions for linear forms. Provided formal definitions for small-signal stimulus (spectrum(MAG, PHASE)) and small-signal noise sources (noise(MAG) and flicker_noise(MAG, EXP)). Reworked simulation recipes for small-signal frequency domain simulation and noise simulation.
0.5 Jan. 10, 1997 Ernst Christen
Changed definitions for small-signal stimulus to special quantity declarations. Removed special handling for flicker noise. Reorganized document. Updated rationale.
0.6 Feb. 18, 1997 Ernst Christen
Updated definition of zero-order hold to reflect initialization correctly. Modified definition of source quantities to better follow LRM style (suggested by David Barton).
0.7 April 8, 1997 Ernst Christen
Changed definition of frequency domain and noise calculation to make use of augmentation sets. Fixed definition of Q'ZOH. Added notes to ZOH definition. Changed syntax of source quantity declaration after discussions with Ken Bakalar and Dave Barton. Made FREQUENCY a pure function.