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

Show entire file | Details | Blame | View Log

Rev 37 Rev 38
Line 1... Line 1...
--! 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;
 
 
Line 8... Line 11...
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
Line 29... Line 34...
        --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 (
Line 54... Line 59...
   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;

powered by: WebSVN 2.1.0

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