我正在尝试在 Verilog 中创建一个具有 10 个空格的 32 位数组。这是代码:
reg [31:0] internalMemory [0:9];
然后我尝试将 32 位值分配给该寄存器内的不同位置。这是一个代码示例:
internalMemory[0] = 32'b00000000001000100001100000100000;
internalMemory[1] = 32'b00000000001000100001100000100001;
编译时出现以下错误:
IR.v:21: syntax error
IR.v:21: error: Invalid module instantiation
第 21 行代表我试图访问internalMemory[1]
.
关于为什么会发生这种情况以及如何解决它的任何建议?
谢谢!
更新 1:
按照这里的要求,我正在尝试实现指令寄存器的代码:
`include "IRTester.v"
module instruction_register(IREnable, programCounter, controlUnit, RS, RT, RD, immediate);
parameter dataWidth = 32; //input size
input wire IREnable;
input wire [31:0] programCounter; //instruction to be read
output wire [5:0] controlUnit;
output wire [4:0] RS;
output wire [4:0] RT;
output wire [4:0] RD;
output wire [15:0] immediate;
wire [31:0] temp;
reg [31:0] internalMemory [0:9];
always @ (posedge IREnable)
internalMemory[0] = 32'b00000000001000100001100000100000;
internalMemory[1] = 32'b00000000001000100001100000100001;
assign temp = internalMemory[programCounter];
assign controlUnit = temp[31:26];
assign RS = temp[25:21];
assign RT = temp[20:16];
assign RD = temp[15:11];
assign immediate = temp[15:0];
endmodule