我想创建一个常量值的二维数组作为可综合的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;
如何避免此严重警告?我必须使用最小内存深度吗?
答案 0 :(得分:0)
推断的存储设备通常将基于最小内存大小的一些量子,这取决于所使用的芯片体系结构。假设推断的内存确实被推断为深度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;
答案 1 :(得分:0)
我用系统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};