"OR" multiple 2-D arrays created with a generate statement

Guest
Hi,

I have a set of two dimensional arrays that is created using "generate"
statement as below

genvar j;
generate
for(j=0;j<8;j=j+1)
begin : mat_array
reg [15:0] matrix [0:MATSIZE-1];
always@(*)
begin
integer i;
for(i=0;i<MATSIZE;i=i+1)
matrix = xyz;
end
end
endgenerate

Now I need to "OR" all the different instantiations of the matrix i.e.
something like -

mat_array[0].matrix[0:MATSIZE-1][15:0] |
mat_array[1].matrix[0:MATSIZE-1][15:0] |
mat_array[2].matrix[0:MATSIZE-1][15:0] |
mat_array[3].matrix[0:MATSIZE-1][15:0] |
mat_array[4].matrix[0:MATSIZE-1][15:0] |
mat_array[5].matrix[0:MATSIZE-1][15:0] |
mat_array[6].matrix[0:MATSIZE-1][15:0] |
mat_array[7].matrix[0:MATSIZE-1][15:0]

Maybe I need more sleep but I just cannot seem to figure out how I can
do this that would not cause a problem with the synthesizer.

TIA,
Sanjay
 
Hi Sanjay,

You should not need a generate loop. You can do with a normal 'for' loop.
Also, you should not even need the matrix if you just want to create the OR of all these 'xyz' vectors.
Something like this will do :

reg [15:0] mat_array_matrix [7:0][0:MATSIZE-1] ;
reg [15:0] result ;
integer k, i ;
always @*
begin
result = 0 ;
for (k=0;k<8;k=k+1) begin
for (i=0;i<MATSIZE;i=i+1) begin
mat_array_matrix[k] = xyz ; // if you really want to create the matrix
result = result | xyz ; // if you can do without the matrix
end
end
end

'result' will contain the ORed result you need, and you don't actually need the matrix.
I just included it here for educational purposes.

Rob

<fpgabuilder-groups@yahoo.com> wrote in message news:1166141396.192453.294710@t46g2000cwa.googlegroups.com...
Hi,

I have a set of two dimensional arrays that is created using "generate"
statement as below

genvar j;
generate
for(j=0;j<8;j=j+1)
begin : mat_array
reg [15:0] matrix [0:MATSIZE-1];
always@(*)
begin
integer i;
for(i=0;i<MATSIZE;i=i+1)
matrix = xyz;
end
end
endgenerate

Now I need to "OR" all the different instantiations of the matrix i.e.
something like -

mat_array[0].matrix[0:MATSIZE-1][15:0] |
mat_array[1].matrix[0:MATSIZE-1][15:0] |
mat_array[2].matrix[0:MATSIZE-1][15:0] |
mat_array[3].matrix[0:MATSIZE-1][15:0] |
mat_array[4].matrix[0:MATSIZE-1][15:0] |
mat_array[5].matrix[0:MATSIZE-1][15:0] |
mat_array[6].matrix[0:MATSIZE-1][15:0] |
mat_array[7].matrix[0:MATSIZE-1][15:0]

Maybe I need more sleep but I just cannot seem to figure out how I can
do this that would not cause a problem with the synthesizer.

TIA,
Sanjay
 
Hi Rob,

Thank you for the reply.

I had tried something like below before posting -
result = result | xyz ; // if you can do without the matrix
It was included in the combinatorial always block just as you have
shown. But the simulator (modelsim) didn't like it. It froze. So I
actually created something like

always@(*)
begin
...
result_wire = result | xyz;
end

assign result = result_wire;

Best,
-sanjay

Rob Dekker wrote:
Hi Sanjay,

You should not need a generate loop. You can do with a normal 'for' loop.
Also, you should not even need the matrix if you just want to create the OR of all these 'xyz' vectors.
Something like this will do :

reg [15:0] mat_array_matrix [7:0][0:MATSIZE-1] ;
reg [15:0] result ;
integer k, i ;
always @*
begin
result = 0 ;
for (k=0;k<8;k=k+1) begin
for (i=0;i<MATSIZE;i=i+1) begin
mat_array_matrix[k] = xyz ; // if you really want to create the matrix
result = result | xyz ; // if you can do without the matrix
end
end
end

'result' will contain the ORed result you need, and you don't actually need the matrix.
I just included it here for educational purposes.

Rob

fpgabuilder-groups@yahoo.com> wrote in message news:1166141396.192453.294710@t46g2000cwa.googlegroups.com...
Hi,

I have a set of two dimensional arrays that is created using "generate"
statement as below

genvar j;
generate
for(j=0;j<8;j=j+1)
begin : mat_array
reg [15:0] matrix [0:MATSIZE-1];
always@(*)
begin
integer i;
for(i=0;i<MATSIZE;i=i+1)
matrix = xyz;
end
end
endgenerate

Now I need to "OR" all the different instantiations of the matrix i.e.
something like -

mat_array[0].matrix[0:MATSIZE-1][15:0] |
mat_array[1].matrix[0:MATSIZE-1][15:0] |
mat_array[2].matrix[0:MATSIZE-1][15:0] |
mat_array[3].matrix[0:MATSIZE-1][15:0] |
mat_array[4].matrix[0:MATSIZE-1][15:0] |
mat_array[5].matrix[0:MATSIZE-1][15:0] |
mat_array[6].matrix[0:MATSIZE-1][15:0] |
mat_array[7].matrix[0:MATSIZE-1][15:0]

Maybe I need more sleep but I just cannot seem to figure out how I can
do this that would not cause a problem with the synthesizer.

TIA,
Sanjay
 

Welcome to EDABoard.com

Sponsor

Back
Top