二维矩阵 - 严重警告 (127005):内存深度

2D Matrix - Critical Warning (127005): Memory depth

我想创建一个二维常量数组作为可综合的 Verilog 代码。

这适用于向 DAC 提供正弦波值的模块。

reg [7:0] sine [0:19];

initial begin
    sine[0] = 8'd0;
    sine[1] = 8'd6;
    sine[2] = 8'd24;
    sine[3] = 8'd53;
    sine[4] = 8'd88;
    sine[5] = 8'd127;
    sine[6] = 8'd167;
    sine[7] = 8'd202;
    sine[8] = 8'd231;
    sine[9] = 8'd249;
    sine[10] = 8'd255;
    sine[11] = 8'd249;
    sine[12] = 8'd231;
    sine[13] = 8'd202;
    sine[14] = 8'd167;
    sine[15] = 8'd127;
    sine[16] = 8'd88;
    sine[17] = 8'd53;
    sine[18] = 8'd24;
    sine[19] = 8'd6;
end

当我编译代码时没有错误,但是出现了这个严重警告:

Critical Warning (127005): Memory depth (32) in the design file differs from memory depth (20) in the Memory Initialization File "__.hdl.mif" -- setting initial value for remaining addresses to 0

内存初始化文件:

-- begin_signature
-- DAC_SINE
-- end_signature
WIDTH=8;
DEPTH=20;

ADDRESS_RADIX=UNS;
DATA_RADIX=BIN;

CONTENT BEGIN
    19 :    00000110;
    18 :    00011000;
    17 :    00110101;
    16 :    01011000;
    15 :    01111111;
    14 :    10100111;
    13 :    11001010;
    12 :    11100111;
    11 :    11111001;
    10 :    11111111;
    9 :     11111001;
    8 :     11100111;
    7 :     11001010;
    6 :     10100111;
    5 :     01111111;
    4 :     01011000;
    3 :     00110101;
    2 :     00011000;
    1 :     00000110;
    0 :     00000000;
END;

我怎样才能避免这个严重警告?我必须使用最小内存深度吗?

推断的内存设备通常基于一些最小内存大小的量子,这取决于所使用的芯片架构。假设推断的内存确实被推断到 32 的深度,警告本身证明了这一点,我认为最好的行动方案是如下修改 MIF。因此内存将被完全初始化,并且警告检查得到满足。

-- begin_signature
-- DAC_SINE
-- end_signature
WIDTH=8;
DEPTH=32;

ADDRESS_RADIX=UNS;
DATA_RADIX=BIN;

CONTENT BEGIN
    31 :    00000000;
    30 :    00000000;
    29 :    00000000;
    28 :    00000000;
    27 :    00000000;
    26 :    00000000;
    25 :    00000000;
    24 :    00000000;
    23 :    00000000;
    22 :    00000000;
    21 :    00000000;
    20 :    00000000;
    19 :    00000110;
    18 :    00011000;
    17 :    00110101;
    16 :    01011000;
    15 :    01111111;
    14 :    10100111;
    13 :    11001010;
    12 :    11100111;
    11 :    11111001;
    10 :    11111111;
    9 :     11111001;
    8 :     11100111;
    7 :     11001010;
    6 :     10100111;
    5 :     01111111;
    4 :     01011000;
    3 :     00110101;
    2 :     00011000;
    1 :     00000110;
    0 :     00000000;
END;

我用 System Verilog 替换了 Verilog 模块,它现在将值存储为 2D 数组位参数(值不变)。通过此修改,编译时不会出现严重警告。

parameter bit [7:0] sine [0:19] = '{8'd0, 8'd6, 8'd24, 8'd53, 8'd88, 8'd127, 8'd167, 8'd202, 8'd231, 8'd249, 8'd255, 8'd249, 8'd231, 8'd202, 8'd167, 8'd128, 8'd88, 8'd53, 8'd24, 8'd6};