我在 SystemVerilog 中制作了一个 2D 数组,但是 modelsim 编译时出错,所以现在我的问题是为什么?
这是我正在尝试制作的矩阵乘法和累加单元的代码:
module matrix_mac_unit
(//ports
input clock,
input reset,
input enable,
input clear,
input [7:0] matrix_1 [0:3][0:3],
input [7:0] matrix_2 [0:3][0:3],
output [7:0] result [0:3][0:3]
);
logic [7:0] accumulator [0:3][0:3];
//sequential logic
always_ff @(posedge clock) begin
if (!reset) begin
accumulator <= 0;
end
else if (clear) begin
accumulator <= 0;
end
else begin
accumulator <= result;
end
end
//combinational logic
assign result = enable ? matrix_1 * matrix_2 + accumulator :
accumulator;
endmodule
模型说:
unit.sv(40):(vlog-2110) 非法引用网络数组“matrix_1”。
unit.sv(40):(vlog-2110) 非法引用网络数组“matrix_2”。
unit.sv(40):(vlog-2990) 对解压类型的非法操作。
unit.sv(40):(vlog-2110) 非法引用内存“累加器”。
unit.sv(40):(vlog-2990) 对解压类型的非法操作。
所以我的问题是你如何在 SystemVerilog 中声明一个矩阵?
SystemVerilog 不做矩阵乘法。您需要将方程扩展为单个元素。那里有很多例子。这是一个:http : //verilogcodes.blogspot.com/2015/11/verilog-code-for-matrix-multiplication.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句