uart_tx.vhd
uart_tx.vhd
-- Company:
-- Engineer: Joash Naidoo
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity uart_tx is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
data_in : in STD_LOGIC_VECTOR(7 downto 0);
en : in STD_LOGIC;
busy_out : out STD_LOGIC;
tx_out : out STD_LOGIC
);
end uart_tx;
begin
process(clk) begin
if rising_edge(clk) then
-- Logic
if busy = '0' then
if en = '1' then
-- Begin transaction
cnt <= clks_per_bit-1; -- Hold value for whole period
en_old <= '1';
busy <= '1';
tx_out <= '0';
bitcnt <= X"0";
else
tx_out <= '1';
end if;
else
cnt <= cnt - 1;
end if;
end if;
end if;
end process;
end Behavioral;