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

Subversion Repositories present

[/] [present/] [trunk/] [Decode/] [bench/] [vhdl/] [sLayer_invTB.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
----     Inverse substitution layer test bench of Present decoder. ----
11
---- Nothing special.                                              ----
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 6 gajos
ENTITY sLayer_invTB IS
50
END sLayer_invTB;
51 3 gajos
 
52
ARCHITECTURE behavior OF sLayer_invTB IS
53
 
54
    -- Component Declaration for the Unit Under Test (UUT)
55
 
56
    COMPONENT slayer_inv
57
    PORT(
58
         input : IN  std_logic_vector(3 downto 0);
59
         output : OUT  std_logic_vector(3 downto 0)
60
        );
61
    END COMPONENT;
62
 
63
 
64
   --Inputs
65
   signal clk : std_logic := '0';
66
   signal reset : std_logic := '0';
67
 
68
        --BiDirs
69
   signal input : std_logic_vector(3 downto 0);
70
   signal output : std_logic_vector(3 downto 0);
71
 
72
   -- Clock period definitions
73
   constant clk_period : time := 1ns;
74
 
75
BEGIN
76
 
77
        -- Instantiate the Unit Under Test (UUT)
78
   uut: slayer_inv PORT MAP (
79
          input => input,
80
          output => output
81
        );
82
 
83
   -- Clock process definitions
84
   clk_process :process
85
   begin
86
                clk <= '0';
87
                wait for clk_period/2;
88
                clk <= '1';
89
                wait for clk_period/2;
90
   end process;
91
 
92
 
93
   -- Stimulus process
94
   stim_proc: process
95
   begin
96
      -- hold reset state for 100ms.
97
                reset <= '1';
98
      wait for 100ns;
99
                reset <= '0';
100
      wait for clk_period;
101 10 gajos
 
102
------------- Test case 1 ------------------------
103
--   input <= x"0";
104
--   expected_output <= x"5";
105
--------------------------------------------------              
106
 
107 3 gajos
                input <= x"0";
108
      wait for clk_period;
109 10 gajos
 
110
                if output /= x"5" then
111
                        report "RESULT MISMATCH! Test case 1 failed" severity ERROR;
112
                        assert false severity failure;
113
                else
114
                        report "Test case 1 successful" severity note;
115
                end if;
116
 
117
------------- Test case 2 ------------------------
118
--   input <= x"A";
119
--   expected_output <= x"6";
120
--------------------------------------------------              
121
 
122 3 gajos
                input <= x"A";
123
      wait for clk_period;
124 10 gajos
 
125
                if output /= x"6" then
126
                        report "RESULT MISMATCH! Test case 2 failed" severity ERROR;
127
                        assert false severity failure;
128
                else
129
                        report "Test case 2 successful" severity note;
130
                end if;
131
 
132
------------- Test case 3 ------------------------
133
--   input <= x"F";
134
--   expected_output <= x"A";
135
--------------------------------------------------              
136
 
137 3 gajos
                input <= x"F";
138
      wait for clk_period;
139 10 gajos
 
140
                if output /= x"A" then
141
                        report "RESULT MISMATCH! Test case 3 failed" severity ERROR;
142
                        assert false severity failure;
143
                else
144
                        report "Test case 3 successful" severity note;
145
                end if;
146
 
147
                -- insert stimulus here 
148 3 gajos
                assert false severity failure;
149
   end process;
150
 
151
END;

powered by: WebSVN 2.1.0

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