Manuals >Reference >ADS Simulator Print version of this Book (PDF file) |
![]() ![]() |
|
|
"C-Preprocessor"Before being interpreted by the ADS Simulator, all input files are run through a built-in preprocessor based upon a C preprocessor. This brings several useful features to the ADS Simulator, such as the ability to define macro constants and functions, to include the contents of another file, and to conditionally remove statements from the input. All C preprocessor statements begin with # as the first character. Unfortunately, for reasons of backward compatibility, there is no way to specify include directories. The standard C preprocessor "-I" option is not supported; instead, "-I" is used to specify a file for inclusion into the netlist. File Inclusion#include "filename" is replaced by the contents of the file filename. The file must be specified with an absolute path or must reside in either the current working directory or in /$HPEESOF_DIR/circuit/components/. Library InclusionThe C preprocessor automatically includes a library file if the -N command line option is not specified and if such a file exists. The first file found in the following list is included as the library: $HPEESOF_DIR/circuit/components/gemlib $EESOF_DIR/circuit/components/gemlib $GEMLIB .gemlib ~/.gemlib ~/gemini/gemlib A library file is specified by the user using the -Ifilename command line option. More than 1 library may be specified. Specifying a library file prevents the ADS Simulator from including any of the above library files. Macro DefinitionsA macro definition has the form; #define name replacement-text It defines a macro substitution of the simplest kind--subsequent occurrences of the token name are replaced by replacement-text. The name consists of alphanumeric characters and underscores, but must not begin with a numeric character; the replacement text is arbitrary. Normally the replacement text is the rest of the line, but a long definition may be continued by placing a "\" at the end of each line to be continued. Substitutions do not occur within quoted strings. Names may be undefined with #undef name It is also possible to define macros with parameters. For example, #define to_celcius(t) (((t)-32)/1.8) is a macro with the formal parameter t that is replaced with the corresponding actual parameters when invoked. Thus the line options temp=to_celcius(77) options temp=(((77)-32)/1.8) Macro functions may have more than 1 parameter, but the number of formal and actual parameters must match. Macros may also be defined using the -D command line option. Conditional InclusionIt is possible to conditionally discard portions of the source file. The #if line evaluates a constant integer expression, and if the expression is non-zero, subsequent lines are retained until an #else or #endif line is found. If an #else line is found, any lines between it and the corresponding #endif are discarded. If the expression evaluates to zero, lines between the #if and #else are discarded, while those between the #else and #endif are retained. The conditional inclusion statements nest to an arbitrary level of hierarchy. The following operators and functions can be used in the constant expression;
The #ifdef and #ifndef lines are specialized forms of #if that test whether a name is defined.
|
|
|
|
![]() ![]() |