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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [testSerial_transmitter.vhd] - Diff between revs 37 and 39

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

Rev 37 Rev 39
--! Test serial_transmitter module
--! @file
 
--! @brief Test serial_transmitter module
 
 
 
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
LIBRARY ieee;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_1164.ALL;
 
 
--! Use CPU Definitions package
--! Use CPU Definitions package
use work.pkgDefinitions.all;
use work.pkgDefinitions.all;
 
 
ENTITY testSerial_transmitter IS
ENTITY testSerial_transmitter IS
END testSerial_transmitter;
END testSerial_transmitter;
 
 
 
--! @brief Test serial_transmitter module
 
--! @details Just send the date over the serial_out and analyse the results
ARCHITECTURE behavior OF testSerial_transmitter IS
ARCHITECTURE behavior OF testSerial_transmitter IS
 
 
    -- Component Declaration for the Unit Under Test (UUT)
    -- Component Declaration for the Unit Under Test (UUT)
 
 
    COMPONENT serial_transmitter
    COMPONENT serial_transmitter
    Port ( rst : in  STD_LOGIC;                                                                                         --! Reset input
    Port ( rst : in  STD_LOGIC;                                                                                         --! Reset input
           baudClk : in  STD_LOGIC;                                                                                     --! Baud rate clock input
           baudClk : in  STD_LOGIC;                                                                                     --! Baud rate clock input
           data_byte : in  STD_LOGIC_VECTOR ((nBits-1) downto 0);        --! Byte to be sent
           data_byte : in  STD_LOGIC_VECTOR ((nBits-1) downto 0);        --! Byte to be sent
                          data_sent : out STD_LOGIC;                                                                            --! Indicate that byte has been sent
                          data_sent : out STD_LOGIC;                                                                            --! Indicate that byte has been sent
           serial_out : out  STD_LOGIC);                                                                        --! Uart serial output
           serial_out : out  STD_LOGIC);                                                                        --! Uart serial output
    END COMPONENT;
    END COMPONENT;
 
 
 
 
   --Inputs
   --Inputs
   signal rst : std_logic := '0';                                                                                                        --! Signal to connect with UUT
   signal rst : std_logic := '0';                                                                                                        --! Signal to connect with UUT
   signal baudClk : std_logic := '0';                                                                                            --! Signal to connect with UUT
   signal baudClk : std_logic := '0';                                                                                            --! Signal to connect with UUT
   signal data_byte : std_logic_vector(7 downto 0) := (others => '0');    --! Signal to connect with UUT
   signal data_byte : std_logic_vector(7 downto 0) := (others => '0');    --! Signal to connect with UUT
 
 
        --Outputs
        --Outputs
   signal data_sent : std_logic;                                                                                                                --! Signal to connect with UUT
   signal data_sent : std_logic;                                                                                                                --! Signal to connect with UUT
   signal serial_out : std_logic;                                                                                                       --! Signal to connect with UUT
   signal serial_out : std_logic;                                                                                                       --! Signal to connect with UUT
 
 
   -- Clock period definitions
   -- Clock period definitions
   constant baudClk_period : time := 10 ns;
   constant baudClk_period : time := 10 ns;
 
 
BEGIN
BEGIN
 
 
        --! Instantiate the Unit Under Test (UUT)
        --! Instantiate the Unit Under Test (UUT)
   uut: serial_transmitter PORT MAP (
   uut: serial_transmitter PORT MAP (
          rst => rst,
          rst => rst,
          baudClk => baudClk,
          baudClk => baudClk,
          data_byte => data_byte,
          data_byte => data_byte,
          data_sent => data_sent,
          data_sent => data_sent,
          serial_out => serial_out
          serial_out => serial_out
        );
        );
 
 
   -- Clock process definitions
   -- Clock process definitions
   baudClk_process :process
   baudClk_process :process
   begin
   begin
                baudClk <= '0';
                baudClk <= '0';
                wait for baudClk_period/2;
                wait for baudClk_period/2;
                baudClk <= '1';
                baudClk <= '1';
                wait for baudClk_period/2;
                wait for baudClk_period/2;
   end process;
   end process;
 
 
 
 
   -- Stimulus process
   -- Stimulus process
   stim_proc: process
   stim_proc: process
   begin
   begin
      -- Prepare the data to be sent 0x55
      -- Prepare the data to be sent 0x55
                rst <= '1';
                rst <= '1';
                data_byte <= "01010101";
                data_byte <= "01010101";
      wait for 50 ns;
      wait for 50 ns;
                rst <= '0';
                rst <= '0';
 
 
 
                -- Test serial data...
 
                wait until rising_edge(baudClk); -- Start bit
 
                wait for 1 ns;
 
                assert serial_out = '0' report "Invalid value  "  severity failure;
 
 
 
                for numBit in 0 to 7 loop
 
                        wait until rising_edge(baudClk);
 
                        wait for 1 ns;
 
                        -- The image attribute convert a typed value into a string
 
                        report "Testing bit:" & integer'image(numBit) & " value " & std_logic'image(serial_out);
 
                        assert serial_out = data_byte(numBit) report "Invalid value on bit:"  severity failure;
 
                end loop;
 
 
      wait until data_sent = '1';
      wait until data_sent = '1';
                wait for baudClk_period*3;
                wait for baudClk_period*3;
 
 
                -- Prepare the data to be sent
                -- Prepare the data to be sent
                rst <= '1';
                rst <= '1';
                data_byte <= "11000100";
                data_byte <= "11000100";
      wait for 50 ns;
      wait for 50 ns;
                rst <= '0';
                rst <= '0';
 
 
 
                -- Test serial data...
 
                wait until rising_edge(baudClk); -- Start bit
 
                wait for 1 ns;
 
                assert serial_out = '0' report "Invalid value  "  severity failure;
 
 
 
                for numBit in 0 to (data_byte'LENGTH-1) loop
 
                        -- Wait for the clock rising edge
 
                        wait until rising_edge(baudClk);
 
                        wait for 1 ns;
 
                        report "Testing bit:" & integer'image(numBit) & " value " & std_logic'image(serial_out);
 
                        assert serial_out = data_byte(numBit) report "Invalid value on bit:"  severity failure;
 
                end loop;
 
 
 
 
      wait until data_sent = '1';
      wait until data_sent = '1';
                wait for baudClk_period*3;
                wait for baudClk_period*3;
 
 
                -- Stop Simulation
                -- Stop Simulation
                assert false report "NONE. End of simulation." severity failure;
                assert false report "NONE. End of simulation." severity failure;
 
 
      wait;
      wait;
   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.