Main Content

realizeModel

Create Simulink block equivalent for CIC rate conversion filter objects

Since R2024a

Description

example

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 resulting subsystem block parameters.

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 pair arguments.

If you set the UseLibraryBlocks property to false, the function generates an equivalent subsystem implementation 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. By default, UseLibraryBlocks is set to true in which case the function generates the library block equivalent instead.

Using name-value pair arguments lets you control more fully the way the function generates the equivalent Simulink implementation. You can customize the block name, destination, and even optimize the block structure.

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 using the realizeModel function. By default, the UseLibraryBlocks property is set to true.

The function creates a new Simulink® model and adds this library block to the model. The block name is Filter.

realizeModel(cicDecim)

realizedmodel_cicdecim.png

When you click on 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 property to false. This property determines the implementation of the realized block.

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

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

newsubsystem.png

When you click on 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 using the realizeModel function. Specify the function to place this block in an existing model. Name the block as CIC Interpolator. Change InputProcessing to "Sample based" and specify RateOptions to "multirate".

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 default fixed-point type fixdt(1,16,15). You can customize this data type by passing a custom fixed-point input signal to the dsp.CICInterpolator object algorithm.

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

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 same as the input data type.

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 to the input CIC rate conversion filter object.

  • false –– The function implements the input CIC rate conversion 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. By default, the generated block has the name Filter. If a block with this name already exists in the current 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.

Dependencies

To use this property, 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 as a separate channel. In this mode, the block always performs single-rate processing.

  • "Sample based" –– The block treats each element of the input 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.

Dependencies

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