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

Subversion Repositories cryptopan_core

[/] [cryptopan_core/] [tags/] [local_import/] [rtl/] [subbytesshiftrows.vhd] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tonyb33
--
2
-- This file is part of the Crypto-PAn core.
3
--
4
-- Copyright (c) 2007 The University of Waikato, Hamilton, New Zealand.
5
-- Authors: Anthony Blake (tonyb33@opencores.org)
6
--          
7
-- All rights reserved.
8
--
9
-- This code has been developed by the University of Waikato WAND 
10
-- research group. For further information please see http://www.wand.net.nz/
11
--
12
-- This source file is free software; you can redistribute it and/or modify
13
-- it under the terms of the GNU General Public License as published by
14
-- the Free Software Foundation; either version 2 of the License, or
15
-- (at your option) any later version.
16
--
17
-- This source is distributed in the hope that it will be useful,
18
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-- GNU General Public License for more details.
21
--
22
-- You should have received a copy of the GNU General Public License
23
-- along with libtrace; if not, write to the Free Software
24
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
--
26
 
27
library ieee;
28
use ieee.std_logic_1164.all;
29
 
30
use work.cryptopan.all;
31
 
32
entity subbytesshiftrows is
33
 
34
  port (
35
    bytes_in  : in  s_vector;
36
    bytes_out : out s_vector;
37
 
38
    in_en  : in  std_logic;
39
    out_en : out std_logic;
40
 
41
    clk   : in std_logic;
42
    reset : in std_logic
43
    );
44
 
45
end subbytesshiftrows;
46
 
47
 
48
architecture rtl of subbytesshiftrows is
49
 
50
  component dual_bram_256x8
51
    port (
52
      addra : IN  std_logic_VECTOR(7 downto 0);
53
      addrb : IN  std_logic_VECTOR(7 downto 0);
54
      clka  : IN  std_logic;
55
      clkb  : IN  std_logic;
56
      douta : OUT std_logic_VECTOR(7 downto 0);
57
      doutb : OUT std_logic_VECTOR(7 downto 0));
58
  end component;
59
 
60
  component sbox
61
    port (
62
      clk   : in  std_logic;
63
      reset : in  std_logic;
64
      addra : in  std_logic_vector(7 downto 0);
65
      douta : out std_logic_vector(7 downto 0));
66
  end component;
67
 
68
  signal subbytes_out : s_vector;
69
 
70
  signal in_en_int : std_logic;
71
 
72
begin  -- rtl
73
 
74
  out_en <= in_en_int;
75
 
76
  CLKLOGIC : process (clk, reset)
77
  begin
78
    if reset = '1' then
79
      in_en_int <= '0';
80
    elsif clk'event and clk = '1' then
81
      in_en_int <= in_en;
82
    end if;
83
  end process CLKLOGIC;
84
 
85
  USE_BRAM_GEN         : if use_bram = true generate
86
    GEN_SBOX_BRAM : for i in 0 to 7 generate
87
 
88
      SBOX_i: dual_bram_256x8
89
        port map (
90
            addra => bytes_in(i),
91
            addrb => bytes_in(i+8),
92
            clka  => clk,
93
            clkb  => clk,
94
            douta => subbytes_out(i),
95
            doutb => subbytes_out(i+8));
96
 
97
    end generate GEN_SBOX_BRAM;
98
  end generate USE_BRAM_GEN;
99
 
100
  NO_BRAM_GEN            : if use_bram = false generate
101
    GEN_SBOX_NOBRAM : for i in 0 to 15 generate
102
      SBOX_i : sbox
103
        port map (
104
          clk   => clk,
105
          reset => reset,
106
          addra => bytes_in(i),
107
          douta => subbytes_out(i) );
108
 
109
    end generate GEN_SBOX_NOBRAM;
110
  end generate NO_BRAM_GEN;
111
 
112
  bytes_out(0) <= subbytes_out(0);
113
  bytes_out(1) <= subbytes_out(1);
114
  bytes_out(2) <= subbytes_out(2);
115
  bytes_out(3) <= subbytes_out(3);
116
 
117
  bytes_out(4) <= subbytes_out(5);
118
  bytes_out(5) <= subbytes_out(6);
119
  bytes_out(6) <= subbytes_out(7);
120
  bytes_out(7) <= subbytes_out(4);
121
 
122
  bytes_out(8)  <= subbytes_out(10);
123
  bytes_out(9)  <= subbytes_out(11);
124
  bytes_out(10) <= subbytes_out(8);
125
  bytes_out(11) <= subbytes_out(9);
126
 
127
  bytes_out(12) <= subbytes_out(15);
128
  bytes_out(13) <= subbytes_out(12);
129
  bytes_out(14) <= subbytes_out(13);
130
  bytes_out(15) <= subbytes_out(14);
131
 
132
 
133
 
134
end rtl;

powered by: WebSVN 2.1.0

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