Line 4... |
Line 4... |
|
|
--! 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; --! 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 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...
|
Line 46... |
Line 46... |
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,
|
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,
|