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

Subversion Repositories xteacore

[/] [xteacore/] [trunk/] [tb/] [tb_xtea.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 entactogen
 
2
-- Copyright (c) 2013 Antonio de la Piedra
3
 
4
-- This program is free software: you can redistribute it and/or modify
5
-- it under the terms of the GNU General Public License as published by
6
-- the Free Software Foundation, either version 3 of the License, or
7
-- (at your option) any later version.
8
 
9
-- This program is distributed in the hope that it will be useful,
10
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- GNU General Public License for more details.
13
 
14
-- You should have received a copy of the GNU General Public License
15
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
LIBRARY ieee;
18
USE ieee.std_logic_1164.ALL;
19
 
20
ENTITY tb_xtea IS
21
END tb_xtea;
22
 
23
ARCHITECTURE behavior OF tb_xtea IS
24
 
25
    -- Component Declaration for the Unit Under Test (UUT)
26
 
27
    COMPONENT xtea
28
    PORT(
29
         clk : IN  std_logic;
30
         rst : IN  std_logic;
31
         enc : in std_logic;
32
         block_in : IN  std_logic_vector(63 downto 0);
33
         key : IN  std_logic_vector(127 downto 0);
34
         v_0_out : out std_logic_vector(31 downto 0);
35
         v_1_out : out std_logic_vector(31 downto 0)
36
        );
37
    END COMPONENT;
38
 
39
 
40
   --Inputs
41
   signal clk : std_logic := '0';
42
   signal rst : std_logic := '0';
43
   signal enc : std_logic := '0';
44
   signal block_in : std_logic_vector(63 downto 0) := (others => '0');
45
   signal key : std_logic_vector(127 downto 0) := (others => '0');
46
 
47
        --Outputs
48
        signal v_0_out : std_logic_vector(31 downto 0);
49
        signal v_1_out : std_logic_vector(31 downto 0);
50
 
51
   -- Clock period definitions
52
   constant clk_period : time := 10 ns;
53
 
54
BEGIN
55
 
56
        -- Instantiate the Unit Under Test (UUT)
57
   uut: xtea PORT MAP (
58
          clk => clk,
59
          rst => rst,
60
          enc => enc,
61
          block_in => block_in,
62
          key => key,
63
          v_0_out => v_0_out,
64
          v_1_out => v_1_out
65
        );
66
 
67
   -- Clock process definitions
68
   clk_process :process
69
   begin
70
                clk <= '0';
71
                wait for clk_period/2;
72
                clk <= '1';
73
                wait for clk_period/2;
74
   end process;
75
 
76
 
77
   -- Stimulus process
78
   stim_proc: process
79
   begin
80
                wait for clk_period/2 + 10*clk_period;
81
                enc <= '0';
82
                rst <= '1';
83
                block_in <= X"bbbbbbbb" & X"aaaaaaaa" ;
84
                key <= X"44444444" &  X"33333333" & X"22222222" &  X"11111111";
85
 
86
                wait for clk_period;
87
 
88
                rst <= '0';
89
 
90
                wait for 4*64*clk_period;
91
 
92
                assert v_0_out = X"3a53039a"
93
                        report "ENCRYPT ERROR (v_0)" severity FAILURE;
94
 
95
                wait for clk_period;
96
 
97
                assert v_1_out = X"fe2d9913"
98
                        report "ENCRYPT ERROR (v_1)" severity FAILURE;
99
 
100
                wait for clk_period*10;
101
                enc <= '1';
102
                rst <= '1';
103
                block_in <= X"fe2d9913" & X"3a53039a" ;
104
                key <= X"44444444" &  X"33333333" & X"22222222" &  X"11111111";
105
 
106
                wait for clk_period;
107
 
108
                rst <= '0';
109
 
110
                wait for 4*64*clk_period;
111
 
112
                assert v_0_out = X"bbbbbbbb"
113
                        report "DECRYPT ERROR (v_0)" severity FAILURE;
114
 
115
                wait for clk_period;
116
 
117
                assert v_1_out = X"aaaaaaaa"
118
                        report "DECRYPT ERROR (v_1)" severity FAILURE;
119
 
120
 
121
      wait;
122
   end process;
123
 
124
END;

powered by: WebSVN 2.1.0

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