Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
72
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. -- Serializer 8-bit
  4.  
  5. library IEEE;
  6. use IEEE.STD_LOGIC_1164.ALL;
  7. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  8.  
  9. entity serializer is
  10.  
  11.     port(
  12.         RESET, CLK : in std_logic;
  13.         WE : in std_logic_vector(7 downto 0);
  14.         WY : out std_logic
  15.     );
  16.  
  17. end entity serializer;
  18.  
  19.  
  20. architecture serial_arch of serializer is
  21.  
  22. signal counter : std_logic_vector(2 downto 0) := "000";
  23. signal enable : std_logic := '0';
  24. signal reg : std_logic_vector(7 downto 0) := "00000000";
  25.  
  26. begin
  27.  
  28.     licznik: process(RESET, CLK)
  29.     begin
  30.         if(RESET = '0') then
  31.             counter <= (others => '0');
  32.         elsif(CLK'event and CLK = '1') then
  33.             counter <= counter + 1;
  34.         end if;
  35.     end process licznik;
  36.  
  37.     enable_reg : process(counter, RESET)
  38.     begin
  39.         if(RESET = '1' and counter = "000") then
  40.             enable <= '1';
  41.         else
  42.             enable <= '0';
  43.         end if;
  44.     end process enable_reg;
  45.  
  46.     regIsEnabled : process(enable, CLK, RESET)
  47.     begin
  48.         if(enable = '1') then
  49.             reg(0) <= WE(7);
  50.             reg(1) <= WE(6);
  51.             reg(2) <= WE(5);
  52.             reg(3) <= WE(4);
  53.             reg(4) <= WE(3);
  54.             reg(5) <= WE(2);
  55.             reg(6) <= WE(1);
  56.             reg(7) <= WE(0);
  57.         end if;
  58.        
  59.         if(RESET = '0') then
  60.             reg <= (others => '0');
  61.         elsif(CLK'event and CLK = '1') then
  62.             reg <= '0' & reg(7 downto 1);
  63.         end if;
  64.     end process regIsEnabled;
  65.    
  66.     WY <= reg(0);
  67.    
  68. end architecture serial_arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement