URL
https://opencores.org/ocsvn/deflatecore/deflatecore/trunk
Subversion Repositories deflatecore
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 11 to Rev 12
- ↔ Reverse comparison
Rev 11 → Rev 12
/trunk/HashChain.vhd
24,12 → 24,14
Data_Width : natural := 8; -- Width of the hash key generated now at 32 bits |
Hash_Width : natural := 32 |
); |
Port ( Hash_o : out std_logic_vector (Hash_Width - 1 downto 0); -- Hash value of previous data |
Port ( Hash_O : inout std_logic_vector (Hash_Width - 1 downto 0); -- Hash value of previous data |
Data_in : in std_logic_vector (Data_Width-1 downto 0); -- Data input from byte stream |
Clock, -- Clock |
Reset, -- Reset |
Output_E : in bit ; -- Output Enable |
Hash_Generated : out bit -- Enabled when the hash key has been generated |
Reset, |
Star_t, -- Reset |
O_E : in bit ; -- Output Enable |
Busy, |
Done : out bit -- Enabled when the hash key has been generated |
); |
end HashChain; |
|
40,62 → 42,38
--Function now implemented using XOR hash(i) = hash(i - 1) * 33 ^ str[i]; |
architecture DJB2 of HashChain is |
signal mode: integer; |
signal tempval:std_logic_vector (Hash_Width - 1 downto 0); |
signal tempval, hash :std_logic_vector (Hash_Width - 1 downto 0); |
begin |
|
mode <= 0 when clock = '1' and reset = '0' and Output_E = '1' and mode = 4 else -- Active data being latched to output |
1 when clock = '0' and reset = '0' and Output_E = '1' and mode = 0 else -- No change to output till thge next clock |
2 when clock = '1' and reset = '0' and Output_E = '1' and mode = 1 else -- Reset active |
3 when clock = '0' and reset = '0' and Output_E = '1' and mode = 2 else -- Reset active |
4 when clock = '1' and reset = '0' and Output_E = '1' and mode = 3 else -- Disable output |
-- Synchronous reset |
-- Remove remark and semi colon from 8 but it results in greater resource utilisation |
8 when clock ='1' and reset ='1'; |
mode <= 0 when (Reset = '1' or mode > 4) and clock = '1' else -- Rezet |
1 when Star_t = '1' and (mode = 0 or mode < 5) and clock ='1' else -- Start key generation |
2 when mode = 1 and clock = '0' else -- Just the rest of the statemachine |
3 when mode = 2 and clock = '1' else |
4 when mode = 3 and clock = '0' and O_E = '1' else |
5 ; |
|
Hash_Generated <= '0' when mode <4 or mode = 8 else |
'1'; |
hash <= X"16c7" when mode = 0 else |
--hash sll 5 when mode = 1 else |
hash xor tempval when mode =3 else |
hash; |
|
Process (clock) |
variable a, b, hash :std_logic_vector (Hash_Width - 1 downto 0); -- Variables for calculating the output |
variable hashg:bit; |
begin |
case mode is |
when 0 => --Calculate the hash key of the current input value using the Data on the input vector |
b := b + Data_in; --Store the input value into a variable |
when 1 => |
a := hash * X"21"; --Multiply the hash value by 33 |
when 2 => |
tempval <= a+hash; |
when 3 => -- |
hash := tempval xor b; --Xor the above value to the previous hashkey to generate the new hash key |
when 4 => |
b := X"00000000"; |
when others=> |
hash := X"16c7"; --Reset initial hash value to 5831 |
End case; |
hash_o<= hash; -- Latch the clculated hash value to the output |
end process; |
end DJB2; |
--Configuration: |
--Assign the name of the algorithm as the configuration. |
tempval <= X"0000" when mode /= 2 else |
tempval+ Data_in; |
|
--Configuration rs_hash of hashchain is |
--for rshash |
--end for; |
--end rs_hash; |
busy <= '1' when mode > 0 and mode <3 else |
'0'; |
|
--Configuration djb_hash of hashchain is |
--for djb |
--end for; |
--end djb_hash; |
Hash_O <= hash when mode =3 else |
Hash_O when (mode = 4 or mode = 5) and O_E = '1' else |
X"0000"; |
|
done <= '1' when mode = 3 else |
'0'; |
|
|
end DJB2; |
|
Configuration djb2_hash of hashchain is |
for djb2 |
end for; |
end djb2_hash; |
|
--Configuration sdbm_hash of hashchain is |
--for sdbm |
--end for; |
--end sdbm_hash; |
|