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

Subversion Repositories present

[/] [present/] [trunk/] [DecodeTesting/] [bench/] [vhdl/] [keyupd_invTB.vhd] - Blame information for rev 12

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
----     Inverse Key update test bench to be sure that it was      ----
11
---- properly written. As input data, "generated data" by ISE      ----
12
---- simulator present cipher was used.                            ----
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
USE ieee.std_logic_unsigned.all;
48
USE ieee.numeric_std.ALL;
49
 
50
ENTITY keyupd_invTB IS
51
END keyupd_invTB;
52
 
53
ARCHITECTURE behavior OF keyupd_invTB IS
54
 
55
    -- Component Declaration for the Unit Under Test (UUT)
56
 
57
    COMPONENT keyupd_inv
58
    PORT(
59
         key : IN  std_logic_vector(79 downto 0);
60
         num : IN  std_logic_vector(4 downto 0);
61
         keyout : OUT  std_logic_vector(79 downto 0)--;
62
                        --clk, reset : std_logic
63
        );
64
    END COMPONENT;
65
 
66
 
67
   --Inputs
68
   signal key : std_logic_vector(79 downto 0) := (others => '0');
69
   signal num : std_logic_vector(4 downto 0) := (others => '0');
70
        signal clk : std_logic := '0';
71
        signal reset : std_logic := '0';
72
 
73
        --Outputs
74
   signal keyout : std_logic_vector(79 downto 0);
75
 
76
        constant clk_period : time := 1ns;
77
 
78
BEGIN
79
 
80
        -- Instantiate the Unit Under Test (UUT)
81
   uut: keyupd_inv PORT MAP (
82
          key => key,
83
          num => num,
84
          keyout => keyout--,
85
                         --clk => clk,
86
                         --reset => reset
87
        );
88
 
89
   -- No clocks detected in port list. Replace clk below with 
90
   -- appropriate port name 
91
 
92
   clk_process :process
93
   begin
94
                clk <= '0';
95
                wait for clk_period/2;
96
                clk <= '1';
97
                wait for clk_period/2;
98
   end process;
99
 
100
 
101
   -- Stimulus process
102
   stim_proc: process
103
   begin
104
      -- hold reset state for 100ms.
105
                reset <= '1';
106
      wait for 100ns;
107
                reset <='0';
108
      wait for clk_period;
109 11 gajos
 
110
------------- Test case 1 ------------------------
111
--   key <= x"00000000000000000000";
112
--   expected_keyout <= x"c0000000000000008000";
113
--------------------------------------------------
114
 
115
                key <= x"c0000000000000008000";
116 3 gajos
                num <= "00001";
117
                wait for clk_period;
118 11 gajos
 
119
                if keyout /= x"00000000000000000000" then
120
                        report "RESULT MISMATCH! Test case 1 failed" severity ERROR;
121
                        assert false severity failure;
122
                else
123
                        report "Test case 1 successful" severity note;
124
                end if;
125
 
126
------------- Test case 2 ------------------------
127
--   key <= x"c0000000000000008000";
128
--   expected_keyout <= x"50001800000000010000";
129
--------------------------------------------------              
130
 
131
                key <= x"50001800000000010000";
132 3 gajos
                num <= "00010";
133
                wait for clk_period;
134 11 gajos
 
135
                if keyout /= x"c0000000000000008000" then
136
                        report "RESULT MISMATCH! Test case 2 failed" severity ERROR;
137
                        assert false severity failure;
138
                else
139
                        report "Test case 2 successful" severity note;
140
                end if;
141
 
142
------------- Test case 3 ------------------------
143
--   key <= x"60000a00030000018000";
144
--   expected_keyout <= x"50001800000000010000";
145
--------------------------------------------------              
146
 
147
                key <= x"60000a00030000018000";
148 3 gajos
                num <= "00011";
149
                wait for clk_period;
150 11 gajos
 
151
                if keyout /= x"50001800000000010000" then
152
                        report "RESULT MISMATCH! Test case 3 failed" severity ERROR;
153
                        assert false severity failure;
154
                else
155
                        report "Test case 3 successful" severity note;
156
                end if;
157
 
158
------------- Test case 4 ------------------------
159
--   key <= x"8ba27a0eb8783ac96d59";
160
--   expected_keyout <= x"8ba27a0eb8783ac96d59";
161
--------------------------------------------------              
162
 
163
                key <= x"6dab31744f41d7008759";
164 3 gajos
                num <= "11111";
165
                wait for clk_period;
166 11 gajos
 
167
                if keyout /= x"8ba27a0eb8783ac96d59" then
168
                        report "RESULT MISMATCH! Test case 4 failed" severity ERROR;
169
                        assert false severity failure;
170
                else
171
                        report "Test case 4 successful" severity note;
172
                end if;
173
 
174 3 gajos
                assert false severity failure;
175
   end process;
176
END;

powered by: WebSVN 2.1.0

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