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 23

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 14 leonardoar
    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 13 leonardoar
                          start : in std_logic;                                                                                                         -- Start (Strobe)
23
                          done : out std_logic;                                                                                                         -- Done (ACK)
24 14 leonardoar
           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 13 leonardoar
                          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 14 leonardoar
           tx_data_sent : in  std_logic;                                                                                        -- Signal comming from serial_transmitter
30
                          tx_start : out std_logic;                                                                                             -- Signal to start sending serial data...
31 13 leonardoar
                          rst_comm_blocks : out std_logic;                                                                              -- Reset Communication blocks
32 14 leonardoar
           rx_data_ready : in  std_logic);
33 13 leonardoar
    END COMPONENT;
34
 
35
 
36
   --Inputs
37
   signal rst : std_logic := '0';
38
   signal clk : std_logic := '0';
39
   signal WE : std_logic := '0';
40
   signal reg_addr : std_logic_vector(1 downto 0) := (others => '0');
41
   signal start : std_logic := '0';
42
   signal DAT_I : std_logic_vector((nBitsLarge-1) downto 0) := (others => '0');
43
   signal data_byte_rx : std_logic_vector((nBits-1) downto 0) := (others => '0');
44
   signal tx_data_sent : std_logic := '0';
45
   signal rx_data_ready : std_logic := '0';
46
 
47
        --Outputs
48
   signal done : std_logic;
49 14 leonardoar
        signal tx_start : std_logic;
50 13 leonardoar
        signal rst_comm_blocks : std_logic;
51
   signal DAT_O : std_logic_vector((nBitsLarge-1) downto 0);
52
   signal baud_wait : std_logic_vector((nBitsLarge-1) downto 0);
53
   signal data_byte_tx : std_logic_vector((nBits-1) downto 0);
54
 
55
   -- Clock period definitions
56 21 leonardoar
   constant clk_period : time := 20 ns; -- 20ns (50Mhz)
57 13 leonardoar
 
58
BEGIN
59
 
60
        -- Instantiate the Unit Under Test (UUT)
61
   uut: uart_control PORT MAP (
62
          rst => rst,
63
          clk => clk,
64
          WE => WE,
65
          reg_addr => reg_addr,
66
          start => start,
67
          done => done,
68
          DAT_I => DAT_I,
69
          DAT_O => DAT_O,
70
          baud_wait => baud_wait,
71
          data_byte_tx => data_byte_tx,
72
          data_byte_rx => data_byte_rx,
73
          tx_data_sent => tx_data_sent,
74
                         rst_comm_blocks => rst_comm_blocks,
75 14 leonardoar
                         tx_start => tx_start,
76 13 leonardoar
          rx_data_ready => rx_data_ready
77
        );
78
 
79
   -- Clock process definitions
80
   clk_process :process
81
   begin
82
                clk <= '0';
83
                wait for clk_period/2;
84
                clk <= '1';
85
                wait for clk_period/2;
86
   end process;
87
 
88
 
89
   -- Stimulus process
90
   stim_proc: process
91
   begin
92
      rst <= '1';
93 22 leonardoar
                start <= '0';
94
      wait for clk_period;
95 13 leonardoar
                rst <= '0';
96 22 leonardoar
      wait for clk_period;
97 13 leonardoar
 
98
      -- Configure the clock... 
99
                reg_addr <= "00";
100
                WE <= '1';
101
                start <= '1';
102
                DAT_I <= conv_std_logic_vector(50000000, (nBitsLarge));
103
                wait until done = '1';
104
                WE <= '0';
105
                start <= '0';
106
                reg_addr <= (others => 'U');
107
                wait for clk_period;
108
 
109
                -- Configure the Baud... 
110
                reg_addr <= "01";
111
                WE <= '1';
112
                start <= '1';
113
                DAT_I <= conv_std_logic_vector(115200, (nBitsLarge));
114
                wait until done = '1';
115
                WE <= '0';
116
                start <= '0';
117
                reg_addr <= (others => 'U');
118
 
119 23 leonardoar
                -- Wait some time to configure the communication block
120
                wait for clk_period * 40;
121 13 leonardoar
 
122 23 leonardoar
 
123 13 leonardoar
                -- Ask to send some data...(0x55)
124
                reg_addr <= "10";
125
                WE <= '1';
126
                start <= '1';
127
                DAT_I <= x"00000055";
128 22 leonardoar
                wait until done = '1';
129
                WE <= '0';
130
                start <= '0';
131
                reg_addr <= (others => 'U');
132
                wait for clk_period;
133
 
134
                -- Ask to read some data...
135
                reg_addr <= "11";
136
                WE <= '0';
137
                start <= '1';
138
                wait until done = '1';
139
                start <= '0';
140
                wait for clk_period*10;
141 13 leonardoar
 
142
      -- Stop Simulation
143
                assert false report "NONE. End of simulation." severity failure;
144
   end process;
145
 
146
END;

powered by: WebSVN 2.1.0

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