------------------------------------------------------------
-- Copyright: 2010 Integrated Sytems Laboratory, ETH Zurich
--            http://www.iis.ee.ethz.ch/~sha3
------------------------------------------------------------
library ieee;
use ieee.numeric_std.all;
use ieee.std_logic_1164.all;

package simdpkg is

  type simdline is array (0 to 3) of std_logic_vector(31 downto 0);
  
  type simdstate is array (0 to 3, 0 to 3) of std_logic_vector(31 downto 0);

  type marray is array (0 to 63) of std_logic_vector(7 downto 0);

  type messperm is array (0 to 31, 0 to 7) of integer;

  type rsline is array (0 to 19, 0 to 1) of integer;
  
  type integer8x8 is array (0 to 7, 0 to 7) of integer;

  type integer128 is array (0 to 127) of integer;
  

  constant IV : simdstate := ((x"4d567983", x"aaf3d925", x"c2c2ba14", x"e2eaa8d2"),
                              (x"07190ba9", x"3ee20b03", x"49b3bcb4", x"1ff47833"),
                              (x"8474577b", x"afd5e751", x"f67caf46", x"d0c661a5"),
                              (x"39d726e9", x"c96006d3", x"668626c9", x"55693de1"));

  constant WPERM : messperm := (
  ( 32,  33,  34,  35,  36,  37,  38,  39),
  ( 48,  49,  50,  51,  52,  53,  54,  55),
  (  0,   1,   2,   3,   4,   5,   6,   7),
  ( 16,  17,  18,  19,  20,  21,  22,  23),
  ( 56,  57,  58,  59,  60,  61,  62,  63),
  ( 40,  41,  42,  43,  44,  45,  46,  47),
  ( 24,  25,  26,  27,  28,  29,  30,  31),
  (  8,   9,  10,  11,  12,  13,  14,  15),
  (120, 121, 122, 123, 124, 125, 126, 127),
  ( 88,  89,  90,  91,  92,  93,  94,  95),
  ( 96,  97,  98,  99, 100, 101, 102, 103),
  ( 64,  65,  66,  67,  68,  69,  70,  71),
  ( 72,  73,  74,  75,  76,  77,  78,  79),
  (104, 105, 106, 107, 108, 109, 110, 111),
  ( 80,  81,  82,  83,  84,  85,  86,  87),
  (112, 113, 114, 115, 116, 117, 118, 119),
  (  8,  72,  10,  74,  12,  76,  14,  78),
  ( 16,  80,  18,  82,  20,  84,  22,  86),
  ( 56, 120,  58, 122,  60, 124,  62, 126),
  ( 32,  96,  34,  98,  36, 100,  38, 102),
  ( 48, 112,  50, 114,  52, 116,  54, 118),
  ( 40, 104,  42, 106,  44, 108,  46, 110),
  (  0,  64,   2,  66,   4,  68,   6,  70),
  ( 24,  88,  26,  90,  28,  92,  30,  94),
  ( 49, 113,  51, 115,  53, 117,  55, 119),
  (  1,  65,   3,  67,   5,  69,   7,  71),
  (  9,  73,  11,  75,  13,  77,  15,  79),
  ( 57, 121,  59, 123,  61, 125,  63, 127),
  ( 25,  89,  27,  91,  29,  93,  31,  95),
  ( 41, 105,  43, 107,  45, 109,  47, 111),
  ( 33,  97,  35,  99,  37, 101,  39, 103),
  ( 17,  81,  19,  83,  21,  85,  23,  87));

  constant rs : rsline := (
  ( 3, 23), (23, 17), (17, 27), (27,  3),
  (28, 19), (19, 22), (22,  7), ( 7, 28),
  (29,  9), ( 9, 15), (15,  5), ( 5, 29),
  ( 4, 13), (13, 10), (10, 25), (25,  4),
  ( 4, 13), (13, 10), (10, 25), (25,  4));
  
  constant FFT64TW : integer8x8 := (
    (1,    1,    1,    1,    1,    1,    1,    1),
    (1,    2,    4,    8,   16,   32,   64,  128),
    (1,   60,    2,  120,    4,  -17,    8,  -34),
    (1,  120,    8,  -68,   64,  -30,   -2,   17),
    (1,   46,   60,  -67,    2,   92,  120,  123),
    (1,   92,  -17,  -22,   32,  117,  -30,   67),
    (1,  -67,  120,  -73,    8,  -22,  -68,  -70),
    (1,  123,  -34,  -70,  128,   67,   17,   35));
  
  constant FFT128TW : integer8x8:= (
  (  1, -118,   46,  -31,   60,  116,  -67,  -61), 
  (  2,   21,   92,  -62,  120,  -25,  123, -122), 
  (  4,   42,  -73, -124,  -17,  -50,  -11,   13), 
  (  8,   84,  111,    9,  -34, -100,  -22,   26), 
  ( 16,  -89,  -35,   18,  -68,   57,  -44,   52), 
  ( 32,   79,  -70,   36,  121,  114,  -88,  104), 
  ( 64,  -99,  117,   72,  -15,  -29,   81,  -49), 
  (128,   59,  -23, -113,  -30,  -58,  -95,  -98));
  
  constant P : integer128 := ( 0,  64,  32,  96,  16,  80,  48, 112,
                               8,  72,  40, 104,  24,  88,  56, 120,
                               4,  68,  36, 100,  20,  84,  52, 116,
                              12,  76,  44, 108,  28,  92,  60, 124,
                               2,  66,  34,  98,  18,  82,  50, 114,
                              10,  74,  42, 106,  26,  90,  58, 122,
                               6,  70,  38, 102,  22,  86,  54, 118,
                              14,  78,  46, 110,  30,  94,  62, 126,
                               1,  65,  33,  97,  17,  81,  49, 113,
                               9,  73,  41, 105,  25,  89,  57, 121,
                               5,  69,  37, 101,  21,  85,  53, 117,
                              13,  77,  45, 109,  29,  93,  61, 125,
                               3,  67,  35,  99,  19,  83,  51, 115,
                              11,  75,  43, 107,  27,  91,  59, 123,
                               7,  71,  39, 103,  23,  87,  55, 119,
                              15,  79,  47, 111,  31,  95,  63, 127);

end simdpkg;

Generated on Fri Sep 24 10:39:12 CEST 2010
Home