使用定点toolboxt来模拟DSP的行为

时间:2014-11-15 15:51:25

标签: matlab fixed-point

我正在使用ADI公司的DSP,我想对算法进行一些模拟。从此我指定了我的架构:

F = fimath('MaxProductWordLength', 40, ...
    'MaxSumWordLength', 40, ...
    'OverflowAction', 'Saturate', ...
    'ProductMode', 'KeepLSB', ...
    'RoundingMethod', 'Floor', ...
    'SumMode', 'KeepLSB', ...
    'SumFractionLength', 8, ...
    'SumFixedExponent', 40, ...
    'ProductFixedExponent', 40, ...    
    'SumWordLength', 40);

R = numerictype(1, 40, 8);

然后我可以声明一些数字并进行乘法运算:

a = fi(32.25, R, F);
b = fi(1234, R, F);
c = fi(0.1, R, F);
a*b+c

输出的格式如下:

        WordLength: 40
    FractionLength: 16

如何强制Matlab将数字保留在指定类型(Q32.8)?

a*b发生同样的问题:

ans = 
3.2768e+04
      DataTypeMode: Fixed-point: binary point scaling
        Signedness: Signed
        WordLength: 32
    FractionLength: 16

    RoundingMethod: Floor
    OverflowAction: Saturate
       ProductMode: KeepLSB
 ProductWordLength: 32
           SumMode: KeepLSB
     SumWordLength: 40
     CastBeforeSum: true

我不想要Q16.16而是Q40.8 ......

1 个答案:

答案 0 :(得分:0)

ProductWordLength:32

尝试将其更改为40?

我不确定这款处理器,但有些处理器有多次移位,所以通常我会使用较短的产品长度来模拟乘法和移位。