首页 > 解决方案 > 访问 Verilog 代码中的 2d 寄存器数组以在 leonardo 工具中合成时出现语法错误

问题描述

我用 ISE 工具中的 verilog 代码制作了一个简单的缓存,并使用了一个 2d 寄存器数组作为我的缓存,在 Modelsim 中模拟测试平台做得很好,没有语法错误,也没有错误的输出信号,但是当我在 Leonardo 工具中告诉莱昂纳多在库 ams600nm 中读取它,它在我访问我的二维数组(缓存)的第一行附近返回语法错误,你知道吗?

代码:

module Cache(clk , wr
,din,adr,dout
);
input clk;
input wr;
input [3:0] din;
input [3:0] adr;
output [3:0] dout;
output hit;
 reg [8:0] cache [3:0];
 reg h;
 reg [3:0] out;
 initial
    begin
        ***cache[0][8] = 1'b0; -----here-----
        cache[1][8] = 1'b0; -----also here for sure-----
        cache[2][8] = 1'b0;
        cache[3][8] = 1'b0;***
    end 

标签: arrayscachingverilogsynthesis

解决方案


  1. hit您在模块端口列表中没有输出。
  2. 你没有endmodule关键字。
  3. 一些软件只允许访问数组行中的所有位。我无权访问您的软件,因此无法对其进行测试,但您应该尝试以下方法:
temp = cache[0];
cache[0] = {1'b 0, temp[7:0]};

这相当于:

cache[0][8] = 1'b0;

temp 应声明为reg [8:0] temp;(与 相同的宽度cache)。


推荐阅读