I have 64 bytes in a multi-dimensional packed array. I want to OR bits of every byte and return a 64 bit result, where each bit represents the OR result of 8 bits in a byte. I wrote a snippet below. Would it work? Is it synthesizable? Could you recommend a better way?
It should be parametric, so I cannot go for manually ORing 8 elements.
module my_module #(
localparam DEPTH = 64,
localparam WIDTH = 8
)(
input logic [DEPTH-1:0][WIDTH-1:0] arr, // Two dimensional input array
output logic [DEPTH-1:0] res // One dimensional output array
);
always_comb begin
// Default assignment:
res = '0;
for (genvar i = 0; i < DEPTH; i++) begin
for (genvar y = 0; y < WIDTH; y++) begin
res[i] = res[i] | arr[y];
end
end
end
endmodule