$readmem 可以在 Verilog 中合成吗? [英] Is $readmem synthesizable in Verilog?

查看:26
本文介绍了$readmem 可以在 Verilog 中合成吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 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?

推荐答案

$readmemb 是否可合成取决于合成工具.

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

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

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

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

Similarly, Xilinx's XST User Guide states that:

$readmemb$readmemh 系统任务可用于初始化块回忆.有关更多信息,请参阅:

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

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

Initializing RAM From an External File Coding Examples

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

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);

这篇关于$readmem 可以在 Verilog 中合成吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆