20
Managing Files
This chapter discusses the following topics:
About Spectre Filename Specification
Many analysis statements require a filename as a parameter value for the input or output of data. It is often easier to keep track of output files if these filename parameter values are related to some other filename, typically the input filename.
The Spectre® circuit simulator’s filename specification features help you manage your data by letting you systematically specify or modify filenames. With the Spectre simulator, you can easily identify data from multiple simulation runs or from single runs containing repeated similar analyses. You can modify input filenames so that you can easily identify the output file from a specific simulation or analysis. You can also construct output filenames in ways that prevent accidental overwriting of data.
Creating Filenames That Help You Manage Data
The Spectre simulator helps you keep track of simulation data by letting you create filenames that are variants of input filenames. For example, with Spectre, you can
- Identify simulation data by date, time, process ID, or other defining characteristics in the results filenames
-
Keep multiple circuits in a single directory without having subsequent simulations overwrite previous results
To do this, you set environment variables so that output filenames are automatically different variants of input filenames. -
Construct filenames at run time
This is convenient if your input data comes from several files. For example, you can use anincludestatement to insert several different circuit files into main input files that each contain analyses. Each circuit file can also be used with several stimulus files. To prevent confusion, you can create filenames at run time for the stimulus files that associate them with the appropriate main input files.
In this section, you will learn how to use the various Spectre features for creating filenames.
Creating Filenames by Modifying Input Filenames
The Spectre simulator gives you predefined percent codes you can put in your filenames. These predefined codes let you construct filenames that add defining characteristics, such as date or time, to input filenames. You specify predefined percent codes with a percent character (%) followed by an uppercase letter. The uppercase letter tells the Spectre simulator how to construct the filename. You can use percent codes in environment variables, in spectre command parameters, or in your netlist—wherever you need to specify filenames for simulation results.
For example, %C is the predefined percent code for the name of the input circuit file. If your circuit file is named opamp1 and you place the following -raw setting for your UNIX environment variable
setenv SPECTRE_DEFAULTS "-raw %C.raw"
the Spectre simulator sends simulation results to the directory named opamp1.raw.
Description of Spectre Predefined Percent Codes
These are the percent code that can help you organize your simulation data:
The predefined percent codes feature does not perform recursive substitutions. For example, if you have an input file named A%SD.xyz and you create an output file with the percent code designation %C.raw, the Spectre simulator creates the output file A%SDxyz.raw. The Spectre simulator does not substitute the simulator name for %S in this case.
Customizing Percent Codes
You can define your own percent codes or redefine existing codes with the +%<X> option of the spectre command. Names of customized percent codes can be any single uppercase or lowercase letter. You can define percent codes in two ways:
-
You can define percent codes for a single simulation by typing this option into the command line with the
spectrecommand at the start of the simulation. -
You can specify the customized percent code as a default by typing the
spectrecommand into theSPECTRE_DEFAULTSenvironment variables.
For example, if you type in the following instruction at the command line
spectre +%E opamp1 test3
the Spectre simulator runs a simulation for circuit test3. During this simulation, the Spectre simulator substitutes the name opamp1 for any %E it finds in results filename specifications.
You undefine customized percent codes with the -%<X> spectre command option. For example, if you customize percent codes with the SPECTRE_DEFAULTS environment variable, you might want to undefine them for a given simulation run. To do this, you include the -%<X> command line option in the spectre command that starts the simulation. Undefined percent codes return to predefined values. If an undefined percent code has no predefined value, it is treated like an empty string.
Creating Filenames from Parts of Input Filenames
Colon modifiers (:x) create filenames from parts of input filenames. You can use colon modifiers with all percent codes except the %% code.
For example, if you apply %C:r.raw to the input filename opamp.ckt
%C is the input filename (opamp.ckt)
:r is the root of the input filename (opamp)
.raw is the new filename extension
The result is the output filename opamp.raw. In this example, (:r) is the colon modifier.
Definitions of Colon Modifiers
The Spectre simulator recognizes the following colon modifiers:
Any character except a modifier after a colon (:) signals the end of modifications. The Spectre simulator appends both the colon and the character to the filename.
The Spectre simulator applies a chain of colon modifiers in the sequence you specify them. For example, if you apply %C:e.%C:r:t to the input filename /circuits/opamp.ckt
%C:e is the extension (ckt) of the input filename
%C:r is the root (/circuits/opamp) of the input filename
:t is the tail of the input filename after the last / (opamp.ckt)
The result is the output filename ckt.opamp.
:t and :r return the whole filename, and the modifier :h returns a period.Examples of Colon Modifier Use
The following table shows the various filenames you can generate from an input filename (%C) of /users/maxwell/circuits/opamp.ckt:
Return to top