VerilogA Reference Manual >Chapter 10: System Tasks and I/O Functions Print version of this Book (PDF file) 



The $table_model FunctionThe interpolation function, $table_model(), allows the module to approximate the behavior of a system by interpolating between usersupplied data points. The user provides a dataset of points (xi1, xi2, .., xiN, yi) such that f(xi1, xi2, .., xiN) = yi, where f is the model function and N is the number of independent variables of the model. These data points are stored in a text file and are accessed during the analysis by the VerilogA module. The interpolation algorithm then approximates the true model behavior at any point in the domain of the sampled data. Data points outside of the sampled domain will be approximated via extrapolation of the data within the domain. Extrapolated data can be inaccurate and should be avoided. The VerilogA algorithm is a piecewiselinear interpolation for the $table_model() function. However, higherorder interpolation algorithms may be provided in a future revision of the language. The $table_model() system function has the same restrictions as analog operators. That is, it cannot be used inside of if(), case(), or for() statements unless these statements are controlled by genvarconstant expressions. Syntax
Table Model InputsThe table_inputs are numerical expressions that are used as the independent model variables for the $table_model() function. They may be any valid expressions that can be assigned to an analog signal. Table Data SourceThe table_data_source argument specifies the source of sample points for the $table_model() function. The sample points may come from two sources: files and arrays. The file source indicates that the sample points be stored in a file, while the array source indicates that the data points are stored in a set of array variables. The user may choose the data source by either providing the file name of a file source or a set of array variables as an argument to the function. The table is created when the $table_model() system function is called for the first time. Any changes to the table_data_source argument(s) of the $table_model() after the first call are quietly ignored (that is, the table model is not recreated). For a file source, each sample point of the table is represented as a sequence of numbers in the order of Xi1 Xi2 .. XiN Yi, where Xik is the coordinate of the sample point in k^{th} dimension and Yi is the model value at this sample point. Each sample point must be separated by a new line. The numbers in the sequence must be separated by one or more spaces or tabs. Comments may be inserted before or after any sample point; comments must begin with `#' and end with a new line. The data file must be in text format only. The numbers must be real or integer. The sample points can be stored in the file in any order. ExampleThe following example shows the contents of a table model files with two dimensions.
If the source of the data is an array, a set of onedimensional arrays that contain the data points must be passed to the $table_model() function. The size of these arrays is determined by the number of sample points in the table, M. The data are stored in the arrays such that for the k^{th} dimension of the i^{th} sample point, kth_dim_array_identifier[i] = Xik and such that for the i^{th} sample point output_array_identifier[i] = Yi. ExampleFor the previous table model example, the same data would be provided to the function in an array as shown in the following code fragment.
Table Control StringThe control string provides information on how the model should interpolate and extrapolate the table data. The control string consists of substrings for each dimension. Each substring may contain one character indicating the degree of the spine interpolation and an additional one or two characters indicating the type of extrapolation method to be used. Table Interpolation DegreeThe degree character is an integer between 1 and 3 representing the degrees of splines to be used for the interpolation. If not given, a degree of 1 (linear) is assumed. Table 101 shows the possible settings.
Extrapolation Control StringThe extrapolation control string is used to control the algorithm to extrapolate beyond the supplied data domain. The string may contain one or two extrapolation method characters. The extrapolation method determines the behavior of the table model when the point to be evaluated is beyond the domain of the user provided sample points. The Clamp extrapolation method, specified with the character C, uses a constant value from the last data point to extend the model.The Linear extrapolation method, specified with the character L, uses piecewise linear interpolation to estimate the requested point. The user may also disable extrapolation by setting the Error extrapolation method using the character E. In this case, an extrapolation error is reported if the $table_model() function is requested to evaluate a point beyond the interpolation region. Table 102 summarizes these options.
For each dimension of the table, users may use up to two extrapolation method characters to specify the extrapolation method used for each end of the data set. When no extrapolation method character is supplied, the Linear extrapolation method will be used for both ends as default behavior. When a single extrapolation method character is supplied, the specified extrapolation method will be used for both ends of the data set. When two extrapolation method characters are supplied, the first character specifies the extrapolation method used for the end with the lower coordinate value and the second character specifies the extrapolation method for the end with the higher coordinate value. Table 103 illustrates some control strings and their interpretation.
ExamplesIn the first example, the data from the table defined earlier is contributed across the ports. The data in both dimensions is linearly extrapolated at both ends of the data.
In the second example, the same information is supplied within the module using the array method.



