Advertisement
Guest User

Untitled

a guest
Jun 24th, 2010
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.60 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    14:47:43 06/20/2010
  6. -- Design Name:
  7. -- Module Name:    UART_TX - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.STD_LOGIC_ARITH.ALL;
  23. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  24.  
  25. ---- Uncomment the following library declaration if instantiating
  26. ---- any Xilinx primitives in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29.  
  30. entity UART_TX is
  31.     Port ( CLK : in  STD_LOGIC;
  32.            TX_PIN : out  STD_LOGIC;
  33.            INPUT : in  integer range 0 to 255;
  34.               PUSH : in STD_LOGIC);
  35. end UART_TX;
  36.  
  37. architecture Behavioral of UART_TX is
  38.     SIGNAL rts : STD_LOGIC := '1';
  39.     SIGNAL bit_cnt : integer range 0 to 12;
  40.     SIGNAL outbuf  : STD_LOGIC_VECTOR (8 downto 1);
  41. begin
  42.     PROCESS ( CLK, PUSH, RTS )
  43.     BEGIN
  44.         IF (rts='1') THEN
  45.             IF RISING_EDGE(CLK) THEN
  46.                 CASE bit_cnt IS
  47.                     WHEN 0 =>
  48.                         TX_PIN <= '0'; --START BIT
  49.                         bit_cnt <= bit_cnt + 1;
  50.                     WHEN 9 =>
  51.                         TX_PIN <= '1'; --STOP BIT
  52.                         bit_cnt <= 0;
  53.                         rts <= '0';
  54.                     WHEN OTHERS =>
  55.                         TX_PIN <= outbuf(bit_cnt);
  56.                         bit_cnt <= bit_cnt + 1;
  57.                 END CASE;
  58.             END IF;
  59.         END IF;
  60.        
  61.         IF PUSH='1' THEN
  62.             rts<='1';
  63.         END IF;
  64.     END PROCESS;
  65.    
  66.     outbuf <= conv_std_logic_vector(INPUT,8);
  67. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement