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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [testSerial_transmitter.vhd] - Blame information for rev 39

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 leonardoar
--! @file
2
--! @brief Test serial_transmitter module
3
 
4
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
5 2 leonardoar
LIBRARY ieee;
6
USE ieee.std_logic_1164.ALL;
7
 
8
--! Use CPU Definitions package
9
use work.pkgDefinitions.all;
10
 
11
ENTITY testSerial_transmitter IS
12
END testSerial_transmitter;
13
 
14 39 leonardoar
--! @brief Test serial_transmitter module
15
--! @details Just send the date over the serial_out and analyse the results
16 2 leonardoar
ARCHITECTURE behavior OF testSerial_transmitter IS
17
 
18
    -- Component Declaration for the Unit Under Test (UUT)
19
 
20
    COMPONENT serial_transmitter
21 37 leonardoar
    Port ( rst : in  STD_LOGIC;                                                                                         --! Reset input
22
           baudClk : in  STD_LOGIC;                                                                                     --! Baud rate clock input
23
           data_byte : in  STD_LOGIC_VECTOR ((nBits-1) downto 0);        --! Byte to be sent
24
                          data_sent : out STD_LOGIC;                                                                            --! Indicate that byte has been sent
25
           serial_out : out  STD_LOGIC);                                                                        --! Uart serial output
26 2 leonardoar
    END COMPONENT;
27
 
28
 
29
   --Inputs
30 37 leonardoar
   signal rst : std_logic := '0';                                                                                                        --! Signal to connect with UUT
31
   signal baudClk : std_logic := '0';                                                                                            --! Signal to connect with UUT
32
   signal data_byte : std_logic_vector(7 downto 0) := (others => '0');    --! Signal to connect with UUT
33 2 leonardoar
 
34
        --Outputs
35 37 leonardoar
   signal data_sent : std_logic;                                                                                                                --! Signal to connect with UUT
36
   signal serial_out : std_logic;                                                                                                       --! Signal to connect with UUT
37 2 leonardoar
 
38
   -- Clock period definitions
39
   constant baudClk_period : time := 10 ns;
40
 
41
BEGIN
42
 
43 36 leonardoar
        --! Instantiate the Unit Under Test (UUT)
44 2 leonardoar
   uut: serial_transmitter PORT MAP (
45
          rst => rst,
46
          baudClk => baudClk,
47
          data_byte => data_byte,
48
          data_sent => data_sent,
49
          serial_out => serial_out
50
        );
51
 
52
   -- Clock process definitions
53
   baudClk_process :process
54
   begin
55
                baudClk <= '0';
56
                wait for baudClk_period/2;
57
                baudClk <= '1';
58
                wait for baudClk_period/2;
59
   end process;
60
 
61
 
62
   -- Stimulus process
63
   stim_proc: process
64
   begin
65
      -- Prepare the data to be sent 0x55
66
                rst <= '1';
67
                data_byte <= "01010101";
68
      wait for 50 ns;
69
                rst <= '0';
70 39 leonardoar
 
71
                -- Test serial data...
72
                wait until rising_edge(baudClk); -- Start bit
73
                wait for 1 ns;
74
                assert serial_out = '0' report "Invalid value  "  severity failure;
75
 
76
                for numBit in 0 to 7 loop
77
                        wait until rising_edge(baudClk);
78
                        wait for 1 ns;
79
                        -- The image attribute convert a typed value into a string
80
                        report "Testing bit:" & integer'image(numBit) & " value " & std_logic'image(serial_out);
81
                        assert serial_out = data_byte(numBit) report "Invalid value on bit:"  severity failure;
82
                end loop;
83 2 leonardoar
 
84
      wait until data_sent = '1';
85
                wait for baudClk_period*3;
86
 
87
                -- Prepare the data to be sent
88
                rst <= '1';
89
                data_byte <= "11000100";
90
      wait for 50 ns;
91
                rst <= '0';
92 39 leonardoar
 
93
                -- Test serial data...
94
                wait until rising_edge(baudClk); -- Start bit
95
                wait for 1 ns;
96
                assert serial_out = '0' report "Invalid value  "  severity failure;
97
 
98
                for numBit in 0 to (data_byte'LENGTH-1) loop
99
                        -- Wait for the clock rising edge
100
                        wait until rising_edge(baudClk);
101
                        wait for 1 ns;
102
                        report "Testing bit:" & integer'image(numBit) & " value " & std_logic'image(serial_out);
103
                        assert serial_out = data_byte(numBit) report "Invalid value on bit:"  severity failure;
104
                end loop;
105
 
106 2 leonardoar
 
107
      wait until data_sent = '1';
108
                wait for baudClk_period*3;
109 11 leonardoar
 
110
                -- Stop Simulation
111
                assert false report "NONE. End of simulation." severity failure;
112 2 leonardoar
 
113
      wait;
114
   end process;
115
 
116
END;

powered by: WebSVN 2.1.0

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