overflow - VHDL modulo 2^32 addition -


i working on vhdl implementation of sha-256 hash function. have 32-bit unsigned signals defined such:

signal a, b : unsigned (31 downto 0); 

within specifications of sha-256 algorithm, says addition must performed modulo 2^32 in order retain 32-bit size in case of overflow. now, according answer this question, sounds overflow handled modular addition in vhdl:

there no overflow handling, overflow carry lost. result integer result of operation modulo 2^max.

i have 2 questions:

  1. in case, max = 31 mean addition operation perform on a , b modded 2^31?
  2. i need perform addition modulo 2^32 doesn't make sense since working 32-bit numbers , 2^32 1 bit large. somehow implied should modding 2^31?

you fine unsigned(31 downto 0). 2^max in post reference error , should read 2^length. length of 31 downto 0 32.

think it, 31 downto 0 can represent numbers 0 2^32-1, wouldn't make sense if addition of range modulo 2^31 if can represent larger numbers!

i'm not sure understand second question, addition modulo 2^32 yields results in range of 0 2^32-1. 2^32 illegal, it's quite fine can't represent unsigned.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -