Timing Diagram Editing and Analysis

1.3 Generating Waveforms and States with Equations

1.3 Generating Waveforms and States with Equations

Previous topic Next topic  

1.3 Generating Waveforms and States with Equations

Previous topic Next topic  

Waveforms can be generated from Waveform Equations and automatically labeled using State Label equations. These features provide a quick way to generate signals that have a known pattern that is more complicated than a periodic clock cycle. The label equations also provide a quick way to define analog data for a waveform.

This is an older method of generating waveform data and these equations generate "one-time" results (the generated events react thereafter the same as if you had manually drawn these events). A newer method called Waveform Equation Blocks preserves the original equation for subsequent editing. These are described in Section 8.2: Waveform Equation Blocks for editable Analog waveforms.

To apply a Waveform or Label Equation to a signal:

Double-click on a signal's name to open the Signal Properties dialog.

Enter an equation and press the Wfm Eqn or Label Eqn button to apply it.

Sigprops_waveformeqn_section

The drop-down boxes have example equations and a history of past equations that you can modify so that you do not have to memorize the syntax. The black triangle is a quick add box that will enter the function values into the box.

Rules for Waveform Equations:

Each time you press Wfm Eqn button the waveform equation will be appended to the end of the signal, so you can build up a waveform using several smaller equations. The following example, uses a waveform equation to generate a variable frequency clock that switches from 25Mhz to 50Mhz. The initial frequency of 25MHz (period = 20+20 = 40ns) for 4 cycles and switches to 50Mhz for 5 more cycles. This type of waveform is tedious to draw by hand, but can be concisely expressed as a waveform equation. Pressing the button again would apply another set of waveforms to the end of the signal.

waveformeqn_clock

Tempwave

A Waveform equation is a list of space-separated, time-value pairs in the form TimeValue[units]=StateValue or TimeValue=StateValue.

If [units] are not specified, then the "display time unit" of the current project will be used.

Legal graphical StateValues are: 0 = strong low, 1= strong high, Z = tristate, V = valid, X = invalid, L = weak low, and H = weak high.

If the StateValue is not a graphical state, then a valid segment will be created and labeled with the state value. This allows you to label a signal with bus values and symbolic names while using the Waveform Equations. For example, 10ns=hello will draw a 10ns long valid segment  with a state value of hello.

For loops, enclose a list of time-value pairs in parenthesis followed by a multiply symbol and the number of times the list is to be repeated.

The default waveform equation contains all of the available states and syntax, so If you start by editing the default equation then you do not have to memorize the waveform equation rules.

Rules for Label Equations:

Each time you press the Label Eqn button the old state values are discarded and the new ones are written in (unlike the waveform equations which append to the end). Label equations provide a quick way to enter state values into digital counter signals and analog sine and capacitor discharge signals. For example a simple counter that starts at one and counts to ten could be written as: Skip(3),Inc(1,1,10).This tells the program to skip three segments, then to start labeling at one and place ten labels, incrementing by one each time. Functions can be combined by using a comma between the commands.

The black triangle to the right of the box is a quick fill box that will enter an equation into the state label box. Then all you have to do is replace the variables with your values.

Tip: First use a Waveform Equation to create an unlabeled signal with the correct number of segments, and then label it with a State Label Equation. For example (20=V)*100 creates a waveform with 100 valid segments that are 20ns wide.

A Label equation is a comma separated list of label functions.

The label functions are applied in the order listed.

Each label function returns a value of list so whenever you see list you can use a function, a single value like 5 or blue, or a list in parentheses (2,3,4).

labeleqn_quickfill

Digital state label functions

Inc(start, increment, count)

This function generates labels that begin at start and increase by increment each time. A total of count labels will be generated. The actual labels generated will be start, start + increment, start + (increment * 2), …, start + increment * (count - 1).

Inc-0-2-10

Dec(start, increment, count)

This function generates a total of count labels that begin at start and decrease by increment each time. It is equivalent to calling Inc(start, -increment, count).

IncString("string", start, increment, count)

This function behaves identically to the Inc function, except that the incremented label values are appended to the string.

IncString

Range(start, finish, count)

This function generates count state labels, evenly distributed over the range of values from start to finish inclusive.

Range

RandomIntegerArray(count, Range_to_zero) or RandInt(count, Range_to_zero)

This function generates random state values for waveforms. Count indicates the number of integers to generate. The integers are random values within an inclusive range of 0 to Range_to_zero.

Rep((list), count)

This function repeats list count number of times. The list can either be a literal list (e.g., (1,3,4) or ("red","green","blue")) or it can be a function that generates a list (e.g., Inc, Dec, or Rep). If the list contains words, place them in quotes. Note that the list must be placed in its own pair of parentheses.

Rep

Hex(list)

This function formats the items in list as hexadecimal. All numbers in the list are converted to a base-16 representation. The letters a-f are lowercase, and the numbers are prefixed by 'h to indicate that they are hexadecimal. By default, all numbers in the list are formatted to the same number of digits, adding leading zeros as necessary. If a MSB and LSB for the signal are specified in the Signal Properties dialog, all numbers will be formatted to display the given number of bits.

Hex

Bin(list)

This function formats the items in list as binary. All numbers in the list are converted to a base-2 representation. The numbers are prefixed by 'b to indicate that they are binary. By default, all numbers in the list are formatted to the same number of digits, adding leading zeros as necessary. If a MSB and LSB for the signal are specified in the Signal Properties dialog, all numbers will be formatted to display the given number of bits.

Bin

Skip(count)

This function causes a number of segments to be skipped (left unchanged) by the equation.

File("filename.txt")

This function imports a set of state values from the specified text file. This is an easy way to import values generated in a program such as MatLab, Mathematica, or a user-written C program. In the file, each state value should be on a separate line.

Signal("signalname")

This function copies the states from the signal indicated by signalname and applies them to the current signal. If no signalname is specified then the function returns the array of states of the current signal (this is useful when working with the map function).

map{operations} list

The map function allows you to perform a set of operations on every state in a state array. The first argument to the map function is the set of operations to perform, enclosed in curly brackets { }. The second argument is the list whose elements are to be operated on. The special variable $_ is used to represent the state value to be operated on (it takes on the value of each state in the list). Once you become familiar with it, the map function in combination with standard Perl language operations gives you extraordinary expressive power. See Chapter 15 for more information on Perl. For example the map{$_ + 5} Signal(). The Signal function returns a list of the states on the current signal, and the map function increments each state in the array by 5.

Analog state label functions

Analog state label equations are covered in Section 8.3 Sine, Capacitor, Ramp, and Exponential waveforms and covers Sin, SinStart, SinEnd, CapCharge, CapDischarge, Ramp, and Exponential. This is an older method of generating analog waveform data and these equations generate "one-time" results (the generated events react thereafter the same as if you had manually drawn these events). Unlike the Waveform Equation Blocks described in Section 8.2: Waveform Equation Blocks for editable Analog waveforms, the original equation cannot be changed to change the waveform, only the individual events can be edited.

User-defined state label functions

Users can also add new functions by placing them into the perl script labelequation.pm located in the SynaptiCAD > Perl directory. Normally, state label equations are entered using the Signals Properties dialog, but they can also be placed in a perl script. Perl scripts are useful for creating especially complex waveforms. The file wfm_analog_example.pl in the perl directory has an example of using a label equation inside of a Perl script.