OpenCores
URL https://opencores.org/ocsvn/camellia-vhdl/camellia-vhdl/trunk

Subversion Repositories camellia-vhdl

[/] [camellia-vhdl/] [trunk/] [looping/] [camellia_tb.vhd] - Blame information for rev 10

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 pfulgoni
 
2
--------------------------------------------------------------------------------
3
-- Designer:      Paolo Fulgoni <pfulgoni@opencores.org>
4
--
5
-- Create Date:   02/19/2008
6 6 pfulgoni
-- Last Update:   04/02/2008
7 3 pfulgoni
-- Project Name:  camellia-vhdl
8
-- Description:   VHDL Test Bench for module camellia
9
--
10
-- Copyright (C) 2008  Paolo Fulgoni
11
-- This file is part of camellia-vhdl.
12
-- camellia-vhdl is free software; you can redistribute it and/or modify
13
-- it under the terms of the GNU General Public License as published by
14
-- the Free Software Foundation; either version 3 of the License, or
15
-- (at your option) any later version.
16
-- camellia-vhdl is distributed in the hope that it will be useful,
17
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
18
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
-- GNU General Public License for more details.
20
-- You should have received a copy of the GNU General Public License
21
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
--
23
-- The Camellia cipher algorithm is 128 bit cipher developed by NTT and
24
-- Mitsubishi Electric researchers.
25
-- http://info.isl.ntt.co.jp/crypt/eng/camellia/
26
--------------------------------------------------------------------------------
27
library IEEE;
28
use IEEE.std_logic_1164.all;
29
 
30
entity camellia_tb is
31
 
32
end camellia_tb;
33
 
34
architecture RTL of camellia_tb is
35
 
36
    component camellia is
37
        port    (
38
                clk        : in  STD_LOGIC;
39
                reset      : in  STD_LOGIC;
40
                data_in    : in  STD_LOGIC_VECTOR (0 to 127);
41 4 pfulgoni
                enc_dec    : in  STD_LOGIC;
42
                data_rdy   : in  STD_LOGIC;
43
                data_acq   : out STD_LOGIC;
44 3 pfulgoni
                key        : in  STD_LOGIC_VECTOR (0 to 255);
45
                k_len      : in  STD_LOGIC_VECTOR (0 to 1);
46 4 pfulgoni
                key_rdy    : in  STD_LOGIC;
47
                key_acq    : out STD_LOGIC;
48
                data_out   : out STD_LOGIC_VECTOR (0 to 127);
49
                output_rdy : out STD_LOGIC
50 3 pfulgoni
                );
51
    end component;
52
 
53
    signal    clk        :  STD_LOGIC;
54
    signal    reset      :  STD_LOGIC;
55
    signal    data_in    :  STD_LOGIC_VECTOR (0 to 127);
56 4 pfulgoni
    signal    enc_dec    :  STD_LOGIC;
57
    signal    data_rdy   :  STD_LOGIC;
58
    signal    data_acq   :  STD_LOGIC;
59 3 pfulgoni
    signal    key        :  STD_LOGIC_VECTOR (0 to 255);
60
    signal    k_len      :  STD_LOGIC_VECTOR (0 to 1);
61 4 pfulgoni
    signal    key_rdy    :  STD_LOGIC;
62
    signal    key_acq    :  STD_LOGIC;
63 3 pfulgoni
    signal    data_out   :  STD_LOGIC_VECTOR (0 to 127);
64 4 pfulgoni
    signal    output_rdy :  STD_LOGIC;
65 3 pfulgoni
 
66
    -- constants
67
    constant KLEN_128    : STD_LOGIC_VECTOR (0 to 1) := "00";
68
    constant KLEN_192    : STD_LOGIC_VECTOR (0 to 1) := "01";
69
    constant KLEN_256    : STD_LOGIC_VECTOR (0 to 1) := "10";
70
    constant ENC         : STD_LOGIC := '0';
71
    constant DEC         : STD_LOGIC := '1';
72 6 pfulgoni
    constant CLK_PERIOD  : TIME := 100 ns;
73 3 pfulgoni
 
74
begin
75
 
76
    uut   : camellia
77 4 pfulgoni
        port map(clk, reset, data_in, enc_dec, data_rdy, data_acq,
78
                 key, k_len, key_rdy, key_acq, data_out, output_rdy);
79 3 pfulgoni
 
80
    tb    : process
81
    begin
82
        reset <= '1';
83 6 pfulgoni
        wait for 80 ns;
84 3 pfulgoni
        reset <= '0';
85 6 pfulgoni
        wait until clk = '1';
86 4 pfulgoni
 
87 3 pfulgoni
        data_in   <= X"0123456789abcdeffedcba9876543210";
88 4 pfulgoni
        enc_dec   <= ENC;
89
        data_rdy  <= '1';
90 3 pfulgoni
        key       <= X"0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff";
91
        k_len     <= KLEN_128;
92 4 pfulgoni
        key_rdy   <= '1';
93
 
94
        wait until key_acq = '1';
95
        key_rdy   <= '0';
96
 
97
        wait until data_acq = '1';
98 3 pfulgoni
        data_in   <= X"67673138549669730857065648eabe43";
99 4 pfulgoni
        enc_dec   <= DEC;
100
 
101 6 pfulgoni
        wait until data_acq = '1';
102
        data_in   <= X"0123456789abcdeffedcba9876543210";
103
        enc_dec   <= ENC;
104
        data_rdy  <= '1';
105
        key       <= X"0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff";
106
        k_len     <= KLEN_192;
107
        key_rdy   <= '1';
108
 
109
        wait until key_acq = '1';
110
        key_rdy   <= '0';
111
 
112
        wait until data_acq = '1';
113
        data_rdy  <= '0';
114
 
115
 
116 3 pfulgoni
        wait;
117
    end process;
118
 
119
    clk_gen  : process
120
    begin
121
        clk <= '0';
122
        wait for CLK_PERIOD / 2;
123
        clk <= '1';
124
        wait for CLK_PERIOD / 2;
125
    end process;
126
 
127
end RTL;

powered by: WebSVN 2.1.0

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