All pastes #928219 Raw Edit

Stuff

public text v1 · immutable
·published 2008-03-04 21:50 UTC
rendered paste body
library ieee;
library std;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio.all;
use std.textio.all;

entity sha512_hu_unit is
port (	clk,reset,enable_hu	: in	std_logic;
		a,b,c,d,e,f,g,h			: in	unsigned(63 downto 0);
		h0,h1,h2,h3,h4,h5,h6,h7 : out	unsigned(63 downto 0);
		output_hash				: in 	std_logic;
		hash_output				: out 	unsigned(511 downto 0)
);
end entity;

architecture struct of sha512_hu_unit is
	signal current_hash : unsigned(511 downto 0);

	alias ht is current_hash( 63 downto   0);
	alias gt is current_hash(127 downto  64);
	alias ft is current_hash(191 downto 128);
	alias et is current_hash(255 downto 192);
	alias dt is current_hash(319 downto 256);
	alias ct is current_hash(383 downto 320);
	alias bt is current_hash(447 downto 384);
	alias at is current_hash(511 downto 448);

begin

	process (clk,reset, enable_hu, output_hash,current_hash)

	begin
		if( reset = '0' ) then 
		at <= x"6a09e667f3bcc908";		bt <= x"bb67ae8584caa73b";
		ct <= x"3c6ef372fe94f82b";		dt <= x"a54ff53a5f1d36f1";
		et <= x"510e527fade682d1";		ft <= x"9b05688c2b3e6c1f";
		gt <= x"1f83d9abfb41bd6b";		ht <= x"5be0cd19137e2179";
		elsif (clk'event and clk= '1') then
			if ( enable_hu = '1') then 
				ht <= ht + h;
				gt <= gt + g;
				ft <= ft + f;
				et <= et + e;
				dt <= dt + d;
				ct <= ct + c;
				bt <= bt + b;
				at <= at + a;
			elsif(  output_hash = '1' ) then
					--current_hash <= current_hash(447 downto 0) & x"0000000000000000";
					hash_output <= current_hash;
			end if; 
		end if;

	end process;
	--hash_output <= current_hash(511 downto 448);
	h7 <= ht;	h6 <= gt;	h5 <= ft;	h4 <= et;
	h3 <= dt;	h2 <= ct;	h1 <= bt;	h0 <= at;
end architecture;