OpenCores
URL https://opencores.org/ocsvn/loadbalancer/loadbalancer/trunk

Subversion Repositories loadbalancer

[/] [loadbalancer/] [trunk/] [Balance/] [hash.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 atalla
-------------------------------------------------
2
----Hash Function---
3
        LIBRARY IEEE;
4
        USE IEEE.STD_LOGIC_1164.ALL;
5
        USE IEEE.STD_LOGIC_ARITH.ALL;
6
        USE IEEE.STD_LOGIC_UNSIGNED.ALL;
7
        USE IEEE.NUMERIC_STD.ALL;
8
        USE IEEE.STD_LOGIC_MISC.ALL;
9
----------------
10
        ENTITY hash IS
11
                GENERIC(
12
                        KEY_WIDTH       :       NATURAL := 48;--Hash key width
13
                        ADD_WIDTH       :       NATURAL := 12; --address width
14
                        HASH_NO         :       NATURAL := 4 --Hash number
15
                );
16
                PORT (
17
                        key             :       STD_LOGIC_VECTOR(47 DOWNTO 0);   --Hash key 
18
                        address         :       OUT STD_LOGIC_VECTOR(ADD_WIDTH-1 DOWNTO 0)               --address 
19
                );
20
        END ENTITY hash;
21
---------------------------------
22
        ARCHITECTURE behavioral OF hash IS
23
                TYPE matrix_generator_type IS ARRAY (0 TO ADD_WIDTH-1) OF STD_LOGIC_VECTOR(KEY_WIDTH-1 DOWNTO 0);
24
                TYPE  matrix_type IS ARRAY (0 TO 3) OF matrix_generator_type ;
25
                CONSTANT matrix : matrix_type:=(
26
                                        (X"1066cb9fe7bc", X"d56494892645", X"492cf1e56e26", X"fbd5ee7df102",
27
                                         X"da6ff1b5421b", X"2186ffc8bdb6", X"9089eb857902", X"4315d53c7df8",
28
                                         X"c13cbcb713d7", X"9c1b26e99383", X"1ff39e15912a", X"b4008e58a8c9"), -- H1                                     
29
                                        (X"02a6200f47d5", X"812bbc47a2a4", X"1bcc1d1cb32a", X"5158420941ea",
30
                                         X"c13cbcb713d7", X"9c1b26e99383", X"1ff39e15912a", X"b4008e58a8c9",
31
                                         X"c13cbcb713d7", X"9c1b26e99383", X"1ff39e15912a", X"b4008e58a8c9"), -- H2                                     
32
                                        (X"2ce30e05be00", X"e8e3eefc2b70", X"5b3a5cdff1d3", X"087f63fb3838",
33
                                         X"f43c6ceb8b24", X"b3e80a27240e", X"88a21edc44d7", X"9a0320707b17",
34
                                         X"c13cbcb713d7", X"9c1b26e99383", X"1ff39e15912a", X"b4008e58a8c9"), -- H3                                     
35
                                        (X"27d0a50ed2db", X"7f09c83e8ce3", X"73af4e487d3f", X"6f02e7293763",
36
                                         X"87ebcfd7adfe", X"ed4fe1631a21", X"88c79139eee0", X"e4dde0201768",
37
                                         X"c13cbcb713d7", X"9c1b26e99383", X"1ff39e15912a", X"b4008e58a8c9")  -- H4
38
 
39
                                                        );
40
 
41
                SIGNAL matrix_wires : matrix_generator_type;
42
                BEGIN
43
                PROCESS(key ,matrix_wires)
44
                BEGIN
45
                        FOR row IN 0 TO ADD_WIDTH-1 LOOP
46
                                FOR col IN 0 TO KEY_WIDTH-1 LOOP
47
                                        matrix_wires(row)(col)<= matrix(HASH_NO-1)(row)(col) AND key(col) ;
48
                                END LOOP;
49
 
50
                                        address(row) <=  XOR_REDUCE(matrix_wires(row)) ;--XOR address(row);
51
 
52
                        END LOOP;
53
                END PROCESS;
54
        END ARCHITECTURE behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.