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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [testBaud_generator.vhd] - Diff between revs 37 and 38

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

Rev 37 Rev 38
--! Test baud_generator module
--! @file
 
--! @brief Test baud_generator 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 ieee.std_logic_unsigned.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_arith.all;
 
 
--! Use Global Definitions package
--! Use Global Definitions package
use work.pkgDefinitions.all;
use work.pkgDefinitions.all;
 
 
 ENTITY testBaud_generator IS
ENTITY testBaud_generator IS
END testBaud_generator;
END testBaud_generator;
 
 
 
--! @brief Test baud_generator module
 
--! @details Exercise the baud generator with 50Mhz clock and dividing by 434, finally checking for period of 8.68 us
ARCHITECTURE behavior OF testBaud_generator IS
ARCHITECTURE behavior OF testBaud_generator IS
 
 
    COMPONENT baud_generator
    COMPONENT baud_generator
    Port ( rst : in STD_LOGIC;                                                                                                          --! Reset Input
    Port ( rst : in STD_LOGIC;                                                                                                          --! Reset Input
                          clk : in  STD_LOGIC;                                                                                                          --! Clock input
                          clk : in  STD_LOGIC;                                                                                                          --! Clock input
           cycle_wait : in  STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0);  --! Number of cycles to wait for baud generation
           cycle_wait : in  STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0);  --! Number of cycles to wait for baud generation
                          baud_oversample : out std_logic;                                                                              --! Oversample(8x) version of baud (Used on serial_receiver)
                          baud_oversample : out std_logic;                                                                              --! Oversample(8x) version of baud (Used on serial_receiver)
           baud : out  STD_LOGIC);                                                                                                      --! Baud generation output (Used on serial_transmitter)
           baud : out  STD_LOGIC);                                                                                                      --! Baud generation output (Used on serial_transmitter)
    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 clk : std_logic := '0';                                                                                                                                                --! Signal to connect with UUT
   signal clk : std_logic := '0';                                                                                                                                                --! Signal to connect with UUT
   signal cycle_wait : std_logic_vector((nBitsLarge-1) downto 0) := (others => '0');      --! Signal to connect with UUT
   signal cycle_wait : std_logic_vector((nBitsLarge-1) downto 0) := (others => '0');      --! Signal to connect with UUT
 
 
        --Outputs
        --Outputs
   signal baud : std_logic;                                     --! Signal to connect with UUT
   signal baud : std_logic;                                     --! Signal to connect with UUT
        signal baud_oversample : std_logic;             --! Signal to connect with UUT
        signal baud_oversample : std_logic;             --! Signal to connect with UUT
 
 
   -- Clock period definitions (1.8432MHz)
   -- Clock period definitions (1.8432MHz)
   constant clk_period : time := 0.543 us; -- 0.543us (1.8432Mhz) 2ns (50Mhz)
   constant clk_period : time := 20 ns; -- 0.543us (1.8432Mhz) 20ns (50Mhz)
 
 
BEGIN
BEGIN
 
 
        --! Instantiate the Unit Under Test (UUT)
        --! Instantiate the Unit Under Test (UUT)
   uut: baud_generator PORT MAP (
   uut: baud_generator PORT MAP (
          rst => rst,
          rst => rst,
          clk => clk,
          clk => clk,
          cycle_wait => cycle_wait,
          cycle_wait => cycle_wait,
                         baud_oversample => baud_oversample,
                         baud_oversample => baud_oversample,
          baud => baud
          baud => baud
        );
        );
 
 
   -- Clock process definitions
   -- Clock process definitions
   clk_process :process
   clk_process :process
   begin
   begin
                clk <= '0';
                clk <= '0';
                wait for clk_period/2;
                wait for clk_period/2;
                clk <= '1';
                clk <= '1';
                wait for clk_period/2;
                wait for clk_period/2;
   end process;
   end process;
 
 
 
 
   -- Stimulus process
   -- Stimulus process
   stim_proc: process
   stim_proc: process
 
   variable t1 : time;
 
        variable t2 : time;
 
        variable period : time; -- 1/115200 = 8.68 us
   begin
   begin
      -- Test the baud generator waiting for 16 clock cycles for 1.8432MHz clock
      -- Test the baud generator waiting for 434 clock cycles from 50MHz clock
                rst <= '1';
                rst <= '1';
                cycle_wait <= conv_std_logic_vector(16, (nBitsLarge));
                cycle_wait <= conv_std_logic_vector(434, (nBitsLarge)); -- 50000000/115200
      wait for 2 ns;
      wait for clk_period;
                rst <= '0';
                rst <= '0';
 
 
      wait for clk_period*300;
      wait until baud = '1';
 
                t1 := now;      -- Get current simulation time
 
                wait until baud = '0';
 
                wait until baud = '1';
 
                t2 := now;      -- Get current simulation time
 
                wait until baud = '0';
 
                wait until baud = '1';
 
                report "Current sim time=" & time'image(now);
 
                period := t2 - t1;
 
 
 
                -- Verify if we have the right period 1/115200 = 8.68 us
 
                assert period = 8.68 us report "Wrong period expecter 8.68 us. got: "& time'image(period) severity failure;
 
 
      -- 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.