dp.vhd 3.18 KB
Newer Older
lwc-tester committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
-- This work is licensed under a Creative Commons
-- Attribution-NonCommercial-ShareAlike 4.0 International License.
-- http://creativecommons.org/licenses/by-nc-sa/4.0

-- Mark D. Aagaard
-- Riham AlTawy
-- Guang Gong
-- Kalikinkar Mandal
-- Raghvendra Rohit
-- Marat Sattarov
-- http://comsec.uwaterloo.ca


-- This is a human-readable summary of (and not a substitute for) the license. 
-- You are free to:

--     Share — copy and redistribute the material in any medium or format
--     Adapt — remix, transform, and build upon the material

--     The licensor cannot revoke these freedoms as long as you follow
--     the license terms.

-- Under the following terms:

--     Attribution — You must give appropriate credit, provide a link to
--     the license, and indicate if changes were made. You may do so in
--     any reasonable manner, but not in any way that suggests the
--     licensor endorses you or your use.

--     NonCommercial — You may not use the material for commercial
--     purposes.

--     ShareAlike — If you remix, transform, or build upon the material,
--     you must distribute your contributions under the same license as
--     the original.

--     No additional restrictions — You may not apply legal terms or
--     technological measures that legally restrict others from doing
--     anything the license permits.

library ieee;
use ieee.std_logic_1164.all;
use work.wage_pkg.all;

entity dp is
  port
    ( clk       : in  std_logic
    ; i_control : in  wage_ctl_ty
    ; i_dom_sep : in  domsep_ty
    ; i_data    : in  data_io
    ; o_data    : out data_io
   );
end dp;

architecture rtl of dp is
  signal i_s36, i_s29, i_s23, i_s18, i_s10, i_s4, o_s36, o_s34, o_s27, o_s18, o_s15, o_s8, wgp_left, wgp_right, rc1, rc0: gf_elem;  
  signal const: std_logic_vector( lfsr_c_sz downto 0 );
  signal lfsr_c_reset, lfsr_en,
         absorb, replace,
         load, sb_off,
         is_tag, i_padding_reg : std_logic;

begin

  is_tag        <= i_control( is_tag_idx );
  sb_off        <= i_control( sb_off_idx );
  i_padding_reg <= i_control( i_padding_reg_idx );
  lfsr_en       <= i_control( lfsr_en_idx );
  lfsr_c_reset  <= i_control( lfsr_c_reset_idx );
  absorb        <= i_control( absorb_idx );
  replace       <= i_control( replace_idx );
  load          <= i_control( load_idx );

  -- wage lfsr
  wage_state: entity work.wagelfsr port map ( clk, lfsr_en, absorb, replace, load, sb_off, is_tag, i_padding_reg, i_dom_sep, i_data, i_s36, i_s29, i_s23, i_s18, i_s10, i_s4, o_s36, o_s34, o_s27, o_s18, o_s15, o_s8, o_data );       

  -- 4x sboxes
  SB_left_1:  entity work.sb port map ( o_s34, i_s29 );
  SB_left_2:  entity work.sb port map ( o_s27, i_s23 );
  SB_right_1: entity work.sb port map ( o_s15, i_s10 );
  SB_right_2: entity work.sb port map ( o_s8, i_s4 );
  
  -- 2x WGP
  wgpleft:    entity work.dwgp(const_array) port map ( o_s36, wgp_left );
  wgpright:   entity work.dwgp(const_array) port map ( o_s18, wgp_right );
 
  -- lfsr_c for constants
  lfsrconst:  entity work.lfsr_c port map ( clk, lfsr_en, lfsr_c_reset, const );

  rc1 <= const( lfsr_c_sz downto 1 ); 
  rc0 <= const( lfsr_c_sz - 1 downto 0 );

  i_s36 <= wgp_left  xor rc1;
  i_s18 <= wgp_right xor rc0;

end;