VHDL modulo 2^64 addition

Status
Not open for further replies.

MSAKARIM

Full Member level 3
Joined
Jun 2, 2015
Messages
154
Helped
1
Reputation
2
Reaction score
4
Trophy points
1,298
Activity points
2,528
I'm working on SHA-512 VHDL implementation and i need to perform (addition mod 2^64)

How can i make the following addition as (modulo 2^64 addition)

Code:
  a(i)          <= std_logic_vector(unsigned(h(i-1)) +unsigned(f3(i)) + unsigned(f0(i)) +unsigned(k(i)) + unsigned(w(i))  + unsigned(f2(i)) + unsigned(f1(i)));
 

Hi,
I noticed that you used this: std_logic_vector(unsigned(h(i-1))

Why not try this: std_logic_vector(unsigned(h(i)-1)

I don't quite understand what you're doing though but if you show your code, then I can follow.
 
Hi,

Signed or unsigned values?

Klaus
 

Hi,

Signed or unsigned values?

Klaus

Since every quantity in the equation is specified as unsigned, then surely it's unsigned ?

Also, I did not understand the symbol " <= ". Is this a qualifier equation or is it an inequality ??
 

Hi,

Since every quantity in the equation is specified as unsigned, then surely it's unsigned ?
For sure you are right. ... I should have been more concentrated when reading post#1.

Klaus
 

Hi,
I noticed that you used this: std_logic_vector(unsigned(h(i-1))

Why not try this: std_logic_vector(unsigned(h(i)-1)

I don't quite understand what you're doing though but if you show your code, then I can follow.

h(i-1) is a previous iteration for h ( NOT h(i)-1 )
 

The code shown looks correct for this problem. My guess is that one or more of the terms is incorrect.

For any encryption core, you really need to get detailed test vectors. Not just input and final output, but all intermediate terms for every iteration. when everything looks random by design it is harder to intuitively trace the problem to a source.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…