duc的matlab,HDL Digital Up-Converter (DUC)

Create Pulse Shaping FIR Filter

Create a 32-tap FIR Interpolator with interpolation factor of 2.

pulseShapingFIR = dsp.FIRInterpolator;

pulseShapingFIR.InterpolationFactor = 2;

pulseShapingFIR.Numerator = [...

0.0007 0.0021 -0.0002 -0.0025 -0.0027 0.0013 0.0049 0.0032 ...

-0.0034 -0.0074 -0.0031 0.0060 0.0099 0.0029 -0.0089 -0.0129 ...

-0.0032 0.0124 0.0177 0.0040 -0.0182 -0.0255 -0.0047 0.0287 ...

0.0390 0.0049 -0.0509 -0.0699 -0.0046 0.1349 0.2776 0.3378 ...

0.2776 0.1349 -0.0046 -0.0699 -0.0509 0.0049 0.0390 0.0287 ...

-0.0047 -0.0255 -0.0182 0.0040 0.0177 0.0124 -0.0032 -0.0129 ...

-0.0089 0.0029 0.0099 0.0060 -0.0031 -0.0074 -0.0034 0.0032 ...

0.0049 0.0013 -0.0027 -0.0025 -0.0002 0.0021 0.0007 ];

Create Compensation Fir Filter

Create an 11-tap FIR Interpolator with interpolation factor of 2.

compensationFIR = dsp.FIRInterpolator;

compensationFIR.InterpolationFactor = 2;

compensationFIR.Numerator = [...

-0.0007 -0.0009 0.0039 0.0120 0.0063 -0.0267 -0.0592 -0.0237 ...

0.1147 0.2895 0.3701 0.2895 0.1147 -0.0237 -0.0592 -0.0267 ...

0.0063 0.0120 0.0039 -0.0009 -0.0007];

Create CIC Interpolating Filter

Create a 5-stage CIC Interpolator with interpolation factor of 32.

CICFilter = dsp.CICInterpolator;

CICFilter.InterpolationFactor = 32;

CICFilter.NumSections = 5;

Cascade of the Filters

Create a cascade filter including the above three filters. Check the frequency response of the cascade filter.

DUC = dsp.FilterCascade(pulseShapingFIR, compensationFIR, CICFilter);

fvtool(DUC);

0ae9920c7b9eea4ccc271627d88c1ae1.png

Generate VHDL Code for DUC and Test Bench

Generate synthesizable and portable VHDL code for the cascade filter.

You have the option of generating a VHDL, Verilog, or ModelSim® .do file test bench to verify that the HDL design matches the MATLAB® filter.

To generate Verilog instead of VHDL, change the value of the property 'TargetLanguage', from 'VHDL' to 'Verilog'.

Generate a stimulus signal for the filter. The length of the stimulus should be greater than the total latency of the filter.

Generate a VHDL test bench to verify that the results match the MATLAB results exactly. This is done by passing another property 'GenerateHDLTestbench' and setting its value to 'on'. The stimulus to test bench is specified using the 'TestBenchUserStimulus' property.

Assume 16-bit signed fixed-point input with 15 bits of fraction.

t = 0.005:0.005:1.5;

stim = chirp(t, 0, 1, 150);

workingdir = tempname;

generatehdl(DUC, 'Name', 'hdlduc',...

'TargetLanguage', 'VHDL',...

'TargetDirectory', workingdir, ...

'GenerateHDLTestbench', 'on', ...

'TestBenchUserStimulus', stim, ...

'InputDataType', numerictype(1,16,15));

### Starting VHDL code generation process for filter: hdlduc

### Cascade stage # 1

### Starting VHDL code generation process for filter: hdlduc_stage1

### Generating: /tmp/Bdoc21a_1606923_129538/tp9b56ccda_2776_4620_92d0_b4d9d3bc95da/hdlduc_stage1.vhd

### Starting generation of hdlduc_stage1 VHDL entity

### Starting generation of hdlduc_stage1 VHDL architecture

### Successful completion of VHDL code generation process for filter: hdlduc_stage1

### Cascade stage # 2

### Starting VHDL code generation process for filter: hdlduc_stage2

### Generating: /tmp/Bdoc21a_1606923_129538/tp9b56ccda_2776_4620_92d0_b4d9d3bc95da/hdlduc_stage2.vhd

### Starting generation of hdlduc_stage2 VHDL entity

### Starting generation of hdlduc_stage2 VHDL architecture

### Successful completion of VHDL code generation process for filter: hdlduc_stage2

### Cascade stage # 3

### Starting VHDL code generation process for filter: hdlduc_stage3

### Generating: /tmp/Bdoc21a_1606923_129538/tp9b56ccda_2776_4620_92d0_b4d9d3bc95da/hdlduc_stage3.vhd

### Starting generation of hdlduc_stage3 VHDL entity

### Starting generation of hdlduc_stage3 VHDL architecture

### Section # 1 : Comb

### Section # 2 : Comb

### Section # 3 : Comb

### Section # 4 : Comb

### Section # 5 : Comb

### Section # 6 : Integrator

### Section # 7 : Integrator

### Section # 8 : Integrator

### Section # 9 : Integrator

### Section # 10 : Integrator

### Successful completion of VHDL code generation process for filter: hdlduc_stage3

### Generating: /tmp/Bdoc21a_1606923_129538/tp9b56ccda_2776_4620_92d0_b4d9d3bc95da/hdlduc.vhd

### Starting generation of hdlduc VHDL entity

### Starting generation of hdlduc VHDL architecture

### Successful completion of VHDL code generation process for filter: hdlduc

### HDL latency is 225 samples

### Starting generation of VHDL Test Bench.

### Generating input stimulus

### Done generating input stimulus; length 300 samples.

### Generating Test bench: /tmp/Bdoc21a_1606923_129538/tp9b56ccda_2776_4620_92d0_b4d9d3bc95da/hdlduc_tb.vhd

### Creating stimulus vectors ...

### Done generating VHDL Test Bench.

ModelSim® Simulation Results

The following display shows the ModelSim HDL simulator running these test benches.

DUC response to a chirp stimulus:

c79f7c61a93b9fb34038f7cea2b8b62d.png

Conclusion

In this example, you designed three individual interpolation filters, cascaded them into a Digital-Up Converter, verified the frequency response of the filter, and called Filter Design HDL Coder™ functions to generate VHDL code for the filter and a VHDL test bench to verify the VHDL code against its MATLAB result. The simulation result of the VHDL code proved that the generated VHDL filter produced a bit-true implementation of the MATLAB filter.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值