$readmem 可以在 Verilog 中综合吗?

发布于 2024-10-05 12:15:05 字数 94 浏览 0 评论 0原文

我正在尝试在 FPGA 上实现微控制器,我需要为其程序提供一个 ROM。如果我使用 $readmemb,它会被正确合成到 ROM 中吗?如果不是,执行此操作的标准方法是什么?

I am trying to implement a microcontroller on an FPGA, and I need to give it a ROM for its program. If I use $readmemb, will that be correctly synthesized to a ROM? If not, what is the standard way to do this?

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

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

发布评论

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

评论(1

秋意浓 2024-10-12 12:15:05

$readmemb 是否可综合取决于综合工具。

Altera 的推荐的 HDL 编码风格指南包括示例 10-31(第 10 页) -38),它演示了从 $readmemb 推断的 ROM(转载如下):

module dual_port_rom (
   input [(addr_width-1):0] addr_a, addr_b,
   input clk, 
   output reg [(data_width-1):0] q_a, q_b
);
   parameter data_width = 8;
   parameter addr_width = 8;
   reg [data_width-1:0] rom[2**addr_width-1:0];
   initial // Read the memory contents in the file
           // dual_port_rom_init.txt. 
   begin
      $readmemb("dual_port_rom_init.txt", rom);
   end
   always @ (posedge clk)
   begin
      q_a <= rom[addr_a];
      q_b <= rom[addr_b];
   end
endmodule

同样,Xilinx 的 XST 用户指南 指出:

$readmemb$readmemh 系统
任务可用于初始化块
回忆。欲了解更多信息,请参阅:

从外部文件初始化 RAM
编码示例

使用$readmemb
二进制和十六进制的 $readmemh
表示。为了避免可能发生的
XST和模拟器的区别
行为,Xilinx® 建议您
在这些系统中使用索引参数
任务。请看下面的编码
示例。

$readmemb("rams_20c.data",ram, 0, 7);

It depends on the synthesis tool whether or not $readmemb is synthesizable.

Altera's Recommended HDL Coding Styles guide includes example 10-31 (page 10-38), which demonstrates a ROM inferred from $readmemb (reproduced below):

module dual_port_rom (
   input [(addr_width-1):0] addr_a, addr_b,
   input clk, 
   output reg [(data_width-1):0] q_a, q_b
);
   parameter data_width = 8;
   parameter addr_width = 8;
   reg [data_width-1:0] rom[2**addr_width-1:0];
   initial // Read the memory contents in the file
           // dual_port_rom_init.txt. 
   begin
      $readmemb("dual_port_rom_init.txt", rom);
   end
   always @ (posedge clk)
   begin
      q_a <= rom[addr_a];
      q_b <= rom[addr_b];
   end
endmodule

Similarly, Xilinx's XST User Guide states that:

The $readmemb and $readmemh system
tasks can be used to initialize block
memories. For more information, see:

Initializing RAM From an External File
Coding Examples

Use $readmemb for
binary and $readmemh for hexadecimal
representation. To avoid the possible
difference between XST and simulator
behavior, Xilinx® recommends that you
use index parameters in these system
tasks. See the following coding
example.

$readmemb("rams_20c.data",ram, 0, 7);

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