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

Subversion Repositories present

[/] [present/] [trunk/] [Decode/] [bench/] [vhdl/] [keyupd_invTB.vhd] - Diff between revs 4 and 10

Only display areas with differences | Details | Blame | View Log

Rev 4 Rev 10
-----------------------------------------------------------------------
-----------------------------------------------------------------------
----                                                               ----
----                                                               ----
---- Present - a lightweight block cipher project                  ----
---- Present - a lightweight block cipher project                  ----
----                                                               ----
----                                                               ----
---- This file is part of the Present - a lightweight block        ----
---- This file is part of the Present - a lightweight block        ----
---- cipher project                                                ----
---- cipher project                                                ----
---- http://www.http://opencores.org/project,present               ----
---- http://www.http://opencores.org/project,present               ----
----                                                               ----
----                                                               ----
---- Description:                                                  ----
---- Description:                                                  ----
----     Inverse Key update test bench to be sure that it was      ----
----     Inverse Key update test bench to be sure that it was      ----
---- properly written. As input data, "generated data" by ISE      ----
---- properly written. As input data, "generated data" by ISE      ----
---- simulator present cipher was used.                            ----
---- simulator present cipher was used.                            ----
---- To Do:                                                        ----
---- To Do:                                                        ----
----                                                               ----
----                                                               ----
---- Author(s):                                                    ----
---- Author(s):                                                    ----
---- - Krzysztof Gajewski, gajos@opencores.org                     ----
---- - Krzysztof Gajewski, gajos@opencores.org                     ----
----                       k.gajewski@gmail.com                    ----
----                       k.gajewski@gmail.com                    ----
----                                                               ----
----                                                               ----
-----------------------------------------------------------------------
-----------------------------------------------------------------------
----                                                               ----
----                                                               ----
---- Copyright (C) 2013 Authors and OPENCORES.ORG                  ----
---- Copyright (C) 2013 Authors and OPENCORES.ORG                  ----
----                                                               ----
----                                                               ----
---- This source file may be used and distributed without          ----
---- This source file may be used and distributed without          ----
---- restriction provided that this copyright statement is not     ----
---- restriction provided that this copyright statement is not     ----
---- removed from the file and that any derivative work contains   ----
---- removed from the file and that any derivative work contains   ----
---- the original copyright notice and the associated disclaimer.  ----
---- the original copyright notice and the associated disclaimer.  ----
----                                                               ----
----                                                               ----
---- This source file is free software; you can redistribute it    ----
---- This source file is free software; you can redistribute it    ----
---- and-or modify it under the terms of the GNU Lesser General    ----
---- and-or modify it under the terms of the GNU Lesser General    ----
---- Public License as published by the Free Software Foundation;  ----
---- Public License as published by the Free Software Foundation;  ----
---- either version 2.1 of the License, or (at your option) any    ----
---- either version 2.1 of the License, or (at your option) any    ----
---- later version.                                                ----
---- later version.                                                ----
----                                                               ----
----                                                               ----
---- This source is distributed in the hope that it will be        ----
---- This source is distributed in the hope that it will be        ----
---- useful, but WITHOUT ANY WARRANTY; without even the implied    ----
---- useful, but WITHOUT ANY WARRANTY; without even the implied    ----
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       ----
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       ----
---- PURPOSE. See the GNU Lesser General Public License for more   ----
---- PURPOSE. See the GNU Lesser General Public License for more   ----
---- details.                                                      ----
---- details.                                                      ----
----                                                               ----
----                                                               ----
---- You should have received a copy of the GNU Lesser General     ----
---- You should have received a copy of the GNU Lesser General     ----
---- Public License along with this source; if not, download it    ----
---- Public License along with this source; if not, download it    ----
---- from http://www.opencores.org/lgpl.shtml                      ----
---- from http://www.opencores.org/lgpl.shtml                      ----
----                                                               ----
----                                                               ----
-----------------------------------------------------------------------
-----------------------------------------------------------------------
LIBRARY ieee;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;
USE ieee.numeric_std.ALL;
 
 
ENTITY keyupd_invTB IS
ENTITY keyupd_invTB IS
END keyupd_invTB;
END keyupd_invTB;
 
 
ARCHITECTURE behavior OF keyupd_invTB IS
ARCHITECTURE behavior OF keyupd_invTB IS
 
 
    -- Component Declaration for the Unit Under Test (UUT)
    -- Component Declaration for the Unit Under Test (UUT)
 
 
    COMPONENT keyupd_inv
    COMPONENT keyupd_inv
    PORT(
    PORT(
         key : IN  std_logic_vector(79 downto 0);
         key : IN  std_logic_vector(79 downto 0);
         num : IN  std_logic_vector(4 downto 0);
         num : IN  std_logic_vector(4 downto 0);
         keyout : OUT  std_logic_vector(79 downto 0)--;
         keyout : OUT  std_logic_vector(79 downto 0)--;
                        --clk, reset : std_logic
                        --clk, reset : std_logic
        );
        );
    END COMPONENT;
    END COMPONENT;
 
 
 
 
   --Inputs
   --Inputs
   signal key : std_logic_vector(79 downto 0) := (others => '0');
   signal key : std_logic_vector(79 downto 0) := (others => '0');
   signal num : std_logic_vector(4 downto 0) := (others => '0');
   signal num : std_logic_vector(4 downto 0) := (others => '0');
        signal clk : std_logic := '0';
        signal clk : std_logic := '0';
        signal reset : std_logic := '0';
        signal reset : std_logic := '0';
 
 
        --Outputs
        --Outputs
   signal keyout : std_logic_vector(79 downto 0);
   signal keyout : std_logic_vector(79 downto 0);
 
 
        constant clk_period : time := 1ns;
        constant clk_period : time := 1ns;
 
 
BEGIN
BEGIN
 
 
        -- Instantiate the Unit Under Test (UUT)
        -- Instantiate the Unit Under Test (UUT)
   uut: keyupd_inv PORT MAP (
   uut: keyupd_inv PORT MAP (
          key => key,
          key => key,
          num => num,
          num => num,
          keyout => keyout--,
          keyout => keyout--,
                         --clk => clk,
                         --clk => clk,
                         --reset => reset
                         --reset => reset
        );
        );
 
 
   -- No clocks detected in port list. Replace clk below with 
   -- No clocks detected in port list. Replace clk below with 
   -- appropriate port name 
   -- appropriate port name 
 
 
   clk_process :process
   clk_process :process
   begin
   begin
                clk <= '0';
                clk <= '0';
                wait for clk_period/2;
                wait for clk_period/2;
                clk <= '1';
                clk <= '1';
                wait for clk_period/2;
                wait for clk_period/2;
   end process;
   end process;
 
 
 
 
   -- Stimulus process
   -- Stimulus process
   stim_proc: process
   stim_proc: process
   begin
   begin
      -- hold reset state for 100ms.
      -- hold reset state for 100ms.
                reset <= '1';
                reset <= '1';
      wait for 100ns;
      wait for 100ns;
                reset <='0';
                reset <='0';
      wait for clk_period;
      wait for clk_period;
                key <= "00000000000000000000000000000000000000000000000000000000000000000000000000000000";
 
 
------------- Test case 1 ------------------------
 
--   key <= x"00000000000000000000";
 
--   expected_keyout <= x"c0000000000000008000";
 
--------------------------------------------------
 
 
 
                key <= x"c0000000000000008000";
                num <= "00001";
                num <= "00001";
                wait for clk_period;
                wait for clk_period;
                key <= x"c0000000000000008000";
 
 
                if keyout /= x"00000000000000000000" then
 
                        report "RESULT MISMATCH! Test case 1 failed" severity ERROR;
 
                        assert false severity failure;
 
                else
 
                        report "Test case 1 successful" severity note;
 
                end if;
 
 
 
------------- Test case 2 ------------------------
 
--   key <= x"c0000000000000008000";
 
--   expected_keyout <= x"50001800000000010000";
 
--------------------------------------------------              
 
 
 
                key <= x"50001800000000010000";
                num <= "00010";
                num <= "00010";
                wait for clk_period;
                wait for clk_period;
                key <= x"50001800000000010000";
 
 
                if keyout /= x"c0000000000000008000" then
 
                        report "RESULT MISMATCH! Test case 2 failed" severity ERROR;
 
                        assert false severity failure;
 
                else
 
                        report "Test case 2 successful" severity note;
 
                end if;
 
 
 
------------- Test case 3 ------------------------
 
--   key <= x"60000a00030000018000";
 
--   expected_keyout <= x"50001800000000010000";
 
--------------------------------------------------              
 
 
 
                key <= x"60000a00030000018000";
                num <= "00011";
                num <= "00011";
                wait for clk_period;
                wait for clk_period;
                key <= x"8ba27a0eb8783ac96d59";
 
 
                if keyout /= x"50001800000000010000" then
 
                        report "RESULT MISMATCH! Test case 3 failed" severity ERROR;
 
                        assert false severity failure;
 
                else
 
                        report "Test case 3 successful" severity note;
 
                end if;
 
 
 
------------- Test case 4 ------------------------
 
--   key <= x"8ba27a0eb8783ac96d59";
 
--   expected_keyout <= x"8ba27a0eb8783ac96d59";
 
--------------------------------------------------              
 
 
 
                key <= x"6dab31744f41d7008759";
                num <= "11111";
                num <= "11111";
                wait for clk_period;
                wait for clk_period;
 
 
 
                if keyout /= x"8ba27a0eb8783ac96d59" then
 
                        report "RESULT MISMATCH! Test case 4 failed" severity ERROR;
 
                        assert false severity failure;
 
                else
 
                        report "Test case 4 successful" severity note;
 
                end if;
 
 
                assert false severity failure;
                assert false severity failure;
   end process;
   end process;
 
 

powered by: WebSVN 2.1.0

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