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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [testUart_control.vhd] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 leonardoar
--! Test baud_generator module
2
LIBRARY ieee;
3
USE ieee.std_logic_1164.ALL;
4
use ieee.std_logic_unsigned.all;
5
use ieee.std_logic_arith.all;
6
 
7
--! Use Global Definitions package
8
use work.pkgDefinitions.all;
9
 
10
ENTITY testUart_control IS
11
END testUart_control;
12
 
13
ARCHITECTURE behavior OF testUart_control IS
14
 
15
    -- Component Declaration for the Unit Under Test (UUT)
16
 
17
    COMPONENT uart_control
18
    Port ( rst : in  STD_LOGIC;                                                                                                         -- Global reset
19
           clk : in  STD_LOGIC;                                                                                                         -- Global clock
20
                          WE    : in STD_LOGIC;                                                                                                         -- Write enable
21
           reg_addr : in  STD_LOGIC_VECTOR (1 downto 0);                                         -- Register address
22
                          start : in std_logic;                                                                                                         -- Start (Strobe)
23
                          done : out std_logic;                                                                                                         -- Done (ACK)
24
           DAT_I : in  STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0);               -- Data Input (Wishbone)
25
           DAT_O : out  STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0);              -- Data output (Wishbone)
26
                          baud_wait : out STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0);    -- Signal to control the baud rate frequency
27
                          data_byte_tx : out std_logic_vector((nBits-1) downto 0);               -- 1 Byte to be send to serial_transmitter
28
                          data_byte_rx : in std_logic_vector((nBits-1) downto 0);        -- 1 Byte to be received by serial_receiver
29
           tx_data_sent : in  STD_LOGIC;                                                                                        -- Signal comming from serial_transmitter
30
                          rst_comm_blocks : out std_logic;                                                                              -- Reset Communication blocks
31
           rx_data_ready : in  STD_LOGIC);                                                                              -- Signal comming from serial_receiver
32
    END COMPONENT;
33
 
34
 
35
   --Inputs
36
   signal rst : std_logic := '0';
37
   signal clk : std_logic := '0';
38
   signal WE : std_logic := '0';
39
   signal reg_addr : std_logic_vector(1 downto 0) := (others => '0');
40
   signal start : std_logic := '0';
41
   signal DAT_I : std_logic_vector((nBitsLarge-1) downto 0) := (others => '0');
42
   signal data_byte_rx : std_logic_vector((nBits-1) downto 0) := (others => '0');
43
   signal tx_data_sent : std_logic := '0';
44
   signal rx_data_ready : std_logic := '0';
45
 
46
        --Outputs
47
   signal done : std_logic;
48
        signal rst_comm_blocks : std_logic;
49
   signal DAT_O : std_logic_vector((nBitsLarge-1) downto 0);
50
   signal baud_wait : std_logic_vector((nBitsLarge-1) downto 0);
51
   signal data_byte_tx : std_logic_vector((nBits-1) downto 0);
52
 
53
   -- Clock period definitions
54
   constant clk_period : time := 2 ns; -- 2ns (50Mhz)
55
 
56
BEGIN
57
 
58
        -- Instantiate the Unit Under Test (UUT)
59
   uut: uart_control PORT MAP (
60
          rst => rst,
61
          clk => clk,
62
          WE => WE,
63
          reg_addr => reg_addr,
64
          start => start,
65
          done => done,
66
          DAT_I => DAT_I,
67
          DAT_O => DAT_O,
68
          baud_wait => baud_wait,
69
          data_byte_tx => data_byte_tx,
70
          data_byte_rx => data_byte_rx,
71
          tx_data_sent => tx_data_sent,
72
                         rst_comm_blocks => rst_comm_blocks,
73
          rx_data_ready => rx_data_ready
74
        );
75
 
76
   -- Clock process definitions
77
   clk_process :process
78
   begin
79
                clk <= '0';
80
                wait for clk_period/2;
81
                clk <= '1';
82
                wait for clk_period/2;
83
   end process;
84
 
85
 
86
   -- Stimulus process
87
   stim_proc: process
88
   begin
89
      rst <= '1';
90
      wait for 1 ns;
91
                rst <= '0';
92
      wait for clk_period*3;
93
 
94
      -- Configure the clock... 
95
                reg_addr <= "00";
96
                WE <= '1';
97
                start <= '1';
98
                DAT_I <= conv_std_logic_vector(50000000, (nBitsLarge));
99
                wait until done = '1';
100
                WE <= '0';
101
                start <= '0';
102
                reg_addr <= (others => 'U');
103
                wait for clk_period;
104
 
105
                -- Configure the Baud... 
106
                reg_addr <= "01";
107
                WE <= '1';
108
                start <= '1';
109
                DAT_I <= conv_std_logic_vector(115200, (nBitsLarge));
110
                wait until done = '1';
111
                WE <= '0';
112
                start <= '0';
113
                reg_addr <= (others => 'U');
114
                wait for clk_period;
115
 
116
 
117
                -- Ask to send some data...(0x55)
118
                reg_addr <= "10";
119
                WE <= '1';
120
                start <= '1';
121
                DAT_I <= x"00000055";
122
                wait for clk_period*10;
123
 
124
      -- Stop Simulation
125
                assert false report "NONE. End of simulation." severity failure;
126
   end process;
127
 
128
END;

powered by: WebSVN 2.1.0

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