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

Subversion Repositories salsa20

[/] [salsa20/] [trunk/] [bench/] [tb_salsa20.vhd] - Diff between revs 3 and 4

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 4
 
-- This file is part of Salsa20IpCore.
 
 
 
-- Salsa20IpCore is free software: you can redistribute it and/or modify
 
-- it under the terms of the GNU Lesser General Public License as published by
 
-- the Free Software Foundation, either version 3 of the License, or
 
-- (at your option) any later version.
 
 
 
-- Salsa20IpCore is distributed in the hope that it will be useful,
 
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
 
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
-- GNU Lesser General Public License for more details.
 
 
 
-- You should have received a copy of the GNU Lesser General Public License
 
-- along with Salsa20IpCore.  If not, see <http://www.gnu.org/licenses/>.
 
 
LIBRARY ieee  ;
LIBRARY ieee  ;
LIBRARY std  ;
LIBRARY std  ;
library modelsim_lib;
library modelsim_lib;
 
 
USE ieee.numeric_std.all  ;
USE ieee.numeric_std.all  ;
USE ieee.std_logic_1164.all  ;
USE ieee.std_logic_1164.all  ;
USE ieee.std_logic_textio.all  ;
USE ieee.std_logic_textio.all  ;
USE ieee.std_logic_unsigned.all  ;
USE ieee.std_logic_unsigned.all  ;
USE std.textio.all  ;
USE std.textio.all  ;
use ieee.std_logic_arith.all;
use ieee.std_logic_arith.all;
use modelsim_lib.util.all;
use modelsim_lib.util.all;
 
 
ENTITY \tb_salsaa.vhd\  IS
ENTITY \tb_salsaa.vhd\  IS
  generic (
  generic (
      log_file_name : string := "log.txt"
      log_file_name : string := "log.txt"
    );
    );
END ;
END ;
 
 
ARCHITECTURE \tb_salsaa.vhd_arch\   OF \tb_salsaa.vhd\   IS
ARCHITECTURE \tb_salsaa.vhd_arch\   OF \tb_salsaa.vhd\   IS
  SIGNAL data_req   :  std_logic  ;
  SIGNAL data_req   :  std_logic  ;
  SIGNAL key   :  std_logic_vector (255 downto 0)  ;
  SIGNAL key   :  std_logic_vector (255 downto 0)  ;
  SIGNAL data   :  std_logic_vector (31 downto 0)  ;
  SIGNAL data   :  std_logic_vector (31 downto 0)  ;
  SIGNAL start   :  std_logic  ;
  SIGNAL start   :  std_logic  ;
  SIGNAL clk   :  std_logic  ;
  SIGNAL clk   :  std_logic  ;
  SIGNAL data_valid   :  std_logic  ;
  SIGNAL data_valid   :  std_logic  ;
  SIGNAL nonce   :  std_logic_vector (63 downto 0)  ;
  SIGNAL nonce   :  std_logic_vector (63 downto 0)  ;
  SIGNAL reset   :  std_logic  ;
  SIGNAL reset   :  std_logic  ;
  COMPONENT salsaa
  COMPONENT salsaa
    PORT (
    PORT (
      data_req  : in std_logic ;
      data_req  : in std_logic ;
      key  : in std_logic_vector (255 downto 0) ;
      key  : in std_logic_vector (255 downto 0) ;
      data  : out std_logic_vector (31 downto 0) ;
      data  : out std_logic_vector (31 downto 0) ;
      start  : in std_logic ;
      start  : in std_logic ;
      clk  : in std_logic ;
      clk  : in std_logic ;
      data_valid  : out std_logic ;
      data_valid  : out std_logic ;
      nonce  : in std_logic_vector (63 downto 0) ;
      nonce  : in std_logic_vector (63 downto 0) ;
      reset  : in std_logic );
      reset  : in std_logic );
  END COMPONENT ;
  END COMPONENT ;
  file log_file : TEXT open write_mode is log_file_name;
  file log_file : TEXT open write_mode is log_file_name;
  variable l : string;
  variable l : string;
 
 
BEGIN
BEGIN
 
 
 
 
  DUT  : salsaa
  DUT  : salsaa
    PORT MAP (
    PORT MAP (
      data_req   => data_req  ,
      data_req   => data_req  ,
      key   => key  ,
      key   => key  ,
      data   => data  ,
      data   => data  ,
      start   => start  ,
      start   => start  ,
      clk   => clk  ,
      clk   => clk  ,
      data_valid   => data_valid  ,
      data_valid   => data_valid  ,
      nonce   => nonce  ,
      nonce   => nonce  ,
      reset   => reset   ) ;
      reset   => reset   ) ;
 
 
key  <= x"201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a090807060504030201"  ;
key  <= x"201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a090807060504030201"  ;
nonce  <= x"0000000000000000"  ;
nonce  <= x"0000000000000000"  ;
 
 
 
 
-- "Clock Pattern" : dutyCycle = 50
-- "Clock Pattern" : dutyCycle = 50
-- Start Time = 0 ps, End Time = 1 us, Period = 6666 ps
-- Start Time = 0 ps, End Time = 1 us, Period = 6666 ps
  Process
  Process
        Begin
        Begin
         clk  <= '0'  ;
         clk  <= '0'  ;
        wait for 3333 ps ;
        wait for 3333 ps ;
-- 3333 ps, single loop till start period.
-- 3333 ps, single loop till start period.
        for Z in 1 to 3000
        for Z in 1 to 3000
        loop
        loop
            clk  <= '1'  ;
            clk  <= '1'  ;
           wait for 3333 ps ;
           wait for 3333 ps ;
            clk  <= '0'  ;
            clk  <= '0'  ;
           wait for 3333 ps ;
           wait for 3333 ps ;
-- 996567 ps, repeat pattern in loop.
-- 996567 ps, repeat pattern in loop.
        end  loop;
        end  loop;
         clk  <= '1'  ;
         clk  <= '1'  ;
        wait for 3333 ps ;
        wait for 3333 ps ;
         clk  <= '0'  ;
         clk  <= '0'  ;
        wait for 100 ps ;
        wait for 100 ps ;
-- dumped values till 1 us
-- dumped values till 1 us
        wait;
        wait;
 End Process;
 End Process;
 
 
 -- "Constant Pattern"
 -- "Constant Pattern"
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
  Process
  Process
        Begin
        Begin
         reset  <= '0'  ;
         reset  <= '0'  ;
        wait for 15879 ps ;
        wait for 15879 ps ;
         reset  <= '1'  ;
         reset  <= '1'  ;
        wait for 17864 ps ;
        wait for 17864 ps ;
         reset  <= '0'  ;
         reset  <= '0'  ;
        wait for 4000000 ps ;
        wait for 4000000 ps ;
-- dumped values till 1 us
-- dumped values till 1 us
        wait;
        wait;
 End Process;
 End Process;
 
 
 
 
-- "Constant Pattern"
-- "Constant Pattern"
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
  Process
  Process
        Begin
        Begin
         start  <= '0'  ;
         start  <= '0'  ;
        wait for 33330 ps ;
        wait for 33330 ps ;
         start  <= '1'  ;
         start  <= '1'  ;
        wait for 33330 ps +3333 ps ;
        wait for 33330 ps +3333 ps ;
         start  <= '0'  ;
         start  <= '0'  ;
        wait for 33330 ps+6666 ps;
        wait for 33330 ps+6666 ps;
-- dumped values till 1 us
-- dumped values till 1 us
        wait;
        wait;
 End Process;
 End Process;
 
 
-- "Constant Pattern"
-- "Constant Pattern"
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
-- Start Time = 0 ps, End Time = 1 us, Period = 0 ps
  Process
  Process
        Begin
        Begin
         data_req  <= '0'  ;
         data_req  <= '0'  ;
        wait for 589941 ps ;
        wait for 589941 ps ;
         data_req  <= '1'  ;
         data_req  <= '1'  ;
        wait for 6666 ps ;
        wait for 6666 ps ;
         data_req  <= '0'  ;
         data_req  <= '0'  ;
        wait for 6666 ps ;
        wait for 6666 ps ;
        for Z in 1 to 300
        for Z in 1 to 300
        loop
        loop
                        data_req  <= '1'  ;
                        data_req  <= '1'  ;
                wait for 6666 ps ;
                wait for 6666 ps ;
                 data_req  <= '0'  ;
                 data_req  <= '0'  ;
                wait for 6666 ps ;
                wait for 6666 ps ;
        end  loop;
        end  loop;
         data_req  <= '1'  ;
         data_req  <= '1'  ;
        wait for 6666 ps ;
        wait for 6666 ps ;
         data_req  <= '0'  ;
         data_req  <= '0'  ;
        wait for 4000000 ps ;
        wait for 4000000 ps ;
-- dumped values till 1 us
-- dumped values till 1 us
        wait;
        wait;
 End Process;
 End Process;
 
 
-- results to file 
-- results to file 
process
process
begin
begin
 
 
 
 
for Z in 1 to 3000 loop
for Z in 1 to 3000 loop
        wait until clk = '1';
        wait until clk = '1';
        if data_valid = '1' then
        if data_valid = '1' then
                write(l,hstr(data));
                write(l,hstr(data));
                writeline(log_file,l);
                writeline(log_file,l);
        end if;
        end if;
        wait until clk = '0';
        wait until clk = '0';
end loop;
end loop;
 
 
 
 
end process;
end process;
 
 
 
 
END;
END;
 
 

powered by: WebSVN 2.1.0

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