Guidelines for Using Selector Blocks to Extract Input Elements from Vector or Matrix Signals
Follow these guidelines when you want to select input elements from vector or matrix signals using Selector blocks.
Each guideline has a severity level that indicates the level of compliance requirements. To learn more, see HDL Modeling Guidelines Severity Levels.
Guideline ID
2.3.3
Severity
Recommended
Description
To extract scalar or partial vector input elements from vector or matrix signals in a model that you want to use for HDL Code generation, use Selector, Multiport Selector (DSP System Toolbox) or Index Vector blocks. Use these parameter settings:
Intended Usage | Recommended Block | Block Parameter Settings | For Vector Inputs | For Matrix Inputs |
---|---|---|---|---|
Extracting one signal from vector or matrix inputs with a fixed or variable output range | Selector | Index mode:
Index
option: Select index options with
| Set the Number of input dimensions
to The Selector block output is a:
| Set the Number of input dimensions to 2. The Selector output is a:
|
Extracting multiple signals from a vector signal with a fixed output range | Multiport Selector (DSP System Toolbox) | Specify multiple subsets of scalar or vector indices to the Indices to output parameter. Example: { The block uses one-based indexing. | The block generates output signal for each index set respectively. Depending on whether each index set is a scalar or a vector, the corresponding output port is also a scalar or vector signal. | HDL code generation is not supported for matrix input. To extract multiple ranges from a matrix, convert the matrix input signal to a vector. |
Extracting only one element as a signal from a vector signal | Index Vector | Data port order: Number of data
ports: HDL Block PropertyCoding
Style: Set to
| You can select only one element in the input vector. The block output is a scalar signal. | Simulation and HDL code generation are not supported for matrix inputs. |
Modeling Considerations
Although you can use the Variable Selector block when the extraction range is variable and the inputs and outputs are vectors, the HDL code generated from this block has an
if-elseif
structure, and is therefore not recommended for this configuration.When you use Selector and Variable Selector blocks that has variable extraction range, you must use a built-in data type such as
uint8
as an input to the Index port(Idx). This may cause small redundant circuit.Selector and Multiport Selector blocks support zero-based indices. When you use Selector or Multiport Selector blocks to select multiple elements, vector or matrix signal is output from one port. Though the HDL code generated from a Selector that uses zero-based index and Multiport Selector are the same, the code from Selector block has better traceability because it keeps the same indices between the model and the generated code.
Although the MATLAB code only supports one-based indices, the generated HDL code uses zero-based indexes. When you use Selector block to extract multiple sets of elements, these sets are output from multiple output ports in the generated HDL code.
See Also
Selector | Multiport Selector (DSP System Toolbox) | Index Vector