wturri
Newbie level 4
I'm implementing a series of multiply-and-accumulate functions in a filter window. All the multiplies happen in a single clock cycle (coded with a FOR loop and results stored into an array). Those products are then summed in groups of 4 and stored into another array, and so forth, until I have a single array of partial sums...
I have these results of intermediate summations being stored in a 1-dimensional array of std_logic_vector. In my last processing stage I want to sum the values in each element of that array, together, and store the result in a single register. In C it would be something like:
mac_result = 0;
for(j = 0; j < num_elements; j++){
mac_result = mac_result + partial_sums[j];
}
I tried doing basically that in VHDL using a variable, then assigning the variable to a signal, but I ended up getting a lot of X's in simulation. The issue is that the number of partial sums (and therefore the number of array elements) will change depending upon the size of the 2D window filter, and so I can't code this using a fixed number of additions. Anyway, what would you do?
I have these results of intermediate summations being stored in a 1-dimensional array of std_logic_vector. In my last processing stage I want to sum the values in each element of that array, together, and store the result in a single register. In C it would be something like:
mac_result = 0;
for(j = 0; j < num_elements; j++){
mac_result = mac_result + partial_sums[j];
}
I tried doing basically that in VHDL using a variable, then assigning the variable to a signal, but I ended up getting a lot of X's in simulation. The issue is that the number of partial sums (and therefore the number of array elements) will change depending upon the size of the 2D window filter, and so I can't code this using a fixed number of additions. Anyway, what would you do?