Search code examples
veriloghardwarefpgahdl

Maximum bit-width to store a summation of M n-bit binary numbers


I am trying to find the formula to calculate the maximum bit-width required to contain a sum of M n-bit unsigned binary numbers. Thanks!


Solution

  • The maximum bit-width needed should be ceil(log_2(M * (2^n - 1))).

    Edit: Thanks to @MBurnham I realize now that it should be floor(log_2(M * (2^n - 1))) + 1 instead.