Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.32 KB | None | 0 0
  1. -- Łukasz Lech
  2. -- 243 265
  3. -- Deserializer 8-bit
  4.  
  5. library IEEE;
  6. use IEEE.STD_LOGIC_1164.ALL;
  7. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  8.  
  9. entity deserializer is
  10.  
  11.     port(
  12.         WE, RESET, CLK : in std_logic;
  13.         WY : out std_logic_vector(7 downto 0)
  14.     );
  15.  
  16. end entity deserializer;
  17.  
  18. architecture deserial_arch of deserializer is
  19.  
  20. signal counter : std_logic_vector(2 downto 0) := "000";
  21. signal send : std_logic := '0';
  22. signal reg : std_logic_vector(7 downto 0) := "00000000";
  23.  
  24. begin
  25.  
  26.     licznik: process(RESET, CLK)
  27.     begin
  28.         if(RESET = '0') then
  29.             counter <= (others => '0');
  30.         elsif(CLK'event and CLK = '1') then
  31.             counter <= counter + 1;
  32.         end if;
  33.     end process licznik;
  34.  
  35.     send_reg : process(counter, RESET)
  36.     begin
  37.         if(RESET = '1' and counter = "000") then
  38.             send <= '1';
  39.         else
  40.             send <= '0';
  41.         end if;
  42.     end process send_reg;
  43.  
  44.     regIsEnabled : process(send, CLK, RESET)
  45.     begin
  46.         if(send = '1') then
  47.             WY(0) <= reg(7);
  48.             WY(1) <= reg(6);
  49.             WY(2) <= reg(5);
  50.             WY(3) <= reg(4);
  51.             WY(4) <= reg(3);
  52.             WY(5) <= reg(2);
  53.             WY(6) <= reg(1);
  54.             WY(7) <= reg(0);
  55.         else
  56.             WY <= (others => '0');
  57.         end if;
  58.        
  59.         if(RESET = '0') then
  60.             reg <= (others => '0');
  61.         elsif(CLK'event and CLK = '1') then
  62.             reg <= WE & reg(7 downto 1);
  63.         end if;
  64.     end process regIsEnabled;
  65.    
  66.    
  67.    
  68. end architecture deserial_arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement