-----------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------
|
-- uart top level module
|
-- uart top level module
|
--
|
--
|
-----------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------
|
library IEEE;
|
library ieee;
|
use IEEE.STD_LOGIC_1164.ALL;
|
use ieee.std_logic_1164.all;
|
|
|
|
library work;
|
|
use work.uart2BusTop_pkg.all;
|
|
|
entity uartTop is
|
entity uartTop is
|
port ( -- global signals
|
port ( -- global signals
|
clr : in std_logic; -- global reset input
|
clr : in std_logic; -- global reset input
|
clk : in std_logic; -- global clock input
|
clk : in std_logic; -- global clock input
|
-- uart serial signals
|
-- uart serial signals
|
serIn : in std_logic; -- serial data input
|
serIn : in std_logic; -- serial data input
|
serOut : out std_logic; -- serial data output
|
serOut : out std_logic; -- serial data output
|
-- transmit and receive internal interface signals
|
-- transmit and receive internal interface signals
|
txData : in std_logic_vector(7 downto 0); -- data byte to transmit
|
txData : in std_logic_vector(7 downto 0); -- data byte to transmit
|
newTxData : in std_logic; -- asserted to indicate that there is a new data byte for transmission
|
newTxData : in std_logic; -- asserted to indicate that there is a new data byte for transmission
|
txBusy : out std_logic; -- signs that transmitter is busy
|
txBusy : out std_logic; -- signs that transmitter is busy
|
rxData : out std_logic_vector(7 downto 0); -- data byte received
|
rxData : out std_logic_vector(7 downto 0); -- data byte received
|
newRxData : out std_logic; -- signs that a new byte was received
|
newRxData : out std_logic; -- signs that a new byte was received
|
-- baud rate configuration register - see baudGen.vhd for details
|
-- baud rate configuration register - see baudGen.vhd for details
|
baudFreq : in std_logic_vector(11 downto 0); -- baud rate setting registers - see header description
|
baudFreq : in std_logic_vector(11 downto 0); -- baud rate setting registers - see header description
|
baudLimit : in std_logic_vector(15 downto 0); -- baud rate setting registers - see header description
|
baudLimit : in std_logic_vector(15 downto 0); -- baud rate setting registers - see header description
|
baudClk : out std_logic); --
|
baudClk : out std_logic); --
|
end uartTop;
|
end uartTop;
|
|
|
architecture Behavioral of uartTop is
|
architecture Behavioral of uartTop is
|
|
|
component baudGen
|
|
port (
|
|
clr : in std_logic;
|
|
clk : in std_logic;
|
|
baudFreq : in std_logic_vector(11 downto 0);
|
|
baudLimit : in std_logic_vector(15 downto 0);
|
|
ce16 : out std_logic);
|
|
end component;
|
|
|
|
component uartTx
|
|
port (
|
|
clr : in std_logic;
|
|
clk : in std_logic;
|
|
ce16 : in std_logic;
|
|
txData : in std_logic_vector(7 downto 0);
|
|
newTxData : in std_logic;
|
|
serOut : out std_logic;
|
|
txBusy : out std_logic);
|
|
end component;
|
|
|
|
component uartRx
|
|
port (
|
|
clr : in std_logic;
|
|
clk : in std_logic;
|
|
ce16 : in std_logic;
|
|
serIn : in std_logic;
|
|
rxData : out std_logic_vector(7 downto 0);
|
|
newRxData : out std_logic);
|
|
end component;
|
|
|
|
signal ce16 : std_logic; -- clock enable at bit rate
|
signal ce16 : std_logic; -- clock enable at bit rate
|
|
|
begin
|
begin
|
-- baud rate generator module
|
-- baud rate generator module
|
bg : baudGen
|
bg : baudGen
|
port map (
|
port map (
|
clr => clr,
|
clr => clr,
|
clk => clk,
|
clk => clk,
|
baudFreq => baudFreq,
|
baudFreq => baudFreq,
|
baudLimit => baudLimit,
|
baudLimit => baudLimit,
|
ce16 => ce16);
|
ce16 => ce16);
|
-- uart receiver
|
-- uart receiver
|
ut : uartTx
|
ut : uartTx
|
port map (
|
port map (
|
clr => clr,
|
clr => clr,
|
clk => clk,
|
clk => clk,
|
ce16 => ce16,
|
ce16 => ce16,
|
txData => txData,
|
txData => txData,
|
newTxData => newTxData,
|
newTxData => newTxData,
|
serOut => serOut,
|
serOut => serOut,
|
txBusy => txBusy);
|
txBusy => txBusy);
|
-- uart transmitter
|
-- uart transmitter
|
ur : uartRx
|
ur : uartRx
|
port map (
|
port map (
|
clr => clr,
|
clr => clr,
|
clk => clk,
|
clk => clk,
|
ce16 => ce16,
|
ce16 => ce16,
|
serIn => serIn,
|
serIn => serIn,
|
rxData => rxData,
|
rxData => rxData,
|
newRxData => newRxData);
|
newRxData => newRxData);
|
baudClk <= ce16;
|
baudClk <= ce16;
|
end Behavioral;
|
end Behavioral;
|
|
|