Line 1... |
Line 1... |
--! Top wishbone slave for the uart
|
--! @file
|
|
--! @brief Top wishbone slave for the uart (Connects uart_control and uart_communication_blocks)
|
|
|
library IEEE;
|
library IEEE;
|
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_1164.ALL;
|
|
|
--! Use CPU Definitions package
|
--! Use CPU Definitions package
|
use work.pkgDefinitions.all;
|
use work.pkgDefinitions.all;
|
|
|
entity uart_wishbone_slave is
|
entity uart_wishbone_slave is
|
Port ( RST_I : in STD_LOGIC;
|
Port ( RST_I : in STD_LOGIC; --! Reset Input
|
CLK_I : in STD_LOGIC;
|
CLK_I : in STD_LOGIC; --! Clock Input
|
ADR_I0 : in STD_LOGIC_VECTOR (1 downto 0);
|
ADR_I0 : in STD_LOGIC_VECTOR (1 downto 0); --! Address input
|
DAT_I0 : in STD_LOGIC_VECTOR (31 downto 0);
|
DAT_I0 : in STD_LOGIC_VECTOR (31 downto 0); --! Data Input 0
|
DAT_O0 : out STD_LOGIC_VECTOR (31 downto 0);
|
DAT_O0 : out STD_LOGIC_VECTOR (31 downto 0); --! Data Output 0
|
WE_I : in STD_LOGIC;
|
WE_I : in STD_LOGIC; --! Write enable input
|
STB_I : in STD_LOGIC;
|
STB_I : in STD_LOGIC; --! Strobe input (Works like a chip select)
|
ACK_O : out STD_LOGIC;
|
ACK_O : out STD_LOGIC; --! Ack output
|
serial_in : in std_logic;
|
|
data_Avaible : out std_logic; -- Indicate that the receiver module got something
|
-- NON-WISHBONE Signals
|
|
serial_in : in std_logic; --! Uart serial input
|
|
data_Avaible : out std_logic; --! Flag to indicate data avaible
|
serial_out : out std_logic
|
serial_out : out std_logic
|
);
|
);
|
end uart_wishbone_slave;
|
end uart_wishbone_slave;
|
|
|
|
--! @brief Top uart_wishbone_slave architecture
|
|
--! @details Connect the control unit and the communication blocks
|
architecture Behavioral of uart_wishbone_slave is
|
architecture Behavioral of uart_wishbone_slave is
|
component uart_control is
|
component uart_control is
|
Port ( rst : in std_logic; -- Global reset
|
Port ( rst : in std_logic; --! Global reset
|
clk : in std_logic; -- Global clock
|
clk : in std_logic; --! Global clock
|
WE : in std_logic; -- Write enable
|
WE : in std_logic; --! Write enable
|
reg_addr : in std_logic_vector (1 downto 0); -- Register address
|
reg_addr : in std_logic_vector (1 downto 0); --! Register address
|
start : in std_logic; -- Start (Strobe)
|
start : in std_logic; --! Start (Strobe)
|
done : out std_logic; -- Done (ACK)
|
done : out std_logic; --! Done (ACK)
|
DAT_I : in std_logic_vector ((nBitsLarge-1) downto 0); -- Data Input (Wishbone)
|
DAT_I : in std_logic_vector ((nBitsLarge-1) downto 0); --! Data Input (Wishbone)
|
DAT_O : out std_logic_vector ((nBitsLarge-1) downto 0); -- Data output (Wishbone)
|
DAT_O : out std_logic_vector ((nBitsLarge-1) downto 0); --! Data output (Wishbone)
|
baud_wait : out std_logic_vector ((nBitsLarge-1) downto 0); -- Signal to control the baud rate frequency
|
baud_wait : out std_logic_vector ((nBitsLarge-1) downto 0); --! Signal to control the baud rate frequency
|
data_byte_tx : out std_logic_vector((nBits-1) downto 0); -- 1 Byte to be send to serial_transmitter
|
data_byte_tx : out std_logic_vector((nBits-1) downto 0); --! 1 Byte to be send to serial_transmitter
|
data_byte_rx : in std_logic_vector((nBits-1) downto 0); -- 1 Byte to be received by serial_receiver
|
data_byte_rx : in std_logic_vector((nBits-1) downto 0); --! 1 Byte to be received by serial_receiver
|
tx_data_sent : in std_logic; -- Signal comming from serial_transmitter
|
tx_data_sent : in std_logic; --! Signal comming from serial_transmitter
|
tx_start : out std_logic; -- Signal to start sending serial data...
|
tx_start : out std_logic; --! Signal to start sending serial data...
|
rst_comm_blocks : out std_logic; -- Reset Communication blocks
|
rst_comm_blocks : out std_logic; --! Reset Communication blocks
|
rx_data_ready : in std_logic);
|
rx_data_ready : in std_logic);
|
end component;
|
end component;
|
|
|
component uart_communication_blocks is
|
component uart_communication_blocks is
|
Port ( rst : in STD_LOGIC;
|
Port ( rst : in STD_LOGIC; --! Global reset
|
clk : in STD_LOGIC;
|
clk : in STD_LOGIC; --! Global clock
|
cycle_wait_baud : in std_logic_vector((nBitsLarge-1) downto 0);
|
cycle_wait_baud : in std_logic_vector((nBitsLarge-1) downto 0); --! Number of cycles to wait in order to generate desired baud
|
byte_tx : in STD_LOGIC_VECTOR ((nBits-1) downto 0);
|
byte_tx : in STD_LOGIC_VECTOR ((nBits-1) downto 0); --! Byte to transmit
|
byte_rx : out STD_LOGIC_VECTOR ((nBits-1) downto 0);
|
byte_rx : out STD_LOGIC_VECTOR ((nBits-1) downto 0); --! Byte to receive
|
data_sent_tx : out STD_LOGIC;
|
data_sent_tx : out STD_LOGIC; --! Indicate that byte has been sent
|
data_received_rx : out STD_LOGIC;
|
data_received_rx : out STD_LOGIC; --! Indicate that we got a byte
|
serial_out : out std_logic;
|
serial_out : out std_logic; --! Uart serial out
|
serial_in : in std_logic;
|
serial_in : in std_logic; --! Uart serial in
|
start_tx : in STD_LOGIC);
|
start_tx : in STD_LOGIC); --! Initiate transmission
|
end component;
|
end component;
|
signal baud_wait : std_logic_vector((nBitsLarge-1) downto 0);
|
signal baud_wait : std_logic_vector((nBitsLarge-1) downto 0);
|
signal tx_data_sent : std_logic;
|
signal tx_data_sent : std_logic;
|
signal tx_start : std_logic;
|
signal tx_start : std_logic;
|
signal rst_comm_blocks : std_logic;
|
signal rst_comm_blocks : std_logic;
|
signal rx_data_ready : std_logic;
|
signal rx_data_ready : std_logic;
|
signal data_byte_tx : std_logic_vector(7 downto 0);
|
signal data_byte_tx : std_logic_vector(7 downto 0);
|
signal data_byte_rx : std_logic_vector(7 downto 0);
|
signal data_byte_rx : std_logic_vector(7 downto 0);
|
begin
|
begin
|
-- Instantiate uart_control
|
--! Instantiate uart_control
|
uUartControl : uart_control port map (
|
uUartControl : uart_control port map (
|
rst => RST_I,
|
rst => RST_I,
|
clk => CLK_I,
|
clk => CLK_I,
|
WE => WE_I,
|
WE => WE_I,
|
reg_addr => ADR_I0,
|
reg_addr => ADR_I0,
|
Line 76... |
Line 82... |
rst_comm_blocks => rst_comm_blocks,
|
rst_comm_blocks => rst_comm_blocks,
|
tx_start => tx_start,
|
tx_start => tx_start,
|
rx_data_ready => rx_data_ready
|
rx_data_ready => rx_data_ready
|
);
|
);
|
|
|
-- Instantiate uart_communication_blocks
|
--! Instantiate uart_communication_blocks
|
uUartCommunicationBlocks : uart_communication_blocks port map (
|
uUartCommunicationBlocks : uart_communication_blocks port map (
|
rst => rst_comm_blocks,
|
rst => rst_comm_blocks,
|
clk => CLK_I,
|
clk => CLK_I,
|
cycle_wait_baud => baud_wait,
|
cycle_wait_baud => baud_wait,
|
byte_tx => data_byte_tx,
|
byte_tx => data_byte_tx,
|