我收到有关$ readmemh的警告:文件中的单词太多

发布于 2025-01-27 14:18:50 字数 838 浏览 3 评论 0原文

这是我定义rom模块的方式,

module rom(
    input   wire    [31:0]  inst_addr_i,
    output  reg     [31:0]  inst_o
);

    reg [31:0]  rom_mem[0:100];

    always@(*) begin
        inst_o = rom_mem[inst_addr_i>>2];
    end

endmodule

这是$ redmem in tb.v

initial begin
        $readmemh("inst.data",tb.rv_soc_ins.rom_ins.rom_mem);
end

inst.data文件是这样的,有354行。

00000d13
00000d93
00000093
00000113
00208f33
00000e93
00200193

这是执行vpp脚本时我得到的:

$ vvp a.out 
WARNING: tb.v:23: $readmemh(inst.data): Too many words in the file for the requested range [0:100].
VCD info: dumpfile gtk.vcd opened for output.

尽管在rom.v中,我已经将ROM设置得足够大。

Here is how I define the rom module

module rom(
    input   wire    [31:0]  inst_addr_i,
    output  reg     [31:0]  inst_o
);

    reg [31:0]  rom_mem[0:100];

    always@(*) begin
        inst_o = rom_mem[inst_addr_i>>2];
    end

endmodule

Here is the $readmem in tb.v

initial begin
        $readmemh("inst.data",tb.rv_soc_ins.rom_ins.rom_mem);
end

And the inst.data file is like this, which has 354 rows.

00000d13
00000d93
00000093
00000113
00208f33
00000e93
00200193

This is what I get when executing the vpp script:

$ vvp a.out 
WARNING: tb.v:23: $readmemh(inst.data): Too many words in the file for the requested range [0:100].
VCD info: dumpfile gtk.vcd opened for output.

Although in rom.v, I have set the rom large enough.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别靠近我心 2025-02-03 14:18:50
reg [31:0]  rom_mem[0:100];

以上声明意味着您有一个带有101 32位单词的内存。

  • [0:100]表示内存中有101个位置(地址)。
  • [31:0]表示内存位置(数据)宽32位。

您的inst.data文件中有354行(或行)。您显示的每一行都有一个32位数据字。假设您在文件的其余部分上有一个单词,则文件中有354个单词。

警告消息告诉您,您的rom 不足以适合文件中的所有数据单词。

我在数据文件中添加了一些注释,以说明Verilog对数据的作用:

00000d13 // row 1 data loaded into rom_mem[0]
00000d93 // row 2 data loaded into rom_mem[1]
00000093
00000113
...
11111111 // row 100 data loaded into rom_mem[99]
22222222 // row 101 data loaded into rom_mem[100]
33333333 // row 102 data is discarded
...
ffffffff // row 354 data is discarded

如您所见,只有前101个数据单词加载到内存中。其余的数据单词不使用。

如果您真的希望您的内存是32x101,并且想摆脱警告,那么您可以从第102行开始删除文件的行,也可以指定开始和结束地址:

    $readmemh("inst.data", tb.rv_soc_ins.rom_ins.rom_mem, 0, 101);

如果您真的希望您的内存是32x354,然后您需要更改rom模块:

reg [31:0]  rom_mem[0:353];

请参阅IEEE STD 1800-2017,第21.4节,从文件加载内存阵列数据。

reg [31:0]  rom_mem[0:100];

The above declaration means that you have a memory with 101 32-bit words.

  • [0:100] means there are 101 locations (addresses) in the memory.
  • [31:0] means the memory location (data) is 32 bits wide.

Your inst.data file has 354 rows (or lines) in the file. Each row you showed has one 32-bit data word. Assuming you have one word on each row for the remainder of the file, then you have 354 words in the file.

The warning message tells you that your rom is not large enough to fit all the data words in the file.

I added some comments to the data file to illustrate what Verilog does with the data:

00000d13 // row 1 data loaded into rom_mem[0]
00000d93 // row 2 data loaded into rom_mem[1]
00000093
00000113
...
11111111 // row 100 data loaded into rom_mem[99]
22222222 // row 101 data loaded into rom_mem[100]
33333333 // row 102 data is discarded
...
ffffffff // row 354 data is discarded

As you can see, only the first 101 data words are loaded into the memory. The remaining data words are not used.

If you really want your memory to be 32x101 and you want to get rid of the warning, then you can delete the lines of the file starting at line 102, or you could specify start and end addresses:

    $readmemh("inst.data", tb.rv_soc_ins.rom_ins.rom_mem, 0, 101);

If you really want your memory to be 32x354, then you need to change the rom module:

reg [31:0]  rom_mem[0:353];

Refer to IEEE Std 1800-2017, section 21.4 Loading memory array data from a file.

计㈡愣 2025-02-03 14:18:50

警告说您的文件(带有354行)比数组(带有101个元素)更长。

关于VCD的消息没有连接:这只是下一个消息告诉您文件“ gtk.vcd”已打开。

The warning is saying that your file (with 354 rows) is longer than your array (with 101 elements).

The message about VCD is unconnected: it is simply the next message telling you that the file "gtk.vcd" has been opened.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文