Advertisement
Guest User

Untitled

a guest
Mar 9th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.02 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.numeric_std.ALL;
  4. use IEEE.std_logic_unsigned.ALL;
  5.  
  6. entity UART_TX is
  7.     Port (clk9600: in std_logic;    -- 9600 Hz clock
  8.             TX : out std_logic      -- TX pin
  9.     );
  10. end UART_TX;
  11.  
  12. architecture Behavioral of UART_TX is
  13. -- dummy data
  14. -- idle (1) for a 3 cycles, start bit (1 to 0 transition), 8 bits of data ('A'), stop bit (=1)
  15. constant bits_to_transmit : std_logic_vector (0 to 12) := "1110100000101";
  16. signal current_bit : std_logic :='1';
  17. signal current_index: integer := 0; -- RTL shows that this is 32 bit number
  18.  
  19. begin
  20.     process (clk9600) -- on every clock tick
  21.     begin  
  22.         if rising_edge(clk9600) then
  23.             -- grab the current bit (in first iteration current_index = 0)
  24.             current_bit <= bits_to_transmit(current_index);
  25.             -- increment index by one, check for overflow
  26.             if current_index < 12 then
  27.                 current_index <= current_index + 1;
  28.             else
  29.                 current_index <= 0;
  30.             end if;
  31.         end if;
  32.     end process;
  33.     -- assign TX the current bit
  34.     TX <= current_bit;
  35. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement