问题描述
我在 ISE 工具中用 verilog 代码制作了一个简单的缓存,并使用了一个二维寄存器数组作为我的缓存,在 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
解决方法
- 模块端口列表中没有输出
hit
。 - 您没有
endmodule
关键字。 - 某些软件只允许访问数组行中的所有位。我无法访问您的软件,因此无法对其进行测试,但您应该尝试类似的操作:
temp = cache[0];
cache[0] = {1'b 0,temp[7:0]};
这相当于:
cache[0][8] = 1'b0;
temp
应声明为 reg [8:0] temp;
(与 cache
的宽度相同)。