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

Subversion Repositories present

[/] [present/] [trunk/] [Pure/] [bench/] [vhdl/] [keyupdTB.vhd] - Blame information for rev 12

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

powered by: WebSVN 2.1.0

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