shiftIn.vhd 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 06/03/2019 01:56:01 PM
  6. -- Design Name:
  7. -- Module Name: shiftOut - 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. entity shiftIn is
  23. generic(
  24. inWidth : integer := 8;
  25. outWidth : integer := 32);
  26. Port ( clk : in STD_LOGIC;
  27. sync_reset : in STD_LOGIC;
  28. dataIn : in std_logic_vector(inWidth-1 downto 0);
  29. dataOut : out std_logic_vector(outWidth-1 downto 0);
  30. finished : out STD_LOGIC);
  31. end shiftIn;
  32. architecture Behavioral of shiftIn is
  33. signal dataIndex : integer range 0 to (outWidth / inWidth) := 0;
  34. begin
  35. p_s2p : process(clk, sync_reset)
  36. begin
  37. if(sync_reset = '0') then
  38. dataIndex <= 0;
  39. finished <= '0';
  40. dataOut <= (others => '0');
  41. elsif(rising_edge(clk)) then
  42. if(dataIndex < outWidth/inWidth) then
  43. dataOut(outWidth - dataIndex * inWidth - 1 downto outWidth - dataIndex * inWidth - inWidth) <= dataIn;
  44. dataIndex <= dataIndex + 1;
  45. finished <= '0';
  46. else
  47. dataIndex <= dataIndex;
  48. finished <= '1';
  49. end if;
  50. end if;
  51. end process;
  52. end Behavioral;