Altera_Forum
Honored Contributor
10 years agoBit widths for addition
Hi, I am trying to write a pipelined adder for a filter design. all the gaussianPixels are 8 bits wide.
gaussianPartialSum0 <= ("00" & gaussianPixels(0)) + ('0' & gaussianPixels(3) & '0') + ("00" & gaussianPixels(6)); gaussianPartialSum1 <= ('0' & gaussianPixels(1) & '0') + (gaussianPixels(4) & "00" ) + ('0' & gaussianPixels(7) & '0'); gaussianPartialSum2 <= ("00" & gaussianPixels(2)) + ('0' & gaussianPixels(5) & '0') + ("00" & gaussianPixels(8)); Gaussian_data_out <= std_logic_vector(gaussianPartialSum0 + gaussianPartialSum1 + gaussianPartialSum2); doing hand calculation, i see that gPS0 and gPS2 should be 10 bits wide and gPS1 should be 11 bits wide. But when i try to make them this length, vhdl complains that the bit widths dont match. The error is that the expression for gPS1 evaluates to 10 bits instead of 11. I'm not familiar with the rules of how VHDL calculates the required bit widths for addition. so by leaving all the gPS signals to 10 bits, im getting the incorrect answer. Is there something else I can do to get the correct values?