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

Subversion Repositories present

[/] [present/] [trunk/] [Decode/] [bench/] [vhdl/] [PresentFullDecoderTB.vhd] - Blame information for rev 10

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
----     Present full decoder test bench. Test signals were taken  ----
11
---- from  'pure' Presnet encoder simulation (it is proper work,   ----
12
---- because it was good implementation).                          ----
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 PresentFullDecoderTB IS
53
END PresentFullDecoderTB;
54
 
55
ARCHITECTURE behavior OF PresentFullDecoderTB IS
56
 
57
    -- Component Declaration for the Unit Under Test (UUT)
58
 
59
    COMPONENT PresentFullDecoder
60
    PORT(
61
         ciphertext : IN  std_logic_vector(63 downto 0);
62
         key : IN  std_logic_vector(79 downto 0);
63
         plaintext : 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 ciphertext : 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 plaintext : 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: PresentFullDecoder PORT MAP (
90
          ciphertext => ciphertext,
91
          key => key,
92
          plaintext => plaintext,
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 10 gajos
---- Preparation for test case 1 -----------------
114
--   ciphertext <= x"5579c1387b228445";
115
--   key <= x"00000000000000000000";
116
--   expected_plaintext <= x"0000000000000000";
117
--------------------------------------------------
118
 
119 3 gajos
                reset <= '1';
120
      start <= '0';
121
                ciphertext <= x"5579c1387b228445";
122
                key <= (others => '0');
123
                wait for 100 ns;
124
                reset <= '0';
125
 
126
                ciphertext <= x"5579c1387b228445";
127
                key <= (others => '0');
128
                start <= '1';
129 10 gajos
      wait until ready = '1';
130
 
131
      if plaintext /= x"0000000000000000" then
132
                        report "RESULT MISMATCH! Test case 1 failed" severity ERROR;
133
                        assert false severity failure;
134
                else
135
                        report "Test case 1 successful" severity note;
136
                end if;
137
 
138
---- Preparation for test case 2 -----------------
139
--   ciphertext <= x"e72c46c0f5945049";
140
--   key <= x"ffffffffffffffffffff";
141
--   expected_plaintext <= x"0000000000000000";
142
--------------------------------------------------
143
 
144 3 gajos
                start <= '0';
145
                wait for clk_period;
146
 
147
                ciphertext <= x"e72c46c0f5945049";
148
                key <= (others => '1');
149
                start <= '1';
150 10 gajos
      wait until ready = '1';
151
 
152
      if plaintext /= x"0000000000000000" then
153
                        report "RESULT MISMATCH! Test case 2 failed" severity ERROR;
154
                        assert false severity failure;
155
                else
156
                        report "Test case 2 successful" severity note;
157
                end if;
158
 
159
---- Preparation for test case 3 -----------------
160
--   ciphertext <= x"a112ffc72f68417b";
161
--   key <= x"00000000000000000000";
162
--   expected_plaintext <= x"ffffffffffffffff";
163
--------------------------------------------------
164
 
165 3 gajos
                start <= '0';
166
                wait for clk_period;
167
 
168
                ciphertext <= x"a112ffc72f68417b";
169
                key <= (others => '0');
170
                start <= '1';
171 10 gajos
      wait until ready = '1';
172
 
173
                if plaintext /= x"ffffffffffffffff" then
174
                        report "RESULT MISMATCH! Test case 3 failed" severity ERROR;
175
                        assert false severity failure;
176
                else
177
                        report "Test case 3 successful" severity note;
178
                end if;
179
 
180
---- Preparation for test case 4 -----------------
181
--   ciphertext <= x"3333dcd3213210d2";
182
--   key <= x"ffffffffffffffffffff";
183
--   expected_plaintext <= x"ffffffffffffffff";
184
--------------------------------------------------
185
 
186 3 gajos
                start <= '0';
187
                wait for clk_period;
188
 
189
                ciphertext <= x"3333dcd3213210d2";
190
                key <= (others => '1');
191
                start <= '1';
192 10 gajos
      wait until ready = '1';
193
 
194 3 gajos
                start <= '0';
195
                wait for clk_period;
196
 
197 10 gajos
                if plaintext /= x"ffffffffffffffff" then
198
                        report "RESULT MISMATCH! Test case 4 failed" severity ERROR;
199
                        assert false severity failure;
200
                else
201
                        report "Test case 4 successful" severity note;
202
                end if;
203
 
204 3 gajos
                assert false severity failure;
205
 
206
   end process;
207
 
208
END;

powered by: WebSVN 2.1.0

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