Need help with this some verilog code I am trying to get this matrix multiplier
ID: 1715834 • Letter: N
Question
Need help with this some verilog code I am trying to get this matrix multiplier to work off the postive edge of the clock.
module Matrix_Multiplication(MatrixOne,MatrixTwo,ResultsBothMatrices);
input [31:0] MatrixOne;
input [31:0] MatrixTwo;
output [31:0] ResultsBothMatrices;
reg [31:0] ResultsBothMatrices;
reg [7:0] MatrixOneA [0:1][0:1];
reg [7:0] MatrixTwoA [0:1][0:1];
reg [7:0] Results [0:1][0:1];
integer i;
integer j;
integer k;
always@ (MatrixOne or MatrixTwo)
begin
{MatrixOneA[0][0],MatrixOneA[0][1],MatrixOneA[1][0],MatrixOneA[1][1]} = MatrixOne;
{MatrixTwoA[0][0],MatrixTwoA[0][1],MatrixTwoA[1][0],MatrixTwoA[1][1]} = MatrixTwo;
i = 0;
j = 0;
k = 0;
Results[0][0] = 0;
Results[0][1] = 0;
Results[1][0] = 0;
Results[1][1] = 0;
for(i=0;i < 2;i=i+1)
for(j=0;j < 2;j=j+1)
for(k=0;k < 2;k=k+1)
Results[i][j] = Results[i][j] + (MatrixOneA[i][k] * MatrixTwoA[k][j]);
ResultsBothMatrices = {Results[0][0],Results[0][1],Results[1][0],Results[1][1]};
end
endmodule
module Matrix_Multiplication_TestBench;
// Here are my inputs for the first matrix
reg [31:0] MatrixOne;
reg [31:0] MatrixTwo;
// Here are my outputs
wire [31:0] ResultsBothMatrices;
// Instantiate the unit test
Matrix_Multiplication uut (
.MatrixOne(MatrixOne),
.MatrixTwo(MatrixTwo),
.ResultsBothMatrices(ResultsBothMatrices)
);
initial begin
// initial the values
// Start off by making both values zero
MatrixOne = 0; MatrixTwo = 0; #100;
// Setting up the matrix
//| 1| 2| | 5| 6|
//| 3| 4| | 7| 8|
MatrixOne = {8'd1,8'd2,8'd3,8'd4};
MatrixTwo = {8'd5,8'd6,8'd7,8'd8};
//The ending results should be
// ||| |||
end
endmodule