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

Subversion Repositories present

[/] [present/] [trunk/] [DecodeTesting/] [bench/] [vhdl/] [PresentKeyGenTB.vhd] - Blame information for rev 14

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

powered by: WebSVN 2.1.0

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