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 |
|
|
key <= "00000000000000000000000000000000000000000000000000000000000000000000000000000000";
|
110 |
|
|
num <= "00001";
|
111 |
|
|
wait for clk_period;
|
112 |
|
|
key <= x"c0000000000000008000";
|
113 |
|
|
num <= "00010";
|
114 |
|
|
wait for clk_period;
|
115 |
|
|
key <= x"50001800000000010000";
|
116 |
|
|
num <= "00011";
|
117 |
|
|
wait for clk_period;
|
118 |
|
|
key <= x"8ba27a0eb8783ac96d59";
|
119 |
|
|
num <= "11111";
|
120 |
|
|
wait for clk_period;
|
121 |
|
|
assert false severity failure;
|
122 |
|
|
end process;
|
123 |
|
|
END;
|