Advertisement
madegoff

shiftreg

Jun 3rd, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3.  
  4. entity PISOShiftReg is
  5. generic(
  6. WIDTH : integer := 8
  7. );
  8. port(
  9. CLK : in std_logic;
  10. CLK_EN : in std_logic;
  11. LOAD : in std_logic;
  12. D_IN : in std_logic_vector(WIDTH-1 downto 0);
  13. D_OUT : out std_logic;
  14. LAST_BIT : out std_logic
  15. );
  16. end entity PISOShiftReg;
  17.  
  18. architecture behavioral of PISOShiftReg is
  19.  
  20. signal shift_reg : std_logic_vector(WIDTH-1 downto 0);
  21. signal count : integer;
  22.  
  23. begin
  24.  
  25. qqq: process(CLK)
  26. begin
  27.  
  28. if rising_edge(CLK) then
  29.  
  30. if (CLK_EN = '1') then
  31.  
  32. if (LOAD = '1') then
  33.  
  34. shift_reg <= D_IN;
  35. D_OUT <= D_IN(0);
  36.  
  37. LAST_BIT <= '0';
  38. count <= 0;
  39.  
  40. else --shiften
  41.  
  42. D_OUT <= shift_reg(0);
  43.  
  44. shift_reg(WIDTH-2 downto 0) <= shift_reg(WIDTH-1 downto 1);
  45. shift_reg(WIDTH-1) <= '0';
  46.  
  47. count <= count + 1;
  48. if (count = WIDTH-1) then
  49. LAST_BIT <= '1';
  50. end if;
  51.  
  52. end if;
  53.  
  54. end if;
  55.  
  56. end if;
  57.  
  58. end process;
  59.  
  60. end architecture behavioral;
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement