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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [testBaud_generator.vhd] - Blame information for rev 38

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 leonardoar
--! @file
2
--! @brief Test baud_generator module
3
 
4
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
5 6 leonardoar
library ieee;
6
use ieee.std_logic_1164.all;
7
use ieee.std_logic_unsigned.all;
8
use ieee.std_logic_arith.all;
9
 
10
--! Use Global Definitions package
11
use work.pkgDefinitions.all;
12
 
13 38 leonardoar
ENTITY testBaud_generator IS
14 6 leonardoar
END testBaud_generator;
15
 
16 38 leonardoar
--! @brief Test baud_generator module
17
--! @details Exercise the baud generator with 50Mhz clock and dividing by 434, finally checking for period of 8.68 us
18 6 leonardoar
ARCHITECTURE behavior OF testBaud_generator IS
19 11 leonardoar
 
20 6 leonardoar
    COMPONENT baud_generator
21 37 leonardoar
    Port ( rst : in STD_LOGIC;                                                                                                          --! Reset Input
22
                          clk : in  STD_LOGIC;                                                                                                          --! Clock input
23
           cycle_wait : in  STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0);  --! Number of cycles to wait for baud generation
24
                          baud_oversample : out std_logic;                                                                              --! Oversample(8x) version of baud (Used on serial_receiver)
25
           baud : out  STD_LOGIC);                                                                                                      --! Baud generation output (Used on serial_transmitter)
26 6 leonardoar
    END COMPONENT;
27
 
28
 
29
   --Inputs
30 37 leonardoar
   signal rst : std_logic := '0';                                                                                                                                                --! Signal to connect with UUT
31
   signal clk : std_logic := '0';                                                                                                                                                --! Signal to connect with UUT
32
   signal cycle_wait : std_logic_vector((nBitsLarge-1) downto 0) := (others => '0');      --! Signal to connect with UUT
33 6 leonardoar
 
34
        --Outputs
35 37 leonardoar
   signal baud : std_logic;                                     --! Signal to connect with UUT
36
        signal baud_oversample : std_logic;             --! Signal to connect with UUT
37 6 leonardoar
 
38 8 leonardoar
   -- Clock period definitions (1.8432MHz)
39 38 leonardoar
   constant clk_period : time := 20 ns; -- 0.543us (1.8432Mhz) 20ns (50Mhz)
40 6 leonardoar
 
41
BEGIN
42
 
43 36 leonardoar
        --! Instantiate the Unit Under Test (UUT)
44 6 leonardoar
   uut: baud_generator PORT MAP (
45
          rst => rst,
46
          clk => clk,
47
          cycle_wait => cycle_wait,
48 11 leonardoar
                         baud_oversample => baud_oversample,
49 6 leonardoar
          baud => baud
50
        );
51
 
52
   -- Clock process definitions
53
   clk_process :process
54
   begin
55
                clk <= '0';
56
                wait for clk_period/2;
57
                clk <= '1';
58
                wait for clk_period/2;
59
   end process;
60
 
61
 
62
   -- Stimulus process
63
   stim_proc: process
64 38 leonardoar
   variable t1 : time;
65
        variable t2 : time;
66
        variable period : time; -- 1/115200 = 8.68 us
67
        begin
68
      -- Test the baud generator waiting for 434 clock cycles from 50MHz clock
69 6 leonardoar
                rst <= '1';
70 38 leonardoar
                cycle_wait <= conv_std_logic_vector(434, (nBitsLarge)); -- 50000000/115200
71
      wait for clk_period;
72 6 leonardoar
                rst <= '0';
73
 
74 38 leonardoar
      wait until baud = '1';
75
                t1 := now;      -- Get current simulation time
76
                wait until baud = '0';
77
                wait until baud = '1';
78
                t2 := now;      -- Get current simulation time
79
                wait until baud = '0';
80
                wait until baud = '1';
81
                report "Current sim time=" & time'image(now);
82
                period := t2 - t1;
83
 
84
                -- Verify if we have the right period 1/115200 = 8.68 us
85
                assert period = 8.68 us report "Wrong period expecter 8.68 us. got: "& time'image(period) severity failure;
86
 
87
                -- Stop Simulation
88 6 leonardoar
                assert false report "NONE. End of simulation." severity failure;
89
 
90
      wait;
91
   end process;
92
 
93
END;

powered by: WebSVN 2.1.0

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