next up previous contents
Next: Driver chip: driver.vhdl Up: VHDL code for brute-force Previous: VHDL code for brute-force

Data Types: crypt_pack.vhdl

 
library ieee;
    use ieee.std_logic_1164.all;

package crypt_pack is
 
 subtype INT32 is STD_LOGIC_VECTOR(31 downto 0); -- MSB is 31, LSB is 0

 component crypt           -- Crypto core
  port(        k0, k1: in  INT32;
         RV0:     out STD_LOGIC;
        CLOCK:  in  STD_LOGIC;
        DONE:   out STD_LOGIC;
        RESET:  in  STD_LOGIC);
 end component;

 FUNCTION "xor" ( l:STD_LOGIC_VECTOR; r:INTEGER ) RETURN STD_LOGIC_VECTOR;
 FUNCTION "xor" ( l:INTEGER; r:STD_LOGIC_VECTOR ) RETURN STD_LOGIC_VECTOR;
-- FUNCTION "sll" ( l,r:STD_LOGIC_VECTOR) RETURN STD_LOGIC_VECTOR;
-- FUNCTION "srl" ( l,r:STD_LOGIC_VECTOR) RETURN STD_LOGIC_VECTOR;
 FUNCTION SHL( l:STD_LOGIC_VECTOR; r:INTEGER ) RETURN STD_LOGIC_VECTOR;
 FUNCTION SHL( l:INTEGER; r:STD_LOGIC_VECTOR ) RETURN STD_LOGIC_VECTOR;
 FUNCTION SHR( l:STD_LOGIC_VECTOR; r:INTEGER ) RETURN STD_LOGIC_VECTOR;
 FUNCTION SHR( l:INTEGER; r:STD_LOGIC_VECTOR ) RETURN STD_LOGIC_VECTOR;

 FUNCTION To_INT32 ( l:INTEGER ) RETURN STD_LOGIC_VECTOR;
 FUNCTION To_INT32 ( b:BIT_VECTOR ) RETURN STD_LOGIC_VECTOR;
end;

use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
package body crypt_pack is

 FUNCTION To_INT32 ( l:INTEGER ) RETURN STD_LOGIC_VECTOR is 
 begin
   return CONV_STD_LOGIC_VECTOR(l, 32);
 end;
 FUNCTION To_INT32 ( b:BIT_VECTOR ) RETURN STD_LOGIC_VECTOR is
 begin
   return To_StdLogicVector(b);
 end;

 FUNCTION "xor" ( l:STD_LOGIC_VECTOR; r:INTEGER ) RETURN STD_LOGIC_VECTOR is
 begin
   return l xor CONV_STD_LOGIC_VECTOR(r, l'length);
 end;
 FUNCTION "xor" ( l:INTEGER; r:STD_LOGIC_VECTOR) RETURN STD_LOGIC_VECTOR is
 begin
   return CONV_STD_LOGIC_VECTOR(l, r'length) xor r;
 end;

-- FUNCTION "sll" ( l,r:STD_LOGIC_VECTOR) RETURN STD_LOGIC_VECTOR is
-- begin
--   return SHL(l, r);
-- end;

-- FUNCTION "srl" ( l,r:STD_LOGIC_VECTOR) RETURN STD_LOGIC_VECTOR is
-- begin
--   return SHR(l, r);
-- end;

-- FUNCTION "sll" ( l:STD_LOGIC_VECTOR; r:INTEGER ) RETURN STD_LOGIC_VECTOR is
--   return l(r to l'length) & 'r' zeros.

 FUNCTION SHL( l:STD_LOGIC_VECTOR; r:INTEGER ) RETURN STD_LOGIC_VECTOR is
 begin
     return SHL(l, CONV_STD_LOGIC_VECTOR(r, l'length));
 end;
 FUNCTION SHL( l:INTEGER; r:STD_LOGIC_VECTOR ) RETURN STD_LOGIC_VECTOR is
 begin
     return SHL(CONV_STD_LOGIC_VECTOR(l, r'length), r);
 end;
 FUNCTION SHR( l:STD_LOGIC_VECTOR; r:INTEGER ) RETURN STD_LOGIC_VECTOR is
 begin
     return SHR(l, CONV_STD_LOGIC_VECTOR(r, l'length));
 end;
 FUNCTION SHR( l:INTEGER; r:STD_LOGIC_VECTOR ) RETURN STD_LOGIC_VECTOR is
 begin
     return SHR(CONV_STD_LOGIC_VECTOR(l, r'length), r);
 end;

end;



C. Scott Ananian
10/11/1997