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

Subversion Repositories usb_dongle_fpga

[/] [usb_dongle_fpga/] [trunk/] [beh/] [toplevel_usb_test.vhd] - Diff between revs 2 and 53

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

Rev 2 Rev 53
------------------------------------------------------------------
------------------------------------------------------------------
-- Universal dongle board source code
-- Universal dongle board source code
-- 
-- 
-- Copyright (C) 2006 Artec Design <jyrit@artecdesign.ee>
-- Copyright (C) 2006 Artec Design <jyrit@artecdesign.ee>
-- 
-- 
-- This source code is free hardware; you can redistribute it and/or
-- This source code is free hardware; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
-- version 2.1 of the License, or (at your option) any later version.
-- 
-- 
-- This source code is distributed in the hope that it will be useful,
-- This source code is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-- Lesser General Public License for more details.
-- Lesser General Public License for more details.
-- 
-- 
-- You should have received a copy of the GNU Lesser General Public
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-- 
-- 
-- 
-- 
-- The complete text of the GNU Lesser General Public License can be found in 
-- The complete text of the GNU Lesser General Public License can be found in 
-- the file 'lesser.txt'.
-- the file 'lesser.txt'.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Company: 
-- Company: 
-- Engineer:
-- Engineer:
--
--
-- Create Date:   18:17:32 09/28/2006
-- Create Date:   18:17:32 09/28/2006
-- Design Name:   design_top
-- Design Name:   design_top
-- Module Name:   C:/projects/USB_dongle/beh/toplevel_usb_test.vhd
-- Module Name:   C:/projects/USB_dongle/beh/toplevel_usb_test.vhd
-- Project Name:  simulation
-- Project Name:  simulation
-- Target Device:  
-- Target Device:  
-- Tool versions:  
-- Tool versions:  
-- Description:   
-- Description:   
-- 
-- 
-- VHDL Test Bench Created by ISE for module: design_top
-- VHDL Test Bench Created by ISE for module: design_top
--
--
-- Dependencies:
-- Dependencies:
-- 
-- 
-- Revision:
-- Revision:
-- Revision 0.01 - File Created
-- Revision 0.01 - File Created
-- Additional Comments:
-- Additional Comments:
--
--
-- Notes: 
-- Notes: 
-- This testbench has been automatically generated using types std_logic and
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends 
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends 
-- that these types always be used for the top-level I/O of a design in order 
-- that these types always be used for the top-level I/O of a design in order 
-- to guarantee that the testbench will bind correctly to the post-implementation 
-- to guarantee that the testbench will bind correctly to the post-implementation 
-- simulation model.
-- simulation model.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
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 toplevel_usb_test_vhd IS
ENTITY toplevel_usb_test_vhd IS
END toplevel_usb_test_vhd;
END toplevel_usb_test_vhd;
 
 
ARCHITECTURE behavior OF toplevel_usb_test_vhd IS
ARCHITECTURE behavior OF toplevel_usb_test_vhd IS
 
 
        -- Component Declaration for the Unit Under Test (UUT)
        -- Component Declaration for the Unit Under Test (UUT)
        COMPONENT design_top
        COMPONENT design_top
        PORT(
        PORT(
                sys_clk : IN std_logic;
                sys_clk : IN std_logic;
                resetn : IN std_logic;
                resetn : IN std_logic;
                hdr : OUT std_logic_vector(10 downto 0);
                hdr : OUT std_logic_vector(10 downto 0);
                alt_clk : IN std_logic;
                alt_clk : IN std_logic;
                mode : IN std_logic_vector(1 downto 0);
                mode : IN std_logic_vector(1 downto 0);
                lreset_n : IN std_logic;
                lreset_n : IN std_logic;
                lclk : IN std_logic;
                lclk : IN std_logic;
                fl_sts : IN std_logic;
                fl_sts : IN std_logic;
                usb_txe_n : IN std_logic;
                usb_txe_n : IN std_logic;
                usb_rxf_n : IN std_logic;
                usb_rxf_n : IN std_logic;
                lad : INOUT std_logic_vector(3 downto 0);
                lad : INOUT std_logic_vector(3 downto 0);
                lframe_n : INOUT std_logic;
                lframe_n : INOUT std_logic;
                fl_data : INOUT std_logic_vector(15 downto 0);
                fl_data : INOUT std_logic_vector(15 downto 0);
                usb_bd : INOUT std_logic_vector(7 downto 0);
                usb_bd : INOUT std_logic_vector(7 downto 0);
                seg_out : OUT std_logic_vector(7 downto 0);
                seg_out : OUT std_logic_vector(7 downto 0);
                scn_seg : OUT std_logic_vector(3 downto 0);
                scn_seg : OUT std_logic_vector(3 downto 0);
                led_green : OUT std_logic;
                led_green : OUT std_logic;
                led_red : OUT std_logic;
                led_red : OUT std_logic;
                fl_addr : OUT std_logic_vector(23 downto 0);
                fl_addr : OUT std_logic_vector(23 downto 0);
                fl_ce_n : OUT std_logic;
                fl_ce_n : OUT std_logic;
                fl_oe_n : OUT std_logic;
                fl_oe_n : OUT std_logic;
                fl_we_n : OUT std_logic;
                fl_we_n : OUT std_logic;
                fl_rp_n : OUT std_logic;
                fl_rp_n : OUT std_logic;
                usb_rd_n : OUT std_logic;
                usb_rd_n : OUT std_logic;
                usb_wr : OUT std_logic
                usb_wr : OUT std_logic
                );
                );
        END COMPONENT;
        END COMPONENT;
 
 
        --Inputs
        --Inputs
        SIGNAL sys_clk :  std_logic := '0';
        SIGNAL sys_clk :  std_logic := '0';
        SIGNAL resetn :  std_logic := '0';
        SIGNAL resetn :  std_logic := '0';
        SIGNAL alt_clk :  std_logic := '0';
        SIGNAL alt_clk :  std_logic := '0';
        SIGNAL lreset_n :  std_logic := '0';
        SIGNAL lreset_n :  std_logic := '0';
        SIGNAL lclk :  std_logic := '0';
        SIGNAL lclk :  std_logic := '0';
        SIGNAL fl_sts :  std_logic := '0';
        SIGNAL fl_sts :  std_logic := '0';
        SIGNAL usb_txe_n :  std_logic := '0';
        SIGNAL usb_txe_n :  std_logic := '0';
        SIGNAL usb_rxf_n :  std_logic := '0';
        SIGNAL usb_rxf_n :  std_logic := '0';
        SIGNAL hdr :  std_logic_vector(10 downto 0);
        SIGNAL hdr :  std_logic_vector(10 downto 0);
        SIGNAL mode :  std_logic_vector(1 downto 0) := (others=>'0');
        SIGNAL mode :  std_logic_vector(1 downto 0) := (others=>'0');
 
 
        --BiDirs
        --BiDirs
        SIGNAL lad :  std_logic_vector(3 downto 0);
        SIGNAL lad :  std_logic_vector(3 downto 0);
        SIGNAL lframe_n :  std_logic;
        SIGNAL lframe_n :  std_logic;
        SIGNAL fl_data :  std_logic_vector(15 downto 0);
        SIGNAL fl_data :  std_logic_vector(15 downto 0);
        SIGNAL usb_bd :  std_logic_vector(7 downto 0);
        SIGNAL usb_bd :  std_logic_vector(7 downto 0);
 
 
        --Outputs
        --Outputs
        SIGNAL seg_out :  std_logic_vector(7 downto 0);
        SIGNAL seg_out :  std_logic_vector(7 downto 0);
        SIGNAL scn_seg :  std_logic_vector(3 downto 0);
        SIGNAL scn_seg :  std_logic_vector(3 downto 0);
        SIGNAL led_green :  std_logic;
        SIGNAL led_green :  std_logic;
        SIGNAL led_red :  std_logic;
        SIGNAL led_red :  std_logic;
        SIGNAL fl_addr :  std_logic_vector(23 downto 0);
        SIGNAL fl_addr :  std_logic_vector(23 downto 0);
        SIGNAL fl_ce_n :  std_logic;
        SIGNAL fl_ce_n :  std_logic;
        SIGNAL fl_oe_n :  std_logic;
        SIGNAL fl_oe_n :  std_logic;
        SIGNAL fl_we_n :  std_logic;
        SIGNAL fl_we_n :  std_logic;
        SIGNAL fl_rp_n :  std_logic;
        SIGNAL fl_rp_n :  std_logic;
        SIGNAL usb_rd_n :  std_logic;
        SIGNAL usb_rd_n :  std_logic;
        SIGNAL usb_wr :  std_logic;
        SIGNAL usb_wr :  std_logic;
 
 
BEGIN
BEGIN
 
 
        -- Instantiate the Unit Under Test (UUT)
        -- Instantiate the Unit Under Test (UUT)
        uut: design_top PORT MAP(
        uut: design_top PORT MAP(
                sys_clk => sys_clk,
                sys_clk => sys_clk,
                resetn => resetn,
                resetn => resetn,
                hdr => hdr,
                hdr => hdr,
                alt_clk => alt_clk,
                alt_clk => alt_clk,
                mode => mode,
                mode => mode,
                lad => lad,
                lad => lad,
                lframe_n => lframe_n,
                lframe_n => lframe_n,
                lreset_n => lreset_n,
                lreset_n => lreset_n,
                lclk => lclk,
                lclk => lclk,
                seg_out => seg_out,
                seg_out => seg_out,
                scn_seg => scn_seg,
                scn_seg => scn_seg,
                led_green => led_green,
                led_green => led_green,
                led_red => led_red,
                led_red => led_red,
                fl_addr => fl_addr,
                fl_addr => fl_addr,
                fl_ce_n => fl_ce_n,
                fl_ce_n => fl_ce_n,
                fl_oe_n => fl_oe_n,
                fl_oe_n => fl_oe_n,
                fl_we_n => fl_we_n,
                fl_we_n => fl_we_n,
                fl_data => fl_data,
                fl_data => fl_data,
                fl_rp_n => fl_rp_n,
                fl_rp_n => fl_rp_n,
                fl_sts => fl_sts,
                fl_sts => fl_sts,
                usb_rd_n => usb_rd_n,
                usb_rd_n => usb_rd_n,
                usb_wr => usb_wr,
                usb_wr => usb_wr,
                usb_txe_n => usb_txe_n,
                usb_txe_n => usb_txe_n,
                usb_rxf_n => usb_rxf_n,
                usb_rxf_n => usb_rxf_n,
                usb_bd => usb_bd
                usb_bd => usb_bd
        );
        );
 
 
 clocker : process is
 clocker : process is
  begin
  begin
    wait for 17 ns;
    wait for 17 ns;
    lclk <=not (lclk);
    lclk <=not (lclk);
  end process clocker;
  end process clocker;
 
 
  clocker2 : process is
  clocker2 : process is
  begin
  begin
    wait for 20 ns;
    wait for 20 ns;
    sys_clk <=not (sys_clk);
    sys_clk <=not (sys_clk);
  end process clocker2;
  end process clocker2;
 
 
 
 
        tb : PROCESS
        tb : PROCESS
        BEGIN
        BEGIN
 
 
                -- Wait 100 ns for global reset to finish
                -- Wait 100 ns for global reset to finish
                wait for 100 ns;
                wait for 100 ns;
                resetn <='1';
                resetn <='1';
                lreset_n <='1';
                lreset_n <='1';
                -- Status check COMMAND
                -- Status check COMMAND
                usb_rxf_n <='0';
                usb_rxf_n <='0';
                usb_bd <=x"00";
                usb_bd <=x"00";
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                wait for 20 ns;
                wait for 20 ns;
                usb_bd <=x"C5";
                usb_bd <=x"C5";
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                usb_bd <=(others=>'Z');
                usb_bd <=(others=>'Z');
                usb_rxf_n <='1';
                usb_rxf_n <='1';
                -- END A1 COMMAND 
                -- END A1 COMMAND 
                wait for 800 ns;
                wait for 800 ns;
 
 
                -- A0 COMMAND
                -- A0 COMMAND
                usb_rxf_n <='0';
                usb_rxf_n <='0';
                usb_bd <=x"02";
                usb_bd <=x"02";
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                wait for 20 ns;
                wait for 20 ns;
                usb_bd <=x"A0";
                usb_bd <=x"A0";
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                usb_bd <=(others=>'Z');
                usb_bd <=(others=>'Z');
                usb_rxf_n <='1';
                usb_rxf_n <='1';
                -- END A0 COMMAND 
                -- END A0 COMMAND 
                wait for 800 ns;
                wait for 800 ns;
 
 
                -- A1 COMMAND
                -- A1 COMMAND
                usb_rxf_n <='0';
                usb_rxf_n <='0';
                usb_bd <=x"00";
                usb_bd <=x"00";
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                wait for 20 ns;
                wait for 20 ns;
                usb_bd <=x"A1";
                usb_bd <=x"A1";
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                usb_bd <=(others=>'Z');
                usb_bd <=(others=>'Z');
                usb_rxf_n <='1';
                usb_rxf_n <='1';
                -- END A1 COMMAND 
                -- END A1 COMMAND 
                wait for 800 ns;
                wait for 800 ns;
 
 
                -- A2 COMMAND
                -- A2 COMMAND
                usb_rxf_n <='0';
                usb_rxf_n <='0';
                usb_bd <=x"00";
                usb_bd <=x"00";
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                wait for 20 ns;
                wait for 20 ns;
                usb_bd <=x"A2";
                usb_bd <=x"A2";
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                usb_bd <=(others=>'Z');
                usb_bd <=(others=>'Z');
                usb_rxf_n <='1';
                usb_rxf_n <='1';
                -- END A2 COMMAND 
                -- END A2 COMMAND 
                wait for 800 ns;
                wait for 800 ns;
 
 
                -- 98 COMMAND
                -- 98 COMMAND
                usb_rxf_n <='0';
                usb_rxf_n <='0';
                usb_bd <=x"00";
                usb_bd <=x"00";
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                wait for 20 ns;
                wait for 20 ns;
                usb_bd <=x"98";
                usb_bd <=x"98";
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                usb_bd <=(others=>'Z');
                usb_bd <=(others=>'Z');
                usb_rxf_n <='1';
                usb_rxf_n <='1';
                -- END A2 COMMAND 
                -- END A2 COMMAND 
                wait for 800 ns;
                wait for 800 ns;
 
 
                -- CD COMMAND
                -- CD COMMAND
                usb_rxf_n <='0';
                usb_rxf_n <='0';
                usb_bd <=x"01";
                usb_bd <=x"01";
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                wait for 20 ns;
                wait for 20 ns;
                usb_bd <=x"CD";
                usb_bd <=x"CD";
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                usb_bd <=(others=>'Z');
                usb_bd <=(others=>'Z');
                usb_rxf_n <='1';
                usb_rxf_n <='1';
                -- END CD COMMAND 
                -- END CD COMMAND 
                wait for 800 ns;
                wait for 800 ns;
 
 
                -- E8 COMMAND
                -- E8 COMMAND
                usb_rxf_n <='0';
                usb_rxf_n <='0';
                usb_bd <=x"01";  --this should mean 2 word to write
                usb_bd <=x"01";  --this should mean 2 word to write
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                wait for 20 ns;
                wait for 20 ns;
                usb_bd <=x"E8";
                usb_bd <=x"E8";
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                usb_bd <=(others=>'Z');
                usb_bd <=(others=>'Z');
                usb_rxf_n <='1';
                usb_rxf_n <='1';
                -- END E8 COMMAND 
                -- END E8 COMMAND 
                wait for 2000 ns;
                wait for 2000 ns;
 
 
                -- SEND Data count to flash COMMAND
                -- SEND Data count to flash COMMAND
                usb_rxf_n <='0';
                usb_rxf_n <='0';
                usb_bd <=x"01";  --this should mean 2 word to write
                usb_bd <=x"01";  --this should mean 2 word to write
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                wait for 20 ns;
                wait for 20 ns;
                usb_bd <=x"00";  --count 00 means 1 word
                usb_bd <=x"00";  --count 00 means 1 word
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                usb_bd <=(others=>'Z');
                usb_bd <=(others=>'Z');
                usb_rxf_n <='1';
                usb_rxf_n <='1';
                -- END COMMAND 
                -- END COMMAND 
                wait for 800 ns;
                wait for 800 ns;
 
 
                -- SEND raw Data
                -- SEND raw Data
                usb_rxf_n <='0';
                usb_rxf_n <='0';
                usb_bd <=x"CA";  --this should mean 1 word to write
                usb_bd <=x"CA";  --this should mean 1 word to write
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                wait for 20 ns;
                wait for 20 ns;
                usb_bd <=x"FE";  --count 00 means 1 word
                usb_bd <=x"FE";  --count 00 means 1 word
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                usb_bd <=(others=>'Z');
                usb_bd <=(others=>'Z');
                usb_rxf_n <='1';
                usb_rxf_n <='1';
                -- END send data
                -- END send data
                wait for 800 ns;
                wait for 800 ns;
 
 
                -- SEND raw Data
                -- SEND raw Data
                usb_rxf_n <='0';
                usb_rxf_n <='0';
                usb_bd <=x"BE";  --this should mean 1 word to write
                usb_bd <=x"BE";  --this should mean 1 word to write
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='0'; --wait to go low --first read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                wait for 20 ns;
                wait for 20 ns;
                usb_bd <=x"CD";  --count 00 means 1 word
                usb_bd <=x"CD";  --count 00 means 1 word
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='0'; --wait to go low --second read
                wait until usb_rd_n='1'; --wait to go low
                wait until usb_rd_n='1'; --wait to go low
                usb_bd <=(others=>'Z');
                usb_bd <=(others=>'Z');
                usb_rxf_n <='1';
                usb_rxf_n <='1';
                -- END send data
                -- END send data
                wait for 800 ns;
                wait for 800 ns;
 
 
                wait; -- will wait forever
                wait; -- will wait forever
        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.