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

Subversion Repositories salsa20

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

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

Line No. Rev Author Line
1 3 lukasz.dzi
LIBRARY ieee  ;
2
LIBRARY std  ;
3
library modelsim_lib;
4
 
5
USE ieee.numeric_std.all  ;
6
USE ieee.std_logic_1164.all  ;
7
USE ieee.std_logic_textio.all  ;
8
USE ieee.std_logic_unsigned.all  ;
9
USE std.textio.all  ;
10
use ieee.std_logic_arith.all;
11
use modelsim_lib.util.all;
12
 
13
ENTITY \tb_salsaa.vhd\  IS
14
  generic (
15
      log_file_name : string := "log.txt"
16
    );
17
END ;
18
 
19
ARCHITECTURE \tb_salsaa.vhd_arch\   OF \tb_salsaa.vhd\   IS
20
  SIGNAL data_req   :  std_logic  ;
21
  SIGNAL key   :  std_logic_vector (255 downto 0)  ;
22
  SIGNAL data   :  std_logic_vector (31 downto 0)  ;
23
  SIGNAL start   :  std_logic  ;
24
  SIGNAL clk   :  std_logic  ;
25
  SIGNAL data_valid   :  std_logic  ;
26
  SIGNAL nonce   :  std_logic_vector (63 downto 0)  ;
27
  SIGNAL reset   :  std_logic  ;
28
  COMPONENT salsaa
29
    PORT (
30
      data_req  : in std_logic ;
31
      key  : in std_logic_vector (255 downto 0) ;
32
      data  : out std_logic_vector (31 downto 0) ;
33
      start  : in std_logic ;
34
      clk  : in std_logic ;
35
      data_valid  : out std_logic ;
36
      nonce  : in std_logic_vector (63 downto 0) ;
37
      reset  : in std_logic );
38
  END COMPONENT ;
39
  file log_file : TEXT open write_mode is log_file_name;
40
  variable l : string;
41
 
42
BEGIN
43
 
44
 
45
  DUT  : salsaa
46
    PORT MAP (
47
      data_req   => data_req  ,
48
      key   => key  ,
49
      data   => data  ,
50
      start   => start  ,
51
      clk   => clk  ,
52
      data_valid   => data_valid  ,
53
      nonce   => nonce  ,
54
      reset   => reset   ) ;
55
 
56
key  <= x"201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a090807060504030201"  ;
57
nonce  <= x"0000000000000000"  ;
58
 
59
 
60
-- "Clock Pattern" : dutyCycle = 50
61
-- Start Time = 0 ps, End Time = 1 us, Period = 6666 ps
62
  Process
63
        Begin
64
         clk  <= '0'  ;
65
        wait for 3333 ps ;
66
-- 3333 ps, single loop till start period.
67
        for Z in 1 to 3000
68
        loop
69
            clk  <= '1'  ;
70
           wait for 3333 ps ;
71
            clk  <= '0'  ;
72
           wait for 3333 ps ;
73
-- 996567 ps, repeat pattern in loop.
74
        end  loop;
75
         clk  <= '1'  ;
76
        wait for 3333 ps ;
77
         clk  <= '0'  ;
78
        wait for 100 ps ;
79
-- dumped values till 1 us
80
        wait;
81
 End Process;
82
 
83
 -- "Constant Pattern"
84
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
85
  Process
86
        Begin
87
         reset  <= '0'  ;
88
        wait for 15879 ps ;
89
         reset  <= '1'  ;
90
        wait for 17864 ps ;
91
         reset  <= '0'  ;
92
        wait for 4000000 ps ;
93
-- dumped values till 1 us
94
        wait;
95
 End Process;
96
 
97
 
98
-- "Constant Pattern"
99
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
100
  Process
101
        Begin
102
         start  <= '0'  ;
103
        wait for 33330 ps ;
104
         start  <= '1'  ;
105
        wait for 33330 ps +3333 ps ;
106
         start  <= '0'  ;
107
        wait for 33330 ps+6666 ps;
108
-- dumped values till 1 us
109
        wait;
110
 End Process;
111
 
112
-- "Constant Pattern"
113
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
114
  Process
115
        Begin
116
         data_req  <= '0'  ;
117
        wait for 589941 ps ;
118
         data_req  <= '1'  ;
119
        wait for 6666 ps ;
120
         data_req  <= '0'  ;
121
        wait for 6666 ps ;
122
        for Z in 1 to 300
123
        loop
124
                        data_req  <= '1'  ;
125
                wait for 6666 ps ;
126
                 data_req  <= '0'  ;
127
                wait for 6666 ps ;
128
        end  loop;
129
         data_req  <= '1'  ;
130
        wait for 6666 ps ;
131
         data_req  <= '0'  ;
132
        wait for 4000000 ps ;
133
-- dumped values till 1 us
134
        wait;
135
 End Process;
136
 
137
-- results to file 
138
process
139
begin
140
 
141
 
142
for Z in 1 to 3000 loop
143
        wait until clk = '1';
144
        if data_valid = '1' then
145
                write(l,hstr(data));
146
                writeline(log_file,l);
147
        end if;
148
        wait until clk = '0';
149
end loop;
150
 
151
 
152
end process;
153
 
154
 
155
END;

powered by: WebSVN 2.1.0

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