Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Generate HDL Code for Multichannel FIR Filter

This example demonstrates how to generate HDL code for a discrete FIR filter with multiple input data streams.

In many DSP applications, multiple data streams are filtered by the same filter. The straightforward solution is to implement a separate filter for each channel. If possible, a more area-efficient structure can be applied by sharing one filter implementation among multiple channels. The resulting hardware requires a faster clock with respect to the sample rate for a single channel filter.

Prerequisites

You require an HDL Coder™ license to run this example.

Model Multichannel FIR Filter

Enter the following commands to open the example model:

modelname = 'dspmultichannelhdl';
open_system(modelname);

Consider a two-channel FIR filter. The input data vector includes two streams of sinusoidal signal with different frequencies. The input data streams are processed by a lowpass filter, whose coefficients are specified by the Model Properties InitFcn Callback function.

Enter the following commands to specify the fully parallel architecture implementation to the Discrete FIR Filter block:

systemname = [modelname '/Multichannel FIR Filter'];
blockname = [systemname '/Discrete FIR Filter'];
set_param(blockname,'FilterStructure','Direct form symmetric');
hdlset_param(blockname, 'Architecture', 'Fully Parallel');

Enter the following commands to allow for resource sharing among multiple channels:

hdlset_param(blockname, 'ChannelSharing', 'On');

You can also specify these settings on the HDL Block Properties menu.

Simulation Results

Enter the following command to run the example model:

sim(modelname);

Enter the following command to open the scope:

open_system([modelname '/Scope']);

Compare the two output data streams.

Enter the following command to close the scope:

close_system([modelname '/Scope']);

Generate HDL Code and Test Bench

Get a unique temporary directory name for the generated files:

workingdir = tempname;

You can enter the following command to validate the parameter settings of the Multichannel FIR Filter block:

checkhdl(systemname,'TargetDirectory',workingdir);

Enter the following command to generate HDL code:

makehdl(systemname,'TargetDirectory',workingdir);
### Generating HDL for 'dspmultichannelhdl/Multichannel FIR Filter'.
### Starting HDL check.
### The code generation and optimization options you have chosen have introduced additional pipeline delays.
### The delay balancing feature has automatically inserted matching delays for compensation.
### The DUT requires an initial pipeline setup latency. Each output port experiences these additional delays.
### Output port 0: 2 cycles.
### Begin VHDL Code Generation for 'dspmultichannelhdl'.
### MESSAGE: The design requires 2 times faster clock with respect to the base rate = 0.0005.
### Working on dspmultichannelhdl/Multichannel FIR Filter/Discrete FIR Filter as /tmp/BR2016bd_418663_21018/publish_examples1/tp4ea903a0_1905_49a8_bc49_c3cb36a12f7f/dspmultichannelhdl/Discrete_FIR_Filter.vhd.
### Working on Multichannel FIR Filter_tc as /tmp/BR2016bd_418663_21018/publish_examples1/tp4ea903a0_1905_49a8_bc49_c3cb36a12f7f/dspmultichannelhdl/Multichannel_FIR_Filter_tc.vhd.
### Working on dspmultichannelhdl/Multichannel FIR Filter as /tmp/BR2016bd_418663_21018/publish_examples1/tp4ea903a0_1905_49a8_bc49_c3cb36a12f7f/dspmultichannelhdl/Multichannel_FIR_Filter.vhd.
### Generating package file /tmp/BR2016bd_418663_21018/publish_examples1/tp4ea903a0_1905_49a8_bc49_c3cb36a12f7f/dspmultichannelhdl/Multichannel_FIR_Filter_pkg.vhd.
### Creating HDL Code Generation Check Report file:///tmp/BR2016bd_418663_21018/publish_examples1/tp4ea903a0_1905_49a8_bc49_c3cb36a12f7f/dspmultichannelhdl/Multichannel_FIR_Filter_report.html
### HDL check for 'dspmultichannelhdl' complete with 0 errors, 0 warnings, and 1 messages.
### HDL code generation complete.

Enter the following command to generate the test bench:

makehdltb(systemname,'TargetDirectory',workingdir);
### Begin TestBench generation.
### Generating HDL TestBench for 'dspmultichannelhdl/Multichannel FIR Filter'.
### Begin simulation of the model 'gm_dspmultichannelhdl'...

### Collecting data...
### Generating test bench data file: /tmp/BR2016bd_418663_21018/publish_examples1/tp4ea903a0_1905_49a8_bc49_c3cb36a12f7f/dspmultichannelhdl/In1.dat.
### Generating test bench data file: /tmp/BR2016bd_418663_21018/publish_examples1/tp4ea903a0_1905_49a8_bc49_c3cb36a12f7f/dspmultichannelhdl/Out1_expected.dat.
### Working on Multichannel_FIR_Filter_tb as /tmp/BR2016bd_418663_21018/publish_examples1/tp4ea903a0_1905_49a8_bc49_c3cb36a12f7f/dspmultichannelhdl/Multichannel_FIR_Filter_tb.vhd.
### Generating package file /tmp/BR2016bd_418663_21018/publish_examples1/tp4ea903a0_1905_49a8_bc49_c3cb36a12f7f/dspmultichannelhdl/Multichannel_FIR_Filter_tb_pkg.vhd.
### HDL TestBench generation complete.
 

Compare Resource Utilization

You can enter the following command to show resource report with channel sharing:

makehdl(systemname,'TargetDirectory',workingdir, 'resource', 'on');

You can enter the following command to show resource report without channel sharing:

hdlset_param(blockname, 'ChannelSharing', 'Off'); makehdl(systemname,'TargetDirectory',workingdir, 'resource', 'on');

You can see the different resource utilization by comparing the two reports:

This ends the Generate HDL Code for Multichannel FIR Filter example.


Was this topic helpful?