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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [uart_wishbone_slave.vhd] - Blame information for rev 36

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 leonardoar
--! @file
2
--! @brief Top wishbone slave for the uart (Connects uart_control and uart_communication_blocks)
3
 
4 14 leonardoar
library IEEE;
5
use IEEE.STD_LOGIC_1164.ALL;
6
 
7
--! Use CPU Definitions package
8
use work.pkgDefinitions.all;
9
 
10
entity uart_wishbone_slave is
11 36 leonardoar
    Port ( RST_I : in  STD_LOGIC;                                                               --! Reset Input
12
           CLK_I : in  STD_LOGIC;                                                               --! Clock Input
13
           ADR_I0 : in  STD_LOGIC_VECTOR (1 downto 0);   --! Address input
14
           DAT_I0 : in  STD_LOGIC_VECTOR (31 downto 0);  --! Data Input 0
15
           DAT_O0 : out  STD_LOGIC_VECTOR (31 downto 0); --! Data Output 0
16
           WE_I : in  STD_LOGIC;                                                                        --! Write enable input
17
           STB_I : in  STD_LOGIC;                                                               --! Strobe input (Works like a chip select)
18
           ACK_O : out  STD_LOGIC;                                                              --! Ack output
19
 
20
                          -- NON-WISHBONE Signals
21
                          serial_in : in std_logic;                                                     --! Uart serial input
22
                          data_Avaible : out std_logic;                                         --! Flag to indicate data avaible                                       
23 14 leonardoar
                          serial_out : out std_logic
24
                          );
25
end uart_wishbone_slave;
26
 
27 36 leonardoar
--! @brief Top uart_wishbone_slave architecture
28
--! @details Connect the control unit and the communication blocks
29 14 leonardoar
architecture Behavioral of uart_wishbone_slave is
30
component uart_control is
31 36 leonardoar
   Port ( rst : in  std_logic;                                                                                                          --! Global reset
32
           clk : in  std_logic;                                                                                                         --! Global clock
33
                          WE    : in std_logic;                                                                                                         --! Write enable
34
           reg_addr : in  std_logic_vector (1 downto 0);                                         --! Register address
35
                          start : in std_logic;                                                                                                         --! Start (Strobe)
36
                          done : out std_logic;                                                                                                         --! Done (ACK)
37
           DAT_I : in  std_logic_vector ((nBitsLarge-1) downto 0);               --! Data Input (Wishbone)
38
           DAT_O : out  std_logic_vector ((nBitsLarge-1) downto 0);              --! Data output (Wishbone)
39
                          baud_wait : out std_logic_vector ((nBitsLarge-1) downto 0);    --! Signal to control the baud rate frequency
40
                          data_byte_tx : out std_logic_vector((nBits-1) downto 0);               --! 1 Byte to be send to serial_transmitter
41
                          data_byte_rx : in std_logic_vector((nBits-1) downto 0);        --! 1 Byte to be received by serial_receiver
42
           tx_data_sent : in  std_logic;                                                                                        --! Signal comming from serial_transmitter
43
                          tx_start : out std_logic;                                                                                             --! Signal to start sending serial data...
44
                          rst_comm_blocks : out std_logic;                                                                              --! Reset Communication blocks                    
45 14 leonardoar
           rx_data_ready : in  std_logic);
46
end component;
47
 
48
component uart_communication_blocks is
49 36 leonardoar
    Port ( rst : in  STD_LOGIC;                                                                                                                 --! Global reset
50
           clk : in  STD_LOGIC;                                                                                                                 --! Global clock
51
                          cycle_wait_baud : in std_logic_vector((nBitsLarge-1) downto 0);        --! Number of cycles to wait in order to generate desired baud
52
           byte_tx : in  STD_LOGIC_VECTOR ((nBits-1) downto 0);                          --! Byte to transmit
53
           byte_rx : out  STD_LOGIC_VECTOR ((nBits-1) downto 0);                         --! Byte to receive
54
           data_sent_tx : out  STD_LOGIC;                                                                                               --! Indicate that byte has been sent
55
           data_received_rx : out  STD_LOGIC;                                                                           --! Indicate that we got a byte
56
                          serial_out : out std_logic;                                                                                                   --! Uart serial out
57
                          serial_in : in std_logic;                                                                                                     --! Uart serial in
58
           start_tx : in  STD_LOGIC);                                                                                                   --! Initiate transmission
59 14 leonardoar
end component;
60
signal baud_wait : std_logic_vector((nBitsLarge-1) downto 0);
61
signal tx_data_sent : std_logic;
62
signal tx_start : std_logic;
63
signal rst_comm_blocks : std_logic;
64
signal rx_data_ready : std_logic;
65
signal data_byte_tx : std_logic_vector(7 downto 0);
66
signal data_byte_rx : std_logic_vector(7 downto 0);
67
begin
68 36 leonardoar
        --! Instantiate uart_control
69 14 leonardoar
        uUartControl : uart_control port map (
70
                rst => RST_I,
71
                clk => CLK_I,
72
                WE      => WE_I,
73
                reg_addr => ADR_I0,
74
                start => STB_I,
75
                done => ACK_O,
76
                DAT_I => DAT_I0,
77
                DAT_O => DAT_O0,
78
                baud_wait => baud_wait,
79
                data_byte_tx => data_byte_tx,
80
                data_byte_rx => data_byte_rx,
81
                tx_data_sent => tx_data_sent,
82
                rst_comm_blocks => rst_comm_blocks,
83
                tx_start => tx_start,
84
                rx_data_ready => rx_data_ready
85
        );
86
 
87 36 leonardoar
        --! Instantiate uart_communication_blocks
88 14 leonardoar
        uUartCommunicationBlocks : uart_communication_blocks port map (
89
                rst => rst_comm_blocks,
90
                clk => CLK_I,
91
                cycle_wait_baud => baud_wait,
92
                byte_tx => data_byte_tx,
93
                byte_rx => data_byte_rx,
94
                data_sent_tx => tx_data_sent,
95
                data_received_rx => rx_data_ready,
96
                serial_out => serial_out,
97
                serial_in => serial_in,
98
                start_tx => tx_start
99
        );
100 21 leonardoar
 
101
        data_Avaible <= rx_data_ready;
102 14 leonardoar
 
103
end Behavioral;
104
 

powered by: WebSVN 2.1.0

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