SHARE
TWEET

Untitled

a guest Mar 26th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    20:24:27 03/25/2019
  6. -- Design Name:
  7. -- Module Name:    rs32 - 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.  
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. --use IEEE.NUMERIC_STD.ALL;
  26.  
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx primitives in this code.
  29. --library UNISIM;
  30. --use UNISIM.VComponents.all;
  31.  
  32. entity rs32 is
  33.     Port ( RXD_i : in  STD_LOGIC;
  34.            clk_i : in  STD_LOGIC;
  35.            data_o : out  STD_LOGIC_VECTOR (7 downto 0));
  36. end rs32;
  37.  
  38. architecture Behavioral of rs32 is
  39.     signal receiving: std_logic := '0';
  40.     signal data_cnt: integer := 0;
  41.     signal time_cnt: integer := 0;
  42. begin
  43.     process(clk_i, RXD_i, data_o):
  44.         if rising_edge(clk_i):
  45.             if receiving = '0' and RXD_i = '0' then
  46.                 receiving <= '1';
  47.                 data_cnt <= 1;
  48.             end if;
  49.            
  50.             if receiving = '1' then
  51.                 time_cnt <= time_cnt + 1;
  52.                 if time_cnt >= 5210 then
  53.                     time_cnt <= 0;
  54.                     if data_cnt < 10 then
  55.                         digit_o(data_cnt - 1) <= RXD_i;
  56.                         data_cnt <= data_cnt +1;
  57.                     end if;
  58.                 end if;
  59.             end if;
  60.            
  61.             if data_cnt = 10 then
  62.                 data_cnt <= 0;
  63.                 receiving <= '0';
  64.         end if;
  65.     end process;
  66.    
  67. end Behavioral;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top