Guest
Hi,
I read the following code on line. The '-' sign in the below code puzzles me a
lot. Could you explain it to me?
Thanks,
..............
module top;
wire[17:0]A[1:3][1:3]; // the matrices
wire[17:0]B[1:3][1:3];
wire[17:0]C[1:3][1:3];
wire[(9*18)-1:0] Abits; // bit-decomposed versions of the above
wire[(9*18)-1:0] Bbits;
wire[(9*18)-1:0] Cbits;
genvar i,j;
// set A and B with initial values
generate
for(i=0; i<3; i=i+1)
for(j=0; j<3; j=j+1) begin
assign A[i+1][j+1] = i*3 + j;
assign B[i+1][j+1] = i*3 + j + 1;
end
endgenerate
// decompose A and B, set C
generate
for(i=1; i<=3; i=i+1)
for(j=1; j<=3; j=j+1) begin
assign Abits[(((i-1)*3 + (j-1)) * 18)+17 -:18] = A[j];
assign Bbits[(((i-1)*3 + (j-1)) * 18)+17 -:18] = B[j];
assign C[j] = Cbits[(((i-1)*3 + (j-1)) * 18)+17 -:18];
end
endgenerate
I read the following code on line. The '-' sign in the below code puzzles me a
lot. Could you explain it to me?
Thanks,
..............
module top;
wire[17:0]A[1:3][1:3]; // the matrices
wire[17:0]B[1:3][1:3];
wire[17:0]C[1:3][1:3];
wire[(9*18)-1:0] Abits; // bit-decomposed versions of the above
wire[(9*18)-1:0] Bbits;
wire[(9*18)-1:0] Cbits;
genvar i,j;
// set A and B with initial values
generate
for(i=0; i<3; i=i+1)
for(j=0; j<3; j=j+1) begin
assign A[i+1][j+1] = i*3 + j;
assign B[i+1][j+1] = i*3 + j + 1;
end
endgenerate
// decompose A and B, set C
generate
for(i=1; i<=3; i=i+1)
for(j=1; j<=3; j=j+1) begin
assign Abits[(((i-1)*3 + (j-1)) * 18)+17 -:18] = A[j];
assign Bbits[(((i-1)*3 + (j-1)) * 18)+17 -:18] = B[j];
assign C[j] = Cbits[(((i-1)*3 + (j-1)) * 18)+17 -:18];
end
endgenerate