# dsphdl.Channelizer

Polyphase filter bank and fast Fourier transform

## Description

The `dsphdl.Channelizer` System object™ separates a broadband input signal into multiple narrowband output signals. It provides hardware speed and area optimization for streaming data applications. The object accepts scalar or vector input of real or complex data, provides hardware-friendly control signals, and has optional output frame control signals. You can achieve gigasamples-per-second (GSPS) throughput by using vector input. The object implements a polyphase filter, with one subfilter per input vector element. The hardware implementation interleaves the subfilters, which results in sharing each filter multiplier (FFT Length / Input Size) times. The object implements the same pipelined Radix 2^2 FFT algorithm as the `dsphdl.FFT` System object.

To channelize input data:

1. Create the `dsphdl.Channelizer` object and set its properties.

2. Call the object with arguments, as if it were a function.

## Creation

### Syntax

``channelizer = dsphdl.Channelizer``
``channelizer = dsphdl.Channelizer(Name,Value)``

### Description

````channelizer = dsphdl.Channelizer` returns a System object, `channelizer`, that implements a raised-cosine filter and an 8-point FFT.```

example

````channelizer = dsphdl.Channelizer(Name,Value)` sets properties using one or more name-value pairs. Enclose each property name in single quotes.```

## Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the `release` function unlocks them.

If a property is tunable, you can change its value at any time.

FFT length, specified as an integer power of two. For HDL code generation, the FFT length must be between 22 and 216, inclusive.

Polyphase filter coefficients, specified as a vector of numeric values. If the number of coefficients is not a multiple of `NumFrequencyBands`, the object pads this vector with zeros. The default filter specification is a raised-cosine FIR filter, `rcosdesign(0.25,2,4,'sqrt')`. You can specify a vector of coefficients or a call to a filter design function that returns the coefficient values. By default, the object casts the coefficients to the same data type as the input.

Specify the HDL filter architecture as one of these structures:

• `Direct form transposed` — This architecture is a fully parallel implementation that is suitable for FPGA and ASIC applications. For architecture and performance details, see Fully Parallel Transposed Architecture.

• `Direct form systolic` — This architecture provides a fully parallel filter implementation that makes efficient use of Intel® and Xilinx® DSP blocks. For architecture and performance details, see Fully Parallel Systolic Architecture.

HDL implementation of complex multipliers, specified as either ```'Use 4 multipliers and 2 adders'``` or ```'Use 3 multipliers and 5 adders'```. Depending on your synthesis tool and target device, one option may be faster or smaller.

Size of output data, specified as:

• `'Same as number of frequency bands'` — Output data is a 1-by-M vector, where M is the FFT length.

• `'Same as input size'` — Output data is an M-by-1 vector, where M is the input vector size.

The output order is bit natural for both output sizes.

FFT output scaling, specified as either:

• `true` — The FFT implements an overall 1/N scale factor by scaling the result of each pipeline stage by 2. This adjustment keeps the output of the FFT in the same amplitude range as its input.

• `false` — The FFT avoids overflow by increasing the word length by one bit at each stage.

Rounding mode used for fixed-point operations. The object uses fixed-point arithmetic for internal calculations when the input is any integer or fixed-point data type. This option does not apply when the input is `single` or `double`. Each FFT stage rounds after the twiddle factor multiplication but before the butterflies. Rounding can also occur when casting the coefficients and the output of the polyphase filter to the data types you specify.

Overflow Handling used for fixed-point operations. The object uses fixed-point arithmetic for internal calculations when the input is any integer or fixed-point data type. This option does not apply when the input is `single` or `double`. This option applies to casting the coefficients and the output of the polyphase filter to the data types you specify.

The FFT algorithm avoids overflow by either scaling the output of each stage (`Normalize` enabled), or by increasing the word length by 1 bit at each stage (`Normalize` disabled).

The object casts the polyphase filter coefficients to this data type, using the rounding and overflow settings you specify. When you specify ```'Same word length as input'``` (default), the object selects the binary point using `fi()` best-precision rules.

Data type of the output of the polyphase filter, specified as ```'Same word length as input'```, `'Full precision'`, or a `numerictype` object. The object casts the output of the polyphase filter (the input to the FFT) to this data type, using the rounding and overflow settings you specify. When you specify `'Full precision'`, the object selects a best-precision binary point by considering the values of your filter coefficients and the range of your input data type.

By default, the FFT logic does not change the data type. When you disable `Normalize`, the FFT algorithm avoids overflow by increasing the word length by 1 bit at each stage.

Enable `reset` input argument to the object. When `reset` is `1` (true), the object stops the current calculation and clears internal states. When the `reset` is `0` (false) and the input `valid` is `1` (true), the object captures data for processing.

Enable `startOut` output argument of the object. When enabled, the object returns an additional output signal that is `1` (true) on the first cycle of each valid output frame.

Enable `endOut` output argument of the object. When enabled, the object returns an additional output signal that is `1` (true) on the first cycle of each valid output frame.

## Usage

### Syntax

``````[dataOut,validOut] = channelizer(dataIn,validIn)``````
``````[dataOut,validOut] = channelizer(dataIn,validIn,reset)``````
``````[dataOut,startOut,endOut,validOut] = channelizer(___)``````

### Description

example

``````[dataOut,validOut] = channelizer(dataIn,validIn)``` filters and computes a fast Fourier transform, and returns the frequency channels, `dataOut`, detected in the input signal, `dataIn`, when `validIn` is `1` (true). The `validIn` and `validOut` arguments are logical scalars that indicate the validity of the input and output signals, respectively.```
``````[dataOut,validOut] = channelizer(dataIn,validIn,reset)``` returns the frequency channels, `dataOut`, detected in the input signal, `dataIn`, when `validIn` is `1` (true) and `reset` is `0` (false). When `reset` is `1` (true), the object stops the current calculation and clears all internal state. To use this syntax, set the `ResetInputPort` property to `true`. For example: channelizer = dsphdl.Channelizer(...,'ResetInputPort',true); ... [dataOut,validOut] = channelizer(dataIn,validIn,reset)```
``````[dataOut,startOut,endOut,validOut] = channelizer(___)``` returns the frequency channels, `dataOut`, computed from the input arguments of any of the previous syntaxes. `startOut` is `1` (true) for the first sample of a frame of output data. `endOut` is `1` (true) for the last sample of a frame of output data. To use this syntax, set the `StartOutputPort` and `EndOutputPort` properties to `true`. For example: channelizer = dsphdl.Channelizer(...,'StartOutputPort',true,'EndOutputPort',true); ... [dataOut,startOut,endOut,validOut] = channelizer(dataIn,validIn)```

### Input Arguments

expand all

Input data, specified as a scalar or column vector of real or complex values.

The vector size must be a power of 2 and in the range [2, 64], and is not greater than the number of channels (FFT length).

The software supports `double` and `single` data types for simulation, but not for HDL code generation.

The object does not accept `uint64` data.

Data Types: `fi` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `single` | `double`
Complex Number Support: Yes

Control signal that indicates if the input data is valid. When `validIn` is `1` (`true`), the object captures the values from the `dataIn` argument. When `validIn` is `0` (`false`), the object ignores the values from the `dataIn` argument.

Data Types: `logical`

Control signal that clears internal states. When `reset` is `1` (`true`), the object stops the current calculation and clears internal states. When the `reset` is `0` (`false`) and the input `valid` is `1` (`true`), the block captures data for processing.

For more reset considerations, see the Reset Signal section on the Hardware Control Signals page.

#### Dependencies

To enable this argument, set `ResetInputPort` to `true`.

Data Types: `logical`

### Output Arguments

expand all

Frequency channel output data, returned as a row vector.

• If you set `OutputSize` to ```'Same as number of frequency bands'``` (default), the output data is a 1-by-M vector, where M is the FFT length.

• If you set `OutputSize` to ```'Same as input size'```, the output data is an M-by-1 vector, where M is the input vector size.

The output order is bit natural for either output size. The data type is a result of the `FilterOutputDataType` and the FFT bit growth necessary to avoid overflow.

Control signal that indicates if the output data is valid. When `validOut` is `1` (`true`), the object returns valid data from the `dataOut` argument. When `validOut` is `0` (`false`), values from the `dataOut` argument are not valid.

Data Types: `logical`

First sample of output frame, returned as a logical scalar. The object sets `startOut` to `1` (true) during the first valid sample on `dataOut`.

#### Dependencies

To enable this argument, set `StartOutputPort` to `true`.

Data Types: `logical`

Last sample of output frame, returned as a logical scalar. The object sets `endOut` to `1` (true) during the last valid sample on `dataOut`.

#### Dependencies

To enable this argument, set `EndOutputPort` to `true`.

Data Types: `logical`

## Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named `obj`, use this syntax:

`release(obj)`

expand all

 `getLatency` Latency of channelizer calculation
 `step` Run System object algorithm `release` Release resources and allow changes to System object property values and input characteristics `reset` Reset internal states of System object

## Examples

collapse all

Create a function that contains a channelizer object and supports HDL code generation.

Create the specifications and input signal. The signal has 8 frequency channels.

```N = 8; loopCount = 1024; offsets = [-40 -30 -20 10 15 25 35 -15]; sinewave = dsp.SineWave('ComplexOutput',true,'Frequency', ... offsets+(-375:125:500),'SamplesPerFrame',loopCount); sa = spectrumAnalyzer('ShowLegend',true, ... 'SampleRate',sinewave.SampleRate/N); ```

Write a function that creates and calls the channelizer System object™. You can generate HDL from this function.

```function [yOut,validOut] = HDLChannelizer8(yIn,validIn) %HDLChannelizer8 % Process one sample of data using the dsphdl.Channelizer System object % yIn is a fixed-point scalar or column vector. % validIn is a logical scalar value. % You can generate HDL code from this function. persistent channelize8; coder.extrinsic('tf'); coder.extrinsic('dsp.Channelizer'); if isempty(channelize8) % Use filter coeffs from non-HDL channelizer, or supply your own. channelizer = coder.const(dsp.Channelizer('NumFrequencyBands',8)); coeff = coder.const(tf(channelizer)); channelize8 = dsphdl.Channelizer('NumFrequencyBands',8,'FilterCoefficients',coeff); end [yOut,validOut] = channelize8(yIn,validIn); end ```

Channelize the input data by calling the object for each data sample.

```y = zeros(loopCount/N,N); validOut = false(loopCount/N,1); yValid = zeros(loopCount/(N*N),N); for reps=1:30 x = fi(sum(sinewave(),2),1,18); for loop=1:length(x) [y(loop,:),validOut(loop)]= HDLChannelizer8(x(loop),true); end yValid = y(validOut == 1,:); sa(yValid); end ``` The latency of the `dsphdl.Channelizer` object varies with the FFT length, filter structure, vector size, and input type. Use the `getLatency` function to find the latency of a particular configuration. The latency is measured as the number of cycles between the first valid input and the first valid output, assuming that the input is contiguous. The number of filter coefficients does not affect the latency. Setting the output size equal to the input size reduces the latency because the samples are not saved and reordered.

Create a `dsphdl.Channelizer` object with filter structure set to direct form transposed and request the latency.

```channelize = dsphdl.Channelizer('NumFrequencyBands',512, 'FilterStructure','Direct form transposed'); L512 = getLatency(channelize)```
```L512 = 1118 ```

Request hypothetical latency information about a similar object with a different number of frequency bands (FFT length). The properties of the original object do not change.

`L256 = getLatency(channelize,256)`
```L256 = 592 ```
`N = channelize.NumFrequencyBands`
```N = 512 ```

Request hypothetical latency information of a similar object that accepts eight-sample vector input.

`L256v8 = getLatency(channelize,256,8)`
```L256v8 = 132 ```

Enable scaling at each stage of the FFT. The latency does not change.

```channelize.Normalize = true; L512n = getLatency(channelize)```
```L512n = 1118 ```

Request the same output size and order as the input data. The latency decreases because the object does not need to store and reorder the data before output. The default input size is scalar.

```channelize.OutputSize = 'Same as input size'; L512r = getLatency(channelize)```
```L512r = 1084 ```

Check the latency of a vector input implementation where the input and output are the same size. Specify the current value of the FFT length and a vector size of 8 samples. The latency decreases because the object computes results in parallel when the input is a vector.

`L512rv8 = getLatency(channelize,channelize.NumFrequencyBands,8)`
```L512rv8 = 218 ```

Check the latency of a vector input implementation where the input type is complex. Specify the current value of the FFT length and a vector size of 16 samples.

`L512rv16i = getLatency(channelize,channelize.NumFrequencyBands,16,true)`
```L512rv16i = 152 ```

## Algorithms

expand all

This object implements the algorithm described on the Channelizer block reference page.

Note

The output of the `dsphdl.Channelizer` object does not match the output from the `dsp.Channelizer` object sample-for-sample. This mismatch is because the objects apply the input samples to the subfilters in different orders. The `dsphdl.Channelizer` object applies input X(0) to subfilter EM-1(z), X(1) to subfilter EM-2(z), ..., X(M-1) to subfilter E0(z). The channels detected by both objects match, when analyzed over multiple frames.

## Version History

Introduced in R2017a

expand all
{"ft_lang_label":"__label__en","ft_lang_prob":0.6817689,"math_prob":0.94981456,"size":20154,"snap":"2023-14-2023-23","text_gpt3_token_len":4793,"char_repetition_ratio":0.15111662,"word_repetition_ratio":0.19779149,"special_character_ratio":0.21955939,"punctuation_ratio":0.12517346,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9786625,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-06-04T14:37:57Z\",\"WARC-Record-ID\":\"<urn:uuid:996d5df0-d603-492e-8b85-716f4d103932>\",\"Content-Length\":\"163323\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ccadf83a-66ba-4c24-974f-b64e14e30f53>\",\"WARC-Concurrent-To\":\"<urn:uuid:48847917-a42e-4b6b-be47-871e06fcf7fc>\",\"WARC-IP-Address\":\"104.86.80.92\",\"WARC-Target-URI\":\"https://in.mathworks.com/help/dsphdl/ref/dsphdl.channelizer-system-object.html\",\"WARC-Payload-Digest\":\"sha1:DBNDJDXRPELMY2CSBMZZQJOHDSB4G3ZY\",\"WARC-Block-Digest\":\"sha1:RX52RV4BPU5DE4GKCD4ONHPJJWKLX5W7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224649986.95_warc_CC-MAIN-20230604125132-20230604155132-00254.warc.gz\"}"}