Main Content

realizeModel

Create Simulink block equivalent of CIC rate conversion filter objects

Since R2024a

Description

realizeModel(cicObj) generates a Simulink® library block equivalent of the dsp.CICDecimator and dsp.CICInterpolator objects. The properties and values of these objects define the parameters of the resulting block.

When cicObj is a dsp.CICDecimator object, the realizeModel function generates a CIC Decimation block. When cicObj is a dsp.CICInterpolator object, the realizeModel function generates a CIC Interpolation block.

Note

This function requires a Fixed-Point Designer™ license.

example

realizeModel(cicObj,Name=Value) generates a Simulink library block for cicObj with additional options specified by one or more name-value arguments.

The value of the UseLibraryBlocks argument determines how the function implements the realized block. The value of this argument is true by default, so the function generates the library block equivalent of the object with default settings. If you set the UseLibraryBlocks argument to false, the function generates a subsystem equivalent of a CIC rate converter using the Add (Simulink), Delay (Simulink), and Data Type Conversion (Simulink) blocks. To model rate conversion operations, the function uses the Downsample and Upsample blocks.

Use the name-value arguments to control how the function generates the equivalent Simulink implementation. You can use these arguments to customize the block name, destination, and even optimize the block structure.

example

Examples

collapse all

Create a dsp.CICDecimator object with custom fixed-point settings.

cicDecim = dsp.CICDecimator(5,2,3,...
    FixedPointDataType="Specify word lengths",...
    SectionWordLengths=18*ones(1,6))
cicDecim = 
  dsp.CICDecimator with properties:

      DecimationFactor: 5
     DifferentialDelay: 2
           NumSections: 3
    FixedPointDataType: 'Specify word lengths'
    SectionWordLengths: [18 18 18 18 18 18]
      OutputWordLength: 32

Realize the equivalent library block by using the realizeModel function. Because the value of the UseLibraryBlocks argument is true by default, the function creates a block named Filter and adds it to a new Simulink model.

realizeModel(cicDecim)

realizedmodel_cicdecim.png

When you click this block, you can see that the equivalent implementation uses a Data Type Conversion block and a CIC Decimation block.

library_implementation.png

Call the realizeModel function again and set the UseLibraryBlocks argument to false.

The function generates a new subsystem block named Filter1 and adds this block to the existing model. To change the block name, set BlockName to a custom name.

realizeModel(cicDecim,UseLibraryBlocks=false,BlockName="Subsystem")

newsubsystem.png

When you click this block, you can see that the equivalent implementation contains a series of Add, Delay, and Data Type Conversion blocks. To implement the rate conversion, the model uses a Downsample block.

subsystem_implementation.png

Create a dsp.CICInterpolator object with custom fixed-point settings.

cicInterp = dsp.CICInterpolator(5,6,2,...
    FixedPointDataType="Specify word lengths",...
    SectionWordLengths=[20 22 18 16])
cicInterp = 
  dsp.CICInterpolator with properties:

    InterpolationFactor: 5
      DifferentialDelay: 6
            NumSections: 2
     FixedPointDataType: 'Specify word lengths'
     SectionWordLengths: [20 22 18 16]
       OutputWordLength: 32

Realize the equivalent library block by using the realizeModel function. Use the Destination name-value argument to place this block in an existing model. Then, specify the block name, input processing type, and the rate options.

new_system("cicInterpolationModel")
realizeModel(cicInterp,Destination="cicInterpolationModel",...
    UseLibraryBlocks=true,BlockName='CIC Interpolator',...
    InputProcessing="Sample based",RateOptions="multirate");

cicInterpolation_model.png

Click the CIC Interpolator subsystem block.

cicInterpolation_subsystem.png

Open the CIC Interpolation block dialog box. The block dialog box is populated according to the settings of the dsp.CICInterpolator object and the realizeModel function.

blockdialog.png

The Input Quantizer block casts the input data to the fixdt(1,16,15) data type by default. You can customize this data type by passing a custom fixed-point input signal to the dsp.CICInterpolator object.

Create fixed-point data with a word length of 21 and a fraction length of 12. Pass this data to the dsp.CICInterpolator object.

u = fi(ones(5,1),1,21,12);
y = cicInterp(u);

Now, realize the model again. Specify a new name to this block.

realizeModel(cicInterp,Destination="cicInterpolationModel",...
    UseLibraryBlocks=true,BlockName='Custom Input Type',...
    InputProcessing="Sample based",RateOptions="multirate")

cicInterpolation_newsubsystem.png

Click the Custom Input Type > Input Quantizer block. You can see that this block now casts the input data to fixdt(1,21,12), which is the data type of the input data.

Input Arguments

collapse all

Input CIC rate conversion filter System object™, specified as one of these:

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.

Example: c = dsp.CICDecimator; realizeModel(c,UseLibraryBlocks=false,Optimize=true);

Implementation of the realized model, specified as one of these options:

  • true –– The function generates a library block equivalent of the input CIC rate conversion filter object.

  • false –– The function generates a subsystem equivalent of the input CIC rate conversion filter object. The function implements the filter object using the Add (Simulink), Delay (Simulink), and Data Type Conversion (Simulink) blocks. To model the rate conversion operations, the function uses the Downsample and Upsample blocks.

Data Types: logical

Destination model to which the function adds the realized block, specified as one of these options:

  • "current" –– Add the block to your current Simulink model.

  • "new" –– Add the block to a new Simulink model.

  • Character vector or string scalar –– Add the block to the specified model or subsystem that already exists.

Data Types: char | string

Name of the block that the realizeModel function generates, specified as a character vector or a string scalar. The function names the block Filter. If a block with this name already exists in the specified destination, the function updates the name to Filter#.

Data Types: char | string

Option to overwrite existing block, specified as one of these options:

  • false –– Create a new block.

  • true –– Overwrite an existing block with the same name.

Data Types: logical

Option to optimize these elementary operations in the block implementation:

  • Remove zero-gain blocks.

  • Replace unity-gain blocks with direct connections.

  • Replace negative unity-gain blocks with a sign change at the nearest sum block.

  • Replace delay chains made up of n unit delays with a single delay by n.

To use this argument, set UseLibraryBlocks to false.

Method to process input signals, specified as one of these options:

  • "Frame based" –– The block treats each column of the input signal as a separate channel. In this mode, the block always performs single-rate processing.

  • "Sample based" –– The block treats each element of the input signal as a separate channel. In this mode, the input to the block must be a scalar or a vector. You can use the RateOption property to specify whether the block performs single-rate or multirate processing.

To use this property,

Rate processing rule, specified as one of these options:

  • "single-rate" –– The block maintains the sample rate of the input.

  • "multirate" –– The block produces an output with a sample rate that is R times faster than the input sample rate. To select this option, you must set the InputProcessing property to "Sample based".

Dependencies

To use this property,

  • Set UseLibraryBlocks to true.

  • Specify the input filter to be a dsp.CICInterpolator object.

  • Set InputProcessing to "Sample based".

Version History

Introduced in R2024a