Advertisement
Guest User

Untitled

a guest
Jun 24th, 2010
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.50 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    17:40:15 06/19/2010
  6. -- Design Name:
  7. -- Module Name:    UART_RX - 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_RX is
  31.     Port ( CLK : in  STD_LOGIC;
  32.            RX_PIN : in  STD_LOGIC;
  33.            OUTPUT : out integer range 0 to 255;
  34.               POP : out STD_LOGIC);
  35. end UART_RX;
  36.  
  37. architecture Behavioral of UART_RX is
  38.     SIGNAL bit_cnt : integer range 0 to 12;
  39.     SIGNAL outbuf  : STD_LOGIC_VECTOR (8 downto 1);
  40. begin
  41.     PROCESS ( CLK )
  42.     BEGIN
  43.         IF RISING_EDGE(CLK) THEN
  44.             CASE bit_cnt IS
  45.                 WHEN 0 =>
  46.                     IF RX_PIN = '0' THEN
  47.                         bit_cnt <= bit_cnt + 1;
  48.                     END IF;
  49.                 WHEN 9 =>
  50.                     bit_cnt <= bit_cnt + 1;
  51.                     POP <= '1';
  52.                 WHEN 10 =>
  53.                     POP <= '0';
  54.                     bit_cnt <= 0;
  55.                 WHEN OTHERS =>
  56.                     outbuf(bit_cnt) <= RX_PIN;
  57.                     bit_cnt <= bit_cnt + 1;
  58.             END CASE;
  59.         END IF;
  60.     END PROCESS;
  61.    
  62.     OUTPUT <= conv_integer(outbuf);
  63. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement