Documentation

generatetbstimulus

Generate HDL test bench stimulus

Syntax

dataIn = generatetbstimulus(filtSO,'InputDataType',nt)
dataIn = generatetbstimulus(filterObj)
dataIn = generatetbstimulus(___,Name,Value)

Description

example

dataIn = generatetbstimulus(filtSO,'InputDataType',nt) generates a test bench stimulus for the specified filter System object™ and the input data type, specified by nt.

The coder chooses a default set of stimuli, depending on your filter type. The default set is {'impulse','step','ramp','chirp','noise'}. For IIR filters, 'impulse' and 'step' are excluded.

dataIn = generatetbstimulus(filterObj) generates a test bench stimulus for the specified dfilt filter object.

dataIn = generatetbstimulus(___,Name,Value) uses optional name-value pair arguments, in addition to any of the input arguments in previous syntaxes. Use these options to change the default set of stimuli used by the coder.

Examples

collapse all

Design a lowpass filter and construct a direct-form FIR filter System object™, fir_lp .

filtdes = fdesign.lowpass('N,Fc,Ap,Ast',30,0.4,0.05,0.03,'linear');
fir_lp = design(filtdes,'FilterStructure','dffir','SystemObject',true);

Generate test bench input data. The call to generatetbstimulus generates ramp and chirp stimuli and returns the results. Specify the fixed-point input data type as a numerictype object.

rc_stim = generatetbstimulus(fir_lp,'InputDataType',numerictype(1,12,10),'TestBenchStimulus',{'ramp','chirp'});

Apply the quantized filter to the data and plot the results. The call to the step function computes the filtered response to the input stimulus. The input data for the step function must be a column-vector to indicate samples over time. A row-vector would represent independent data channels.

plot(step(fir_lp,rc_stim'))

Input Arguments

collapse all

Filter for which to generate a test bench stimulus, specified as a filter System object. For an overview of supported filter types, see Generate HDL from Filter System Objects. To create a filter System object, use its constructor or the design function.

Input data type, specified as a numerictype object. This argument applies only when the input filter is a System object. Call numerictype(s,w,f), where s is 1 for signed and 0 for unsigned, w is the word length in bits, and f is the number of fractional bits.

Filter for which to generate a test bench stimulus, specified as a dfilt object. You can create this object by using the design function. For an overview of supported filter features, see Filter Configuration Options.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'TestBenchStimulus',{'ramp','impulse'}

collapse all

Input stimuli that the generated test bench applies to the filter, specified as the comma-separated pair consisting of 'TestBenchStimulus' and 'impulse', 'step', 'ramp', 'chirp', or 'noise'. You can specify combinations of these stimuli in a cell array, in any order.

You can also specify a custom input vector by using the TestBenchUserStimulus property. When TestBenchUserStimulus is a non-empty vector, it takes priority over TestBenchStimulus.

Example: 'TestBenchStimulus',{'ramp','impulse','noise'}

Custom vector of input data that the generated test bench applies to the filter, specified as the comma-separated pair consisting of 'TestBenchUserStimulus' and the empty vector or a function call that returns a vector. When this argument is set to the empty vector, the test bench uses the TestBenchStimulus property to generate input data.

For example, this function call generates a square wave with a sample frequency of 8 bits per second (Fs/8).

repmat([1 1 1 1 0 0 0 0],1,10)
Specify this stimulus when you call generatetbstimulus.
generatetbstimulus(filt,'InputDataType',numerictype(1,16,15), ...
    'GenerateHDLTestbench','on', ...
    'TestBenchUserStimulus',repmat([1 1 1 1 0 0 0 0],1,10))

Output Arguments

collapse all

Test bench stimulus for the filter, returned as a single, double, or fi array. If the input filter is a dfilt filter object, the results are quantized using the arithmetic property of the filter object. If the input filter is a filter System object, the stimulus is quantized by nt.

Introduced before R2006a

Was this topic helpful?