Matrix multiplication

Hi all,

I try to coded for matrix multiplication with N*N.
am getting some errors related to that

could you please help me.

Thanks,

In reply to Prawin kumar:

It runs just fine for me. What errors are you seeing?

Can you explain what you are trying to accomplish? I see that variables a and b 32-bits wide. Are you trying to have each element 4-bits wide? If so the resulting variable must be at least 8-bits wide.

In reply to sbellock:

display matrix c is 0 right

In reply to DVCoder:

i want you multiply matrix with N*N,it may be 4 bit,8bit,16bit,32bit,
just i want you multiply two matrix.

In reply to Prawin kumar:

could you help on this

In reply to Prawin kumar:
Your code works aa you have written it.

No one can help you if you do not explain what results you are expecting versus what you are seeing. You need to look at the intermediate results and see if they match your expectations. If not, please explain the equations you are trying to implement, the results you expect, and the results you are seeing.

In reply to dave_59:

Hi,

i want multiply two matrix with NN,
i.e when i give N=3 it multiply 3
3 matrix

i’m unable to give inputs to matrix “a” and “b”.

am coded like this
reg [3:0]a= {4’d2,4’d3,4’d1,4’d6};
reg [3:0]b= {4’d1,4’d0,4’d1,4’d5};

https://www.edaplayground.com/x/3ESR.

In reply to PJ:

Did u get the output for matrix multiplication for N*N matrix?

In reply to PJ:

you are assigning a 32 bit integer to a 1 bit register. That’s the reason why you are getting an Error as “Incompatible types at assignment”.

[i]In reply to Raghunandan Reddy:[

i have changed But i am not getting proper output .

In reply to sai yamuna chakka:

change your code of your program according to my below statements it will works fine:

reg [31:0]ra [N][N]; reg [31:0]rb [N][N]; reg [31:0]rc [N][N];

ra[i1][j1]=a[i1][j1]; rb[i][j]=b[i][j];

c[i2][j2]=sum;

rc[i2][j2]=c[i2][j2];

Can anyone help me how to write the testbech for matrix multiplication using testbench components.