Main Content

generatetbstimulus

Generate HDL test bench stimulus

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 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. To create a filter System object, use the design function or see the reference page of the object. You can use the following System objects from DSP System Toolbox™:

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 Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

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

Input stimuli that the generated test bench applies to the filter, specified as 'impulse', 'step', 'ramp', 'chirp', or 'noise'. You can specify combinations of these stimuli in a cell array of character vectors or string 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 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), ...
    '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.

Version History

Introduced before R2006a