--! Top level for interconnection between communication blocks: serial_transmitter, serial_receiver, baud_generator
|
--! Top level for interconnection between communication blocks: serial_transmitter, serial_receiver, baud_generator
|
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_communication_blocks is
|
entity uart_communication_blocks is
|
Port ( rst : in STD_LOGIC;
|
Port ( rst : in STD_LOGIC;
|
clk : in STD_LOGIC;
|
clk : in STD_LOGIC;
|
cycle_wait_baud : in std_logic_vector((nBitsLarge-1) downto 0);
|
cycle_wait_baud : in std_logic_vector((nBitsLarge-1) downto 0);
|
byte_tx : in STD_LOGIC_VECTOR ((nBits-1) downto 0);
|
byte_tx : in STD_LOGIC_VECTOR ((nBits-1) downto 0);
|
byte_rx : out STD_LOGIC_VECTOR ((nBits-1) downto 0);
|
byte_rx : out STD_LOGIC_VECTOR ((nBits-1) downto 0);
|
data_sent_tx : out STD_LOGIC;
|
data_sent_tx : out STD_LOGIC;
|
data_received_rx : out STD_LOGIC;
|
data_received_rx : out STD_LOGIC;
|
serial_out : out std_logic;
|
serial_out : out std_logic;
|
serial_in : in std_logic;
|
serial_in : in std_logic;
|
start_tx : in STD_LOGIC);
|
start_tx : in STD_LOGIC);
|
end uart_communication_blocks;
|
end uart_communication_blocks;
|
|
|
architecture Behavioral of uart_communication_blocks is
|
architecture Behavioral of uart_communication_blocks is
|
|
|
-- Declare components...
|
-- Declare components...
|
component baud_generator is
|
component baud_generator is
|
Port ( rst : in STD_LOGIC;
|
Port ( rst : in STD_LOGIC;
|
clk : in STD_LOGIC;
|
clk : in STD_LOGIC;
|
cycle_wait : in STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0);
|
cycle_wait : in STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0);
|
baud_oversample : out std_logic;
|
baud_oversample : out std_logic;
|
baud : out STD_LOGIC);
|
baud : out STD_LOGIC);
|
end component;
|
end component;
|
|
|
component serial_transmitter is
|
component serial_transmitter is
|
Port ( rst : in STD_LOGIC;
|
Port ( rst : in STD_LOGIC;
|
baudClk : in STD_LOGIC;
|
baudClk : in STD_LOGIC;
|
data_byte : in STD_LOGIC_VECTOR ((nBits-1) downto 0);
|
data_byte : in STD_LOGIC_VECTOR ((nBits-1) downto 0);
|
data_sent : out STD_LOGIC;
|
data_sent : out STD_LOGIC;
|
serial_out : out STD_LOGIC);
|
serial_out : out STD_LOGIC);
|
end component;
|
end component;
|
|
|
component serial_receiver is
|
component serial_receiver is
|
Port (
|
Port (
|
rst : in STD_LOGIC;
|
rst : in STD_LOGIC;
|
baudClk : in STD_LOGIC;
|
|
baudOverSampleClk : in STD_LOGIC;
|
baudOverSampleClk : in STD_LOGIC;
|
serial_in : in STD_LOGIC;
|
serial_in : in STD_LOGIC;
|
data_ready : out STD_LOGIC;
|
data_ready : out STD_LOGIC;
|
data_byte : out STD_LOGIC_VECTOR ((nBits-1) downto 0));
|
data_byte : out STD_LOGIC_VECTOR ((nBits-1) downto 0));
|
end component;
|
end component;
|
signal baud_tick : std_logic;
|
signal baud_tick : std_logic;
|
signal baud_tick_oversample : std_logic;
|
signal baud_tick_oversample : std_logic;
|
begin
|
begin
|
-- Instantiate baud generator
|
-- Instantiate baud generator
|
uBaudGen : baud_generator port map (
|
uBaudGen : baud_generator port map (
|
rst => rst,
|
rst => rst,
|
clk => clk,
|
clk => clk,
|
cycle_wait => cycle_wait_baud,
|
cycle_wait => cycle_wait_baud,
|
baud_oversample => baud_tick_oversample,
|
baud_oversample => baud_tick_oversample,
|
baud => baud_tick
|
baud => baud_tick
|
);
|
);
|
|
|
-- Instantiate serial_transmitter
|
-- Instantiate serial_transmitter
|
uTransmitter : serial_transmitter port map (
|
uTransmitter : serial_transmitter port map (
|
rst => not start_tx,
|
rst => not start_tx,
|
baudClk => baud_tick,
|
baudClk => baud_tick,
|
data_byte => byte_tx,
|
data_byte => byte_tx,
|
data_sent => data_sent_tx,
|
data_sent => data_sent_tx,
|
serial_out => serial_out
|
serial_out => serial_out
|
);
|
);
|
|
|
-- Instantiate serial_receiver
|
-- Instantiate serial_receiver
|
uReceiver : serial_receiver port map(
|
uReceiver : serial_receiver port map(
|
rst => rst,
|
rst => rst,
|
baudClk => baud_tick,
|
|
baudOverSampleClk => baud_tick_oversample,
|
baudOverSampleClk => baud_tick_oversample,
|
serial_in => serial_in,
|
serial_in => serial_in,
|
data_ready => data_received_rx,
|
data_ready => data_received_rx,
|
data_byte => byte_rx
|
data_byte => byte_rx
|
);
|
);
|
|
|
end Behavioral;
|
end Behavioral;
|
|
|
|
|