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

Subversion Repositories present

[/] [present/] [trunk/] [PureTesting/] [bench/] [vhdl/] [PresentTB.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 gajos
-----------------------------------------------------------------------
2
----                                                               ----
3
---- Present - a lightweight block cipher project                  ----
4
----                                                               ----
5
---- This file is part of the Present - a lightweight block        ----
6
---- cipher project                                                ----
7
---- http://www.http://opencores.org/project,present               ----
8
----                                                               ----
9
---- Description:                                                  ----
10
----     Test bench of Present encoder. Nothing special. Data taken----
11
---- from http://homes.esat.kuleuven.be/~abogdano/papers/          ----
12
---- present_ches07.pdf                                            ----
13
---- To Do:                                                        ----
14
----                                                               ----
15
---- Author(s):                                                    ----
16
---- - Krzysztof Gajewski, gajos@opencores.org                     ----
17
----                       k.gajewski@gmail.com                    ----
18
----                                                               ----
19
-----------------------------------------------------------------------
20
----                                                               ----
21
---- Copyright (C) 2013 Authors and OPENCORES.ORG                  ----
22
----                                                               ----
23
---- This source file may be used and distributed without          ----
24
---- restriction provided that this copyright statement is not     ----
25
---- removed from the file and that any derivative work contains   ----
26
---- the original copyright notice and the associated disclaimer.  ----
27
----                                                               ----
28
---- This source file is free software; you can redistribute it    ----
29
---- and-or modify it under the terms of the GNU Lesser General    ----
30
---- Public License as published by the Free Software Foundation;  ----
31
---- either version 2.1 of the License, or (at your option) any    ----
32
---- later version.                                                ----
33
----                                                               ----
34
---- This source is distributed in the hope that it will be        ----
35
---- useful, but WITHOUT ANY WARRANTY; without even the implied    ----
36
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       ----
37
---- PURPOSE. See the GNU Lesser General Public License for more   ----
38
---- details.                                                      ----
39
----                                                               ----
40
---- You should have received a copy of the GNU Lesser General     ----
41
---- Public License along with this source; if not, download it    ----
42
---- from http://www.opencores.org/lgpl.shtml                      ----
43
----                                                               ----
44
-----------------------------------------------------------------------
45 3 gajos
LIBRARY ieee;
46
USE ieee.std_logic_1164.ALL;
47
 
48
-- Uncomment the following library declaration if using
49
-- arithmetic functions with Signed or Unsigned values
50
--USE ieee.numeric_std.ALL;
51
 
52
ENTITY PresentTB IS
53
END PresentTB;
54
 
55
ARCHITECTURE behavior OF PresentTB IS
56
 
57
    -- Component Declaration for the Unit Under Test (UUT)
58
 
59
    COMPONENT PresentEnc
60
    PORT(
61
         plaintext : IN  std_logic_vector(63 downto 0);
62
         key : IN  std_logic_vector(79 downto 0);
63
         ciphertext : OUT  std_logic_vector(63 downto 0);
64
         start : IN  std_logic;
65
         clk : IN  std_logic;
66
         reset : IN  std_logic;
67
         ready : OUT  std_logic
68
        );
69
    END COMPONENT;
70
 
71
 
72
   --Inputs
73
   signal plaintext : std_logic_vector(63 downto 0) := (others => '0');
74
   signal key : std_logic_vector(79 downto 0) := (others => '0');
75
   signal start : std_logic := '0';
76
   signal clk : std_logic := '0';
77
   signal reset : std_logic := '0';
78
 
79
        --Outputs
80
   signal ciphertext : std_logic_vector(63 downto 0);
81
   signal ready : std_logic;
82
 
83
   -- Clock period definitions
84
   constant clk_period : time := 10 ns;
85
 
86
BEGIN
87
 
88
        -- Instantiate the Unit Under Test (UUT)
89
   uut: PresentEnc PORT MAP (
90
          plaintext => plaintext,
91
          key => key,
92
          ciphertext => ciphertext,
93
          start => start,
94
          clk => clk,
95
          reset => reset,
96
          ready => ready
97
        );
98
 
99
   -- Clock process definitions
100
   clk_process :process
101
   begin
102
                clk <= '0';
103
                wait for clk_period/2;
104
                clk <= '1';
105
                wait for clk_period/2;
106
   end process;
107
 
108
 
109
   -- Stimulus process
110
   stim_proc: process
111
   begin
112
 
113
                reset <= '1';
114
      start <= '0';
115
                wait for 100 ns;
116
                reset <= '0';
117
 
118 13 gajos
---- Preparation for test case 1 -----------------
119
--   plaintext <= x"0000000000000000";
120
--   key <= x"00000000000000000000";
121
--   expected_ciphertext <= x"5579c1387b228445";
122
--------------------------------------------------
123
 
124 3 gajos
                plaintext <= (others => '0');
125
                key <= (others => '0');
126
                start <= '1';
127 13 gajos
 
128
                wait until ready = '1' and clk = '0';
129
 
130
                if ciphertext /= x"5579c1387b228445" then
131
                        report "RESULT MISMATCH! Test case 1 failed" severity ERROR;
132
                        assert false severity failure;
133
                else
134
                        report "Test case 1 successful" severity note;
135
                end if;
136
 
137
---- Preparation for test case 2 -----------------
138
--   plaintext <= x"0000000000000000";
139
--   key <= x"ffffffffffffffffffff";
140
--   expected_ciphertext <= x"e72c46c0f5945049";
141
--------------------------------------------------              
142
 
143 3 gajos
                start <= '0';
144
                wait for clk_period;
145
 
146
                plaintext <= (others => '0');
147
                key <= (others => '1');
148
                start <= '1';
149 13 gajos
      wait until ready = '1' and clk = '0';
150
 
151
      if ciphertext /= x"e72c46c0f5945049" then
152
                        report "RESULT MISMATCH! Test case 2 failed" severity ERROR;
153
                        assert false severity failure;
154
                else
155
                        report "Test case 2 successful" severity note;
156
                end if;
157
 
158
---- Preparation for test case 3 -----------------
159
--   plaintext <= x"ffffffffffffffff";
160
--   key <= x"00000000000000000000";
161
--   expected_ciphertext <= x"a112ffc72f68417b";
162
--------------------------------------------------
163
 
164 3 gajos
                start <= '0';
165
                wait for clk_period;
166
 
167
                plaintext <= (others => '1');
168
                key <= (others => '0');
169
                start <= '1';
170 13 gajos
      wait until ready = '1' and clk = '0';
171
 
172
                if ciphertext /= x"a112ffc72f68417b" then
173
                        report "RESULT MISMATCH! Test case 3 failed" severity ERROR;
174
                        assert false severity failure;
175
                else
176
                        report "Test case 3 successful" severity note;
177
                end if;
178
 
179
---- Preparation for test case 4 -----------------
180
--   plaintext <= x"ffffffffffffffff";
181
--   key <= x"ffffffffffffffffffff";
182
--   expected_ciphertext <= x"3333dcd3213210d2";
183
--------------------------------------------------
184
 
185 3 gajos
                start <= '0';
186
                wait for clk_period;
187
 
188
                plaintext <= (others => '1');
189
                key <= (others => '1');
190
                start <= '1';
191 13 gajos
      wait until ready = '1' and clk = '0';
192 3 gajos
 
193 13 gajos
                if ciphertext /= x"3333dcd3213210d2" then
194
                        report "RESULT MISMATCH! Test case 4 failed" severity ERROR;
195
                        assert false severity failure;
196
                else
197
                        report "Test case 4 successful" severity note;
198
                end if;
199
 
200 3 gajos
                assert false severity failure;
201
 
202
   end process;
203
 
204 13 gajos
END;

powered by: WebSVN 2.1.0

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