To see the parameter values of a star or galaxy, execute the Edit:edit-params command, which has the accelerator key "e". The

`singen `

star in the `sinMod`

application has the following parameter screen:
Notice that the *frequency *parameter is given as an expression, "PI/100" (PI represents the constant ). This section describes the expression language for specifying parameter values.

The parameter screen can be kept open while you experiment with different values of the parameters. Try changing the value "PI/100" to "PI/200". Click "Apply" in the parameter window, and then "GO" in the run control panel. How does this change the display? Clicking "Cancel" in the parameter window will restore the parameter values to the last saved values and dismiss the parameter window. Clicking "Close" will dismiss the parameter window without restoring the parameter values.

`State`

is a data-structure associated with a star and is used to remember data values from one invocation to the next. For example, the gain of an automatic gain control is a state. A state need not be dynamic since its value may not change during the course of a simulation. Technically, a `Pigi`

is responsible for defining parameter values and storing them in the design database.`pigi`

permits the user to set the initial value of a settable state of any star (lowest level block) and to define and set parameters for a galaxy (composite block) or universe (complete application).`sinMod`

application shown in figure
2-4. The parameter screen for the `modulator`

block is shown below:This block, however, is a galaxy, not a star. If you look inside (as has been done in figure 2-4), and edit the parameters of the

`singen`

block inside `modulator`

, you will seeNotice now that the value of the

`pigi`

can be arithmetic expressions. This is particularly useful for propagating values down from a universe parameter to star parameters somewhere down in the hierarchy. An example of a valid parameter expression is:`order`

is a parameter defined in the galaxy or universe. The basic arithmetic operators are addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (^). These operators work on integers and floating-point numbers. Currently all intermediate expressions are converted to the type of the parameter being computed. Hence, it is necessary to be very careful when, for example, using floating-point values to compute an integer parameter. In an integer parameter specification, all intermediate expressions will be converted to integers.`real`

and `imag`

evaluate to integers or floats. `Syntax 1`

: As a string like "3.2", or more generally "*m.n*", where*m*is the number of integer bits (to the left of the binary point) and*n*is the number of fractional bits (to the right of the binary point). Thus length is*m*+*n*.`Syntax 2`

: A string like "24/32" which means 24 fraction bits from a total length of 32. This format is often more convenient because the word length often remains constant while the number of fraction bits changes with the normalization being used. In both cases, the sign bit counts as one of the integer bits, so this number must be at least one.Thus, for example, a fixed-point parameter might be defined as "(0.8, 2/4)." This means that a 4-bit word will be used with two fraction bits. Since the value "0.8" cannot be represented precisely in this precision, the actual value of the parameter will be rounded to "0.75".

A fixed-point parameter can also be given a value without a precision. In this case, the default precision is used. This has a total word length of 24 bits with the number of integer bits set as required to store the value. For example, the number 1.0 creates a fixed-point object with precision 2.22, and a value like 0.5 would create one with precision 1.23.

The precision of internal computations in a star is typically given by a parameter of type

`precision`

. A precision parameter has a value specified using either of the two syntaxes above.

`<`

as in the following example:`filename`

in the form of `{parameter}`

are replaced with their values. Then, any references to environment variables or home directories are substituted to generate a complete path name. Finally, the contents of the file are then read and spliced into the parameter expression and reparsed. File inputs can be very useful for array parameters which may require a large amount of data. Other expression may come before or after the `<filename`

syntax (any white space that appears after the `<`

character is ignored).`#`

symbol. Everything after the `#`

until the end of the line is discarded when the parameter is evaluated. Comments are especially useful in combination with files as they can help remind the user of which galaxy or star parameter the file was written.
For example, a comment could be added to the *frequency* parameter above:

`#`

character is used to denote the frame number of the image being processed.`{parameter}`

appearing in the expression are replaced by their values. Then, the string is sent to the pigiRpc Tcl interpreter for evaluation. Finally, the result is spliced into the parameter expression and reparsed. The pigiRpc Tcl interpreter is the same interpreter that appears as a window when `pigi`

is started by using `pigi -console`

.
This facility is general and supports both numeric and symbolic computing of expressions. Through Tcl, one can access all of its math functions, which generally behave as the ANSI C functions of the same name: `abs`

, `acos`

, `asin`

, `atan`

, `atan2`

, `ceil`

, `cos`

, `cosh`

, `double`

, `exp`

, `floor`

, `fmod`

, `hypot`

, `int`

, `log`

, `log10`

, `pow`

, `round`

, `sin`

, `sinh`

, `sqrt`

, `tan`

, and `tanh`

. So, a parameter expression could be

`BitDuration`

is a parameter. The `expr`

command is a Tcl command that treats its arguments as a single mathematical expression that must evaluate to a number.The Tcl mechanism can be used to return symbolic expressions:

`gain1`

is not surrounded by curly braces, its value is not substituted before passing the expression to the Tcl interpreter. The Tcl interpreter will return `2*gain1`

which is then evaluated by the parameter parser.
We have also introduced several new procedures in the Tcl interpreter embedded in `pigiRpc`

to help support parameter calculations. They are: `listApplyExpression`

, `max`

, `min`

, `range`

, `rangeApplyExpression`

, and `sign`

. For example,

`min 3 -1`

and then to `-1`

. The procedure `range`

returns a consecutive sequence of numbers:`0 1 2 3 4 5`

. The `rangeApplyExpression`

procedure generates a sequence of values by applying a consecutive sequence of numbers to a Tcl expression that is a function of `i`

. For example, you can generate the taps of an FIR filter that is a sampled sinusoid by using`listApplyExpression`

is similar to `rangeApplyExpression`

except that it only takes two arguments: the second argument is a list of numbers to substitute for `i`

in the expression. The command`rangeApplyExpression`

function.
Inside the `pigiRpc`

console window, which is created when you run pigi with the option `-console`

and which has the `pigi>`

prompt, you can receive help on the new Tcl procedures listApplyExpression, max, min, range, rangeApplyExpression, and sign, by typing

`pigiRpc`

console includes the Ptolemy interpreter (`ptcl`

) which defines the help mechanism. Help is available on all of the commands we have added to the Tcl language.
The Ptolemy interface to Matlab and Mathematica can also be accessed from the pigiRpc console window, and the Tycho editor offers console windows that mimic the Matlab and Mathematica terminal (tty) interfaces. More information about the options of the new Tcl commands `matlab`

and `mathematica`

can be found by using the help facility described above.

`n`

evaluates to an integer. An array or portion of an array can be input from a file using the symbol `<`

as in the following example:`filename,`

and the last two elements will be 3 and 4. This latter capability can be used in combination with the `WaveForm`

star to read a signal from a file. `{word}`

represents the value of a string universe or galaxy parameter. This capability is especially useful for constructing labels for output plots. When using string states to specify options for a Unix command, as in the options parameter in `Xgraph`

stars, you can use either double quotes or single quotes to include white space within a single word:`paramname`

must be the name of either a string array or a scalar-valued parameter (an integer, float or complex array, for example, is not permitted). If it is a string array, then each element of `paramname`

becomes an element of the parameter. If it is some other kind of parameter the value becomes a single element of the string array.
To use one of `[`

, `]`

, `{`

, or `}`

literally, quote them with double quotes. To turn off the special meaning of a double quote, precede it with a backslash: `\"`

. Similarly, use `\\`

to get a single backslash.

String array values may also be read from files using the `<`

symbol. For details on how to use file references, see section
2.4.3 above. Note that for string arrays, the filename can be a

literal string such as

`file.{1,2}`

into `file1`

`file2`

as a Unix shell might do.