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

Subversion Repositories salsa20

[/] [salsa20/] [trunk/] [bench/] [tb_salsa20.vhd] - Blame information for rev 4

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

Line No. Rev Author Line
1 4 lukasz.dzi
-- This file is part of Salsa20IpCore.
2
 
3
-- Salsa20IpCore is free software: you can redistribute it and/or modify
4
-- it under the terms of the GNU Lesser General Public License as published by
5
-- the Free Software Foundation, either version 3 of the License, or
6
-- (at your option) any later version.
7
 
8
-- Salsa20IpCore is distributed in the hope that it will be useful,
9
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
10
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
-- GNU Lesser General Public License for more details.
12
 
13
-- You should have received a copy of the GNU Lesser General Public License
14
-- along with Salsa20IpCore.  If not, see <http://www.gnu.org/licenses/>.
15
 
16 3 lukasz.dzi
LIBRARY ieee  ;
17
LIBRARY std  ;
18
library modelsim_lib;
19
 
20
USE ieee.numeric_std.all  ;
21
USE ieee.std_logic_1164.all  ;
22
USE ieee.std_logic_textio.all  ;
23
USE ieee.std_logic_unsigned.all  ;
24
USE std.textio.all  ;
25
use ieee.std_logic_arith.all;
26
use modelsim_lib.util.all;
27
 
28
ENTITY \tb_salsaa.vhd\  IS
29
  generic (
30
      log_file_name : string := "log.txt"
31
    );
32
END ;
33
 
34
ARCHITECTURE \tb_salsaa.vhd_arch\   OF \tb_salsaa.vhd\   IS
35
  SIGNAL data_req   :  std_logic  ;
36
  SIGNAL key   :  std_logic_vector (255 downto 0)  ;
37
  SIGNAL data   :  std_logic_vector (31 downto 0)  ;
38
  SIGNAL start   :  std_logic  ;
39
  SIGNAL clk   :  std_logic  ;
40
  SIGNAL data_valid   :  std_logic  ;
41
  SIGNAL nonce   :  std_logic_vector (63 downto 0)  ;
42
  SIGNAL reset   :  std_logic  ;
43
  COMPONENT salsaa
44
    PORT (
45
      data_req  : in std_logic ;
46
      key  : in std_logic_vector (255 downto 0) ;
47
      data  : out std_logic_vector (31 downto 0) ;
48
      start  : in std_logic ;
49
      clk  : in std_logic ;
50
      data_valid  : out std_logic ;
51
      nonce  : in std_logic_vector (63 downto 0) ;
52
      reset  : in std_logic );
53
  END COMPONENT ;
54
  file log_file : TEXT open write_mode is log_file_name;
55
  variable l : string;
56
 
57
BEGIN
58
 
59
 
60
  DUT  : salsaa
61
    PORT MAP (
62
      data_req   => data_req  ,
63
      key   => key  ,
64
      data   => data  ,
65
      start   => start  ,
66
      clk   => clk  ,
67
      data_valid   => data_valid  ,
68
      nonce   => nonce  ,
69
      reset   => reset   ) ;
70
 
71
key  <= x"201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a090807060504030201"  ;
72
nonce  <= x"0000000000000000"  ;
73
 
74
 
75
-- "Clock Pattern" : dutyCycle = 50
76
-- Start Time = 0 ps, End Time = 1 us, Period = 6666 ps
77
  Process
78
        Begin
79
         clk  <= '0'  ;
80
        wait for 3333 ps ;
81
-- 3333 ps, single loop till start period.
82
        for Z in 1 to 3000
83
        loop
84
            clk  <= '1'  ;
85
           wait for 3333 ps ;
86
            clk  <= '0'  ;
87
           wait for 3333 ps ;
88
-- 996567 ps, repeat pattern in loop.
89
        end  loop;
90
         clk  <= '1'  ;
91
        wait for 3333 ps ;
92
         clk  <= '0'  ;
93
        wait for 100 ps ;
94
-- dumped values till 1 us
95
        wait;
96
 End Process;
97
 
98
 -- "Constant Pattern"
99
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
100
  Process
101
        Begin
102
         reset  <= '0'  ;
103
        wait for 15879 ps ;
104
         reset  <= '1'  ;
105
        wait for 17864 ps ;
106
         reset  <= '0'  ;
107
        wait for 4000000 ps ;
108
-- dumped values till 1 us
109
        wait;
110
 End Process;
111
 
112
 
113
-- "Constant Pattern"
114
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
115
  Process
116
        Begin
117
         start  <= '0'  ;
118
        wait for 33330 ps ;
119
         start  <= '1'  ;
120
        wait for 33330 ps +3333 ps ;
121
         start  <= '0'  ;
122
        wait for 33330 ps+6666 ps;
123
-- dumped values till 1 us
124
        wait;
125
 End Process;
126
 
127
-- "Constant Pattern"
128
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
129
  Process
130
        Begin
131
         data_req  <= '0'  ;
132
        wait for 589941 ps ;
133
         data_req  <= '1'  ;
134
        wait for 6666 ps ;
135
         data_req  <= '0'  ;
136
        wait for 6666 ps ;
137
        for Z in 1 to 300
138
        loop
139
                        data_req  <= '1'  ;
140
                wait for 6666 ps ;
141
                 data_req  <= '0'  ;
142
                wait for 6666 ps ;
143
        end  loop;
144
         data_req  <= '1'  ;
145
        wait for 6666 ps ;
146
         data_req  <= '0'  ;
147
        wait for 4000000 ps ;
148
-- dumped values till 1 us
149
        wait;
150
 End Process;
151
 
152
-- results to file 
153
process
154
begin
155
 
156
 
157
for Z in 1 to 3000 loop
158
        wait until clk = '1';
159
        if data_valid = '1' then
160
                write(l,hstr(data));
161
                writeline(log_file,l);
162
        end if;
163
        wait until clk = '0';
164
end loop;
165
 
166
 
167
end process;
168
 
169
 
170
END;

powered by: WebSVN 2.1.0

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