Uart RX - VHD
Uart RX - VHD
-- Company:
-- Engineer: Joash Naidoo
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity uart_rx is
Port ( clk : in STD_LOGIC;
rx_in : in STD_LOGIC;
busy_out : out STD_LOGIC;
rdy : out STD_LOGIC;
data_out : out STD_LOGIC_VECTOR(7 downto 0));
end uart_rx;
begin
-- Notes:
-- 1. Falling bit indicates start of transmission
-- 2. Asynchronous transmission. Count down to find middle of bit
-- 3. If collected 8 bit after start bit, transmit the word back
process(clk) begin
if rising_edge(clk) then
rx_data <= rx_in;
if busy = '0' then
rdy <= '0'; -- Want the rdy flag to pull high one clock cycle when word
complete
cnt <= ((clks_per_bit-1)/2); -- Start Bit so only need to look half period
cnt <= clks_per_bit-1; -- Reset. Next middle is one whole period away
end if;
end if;
end process;
end Behavioral;