StarkRG

Untitled

Sep 5th, 2018
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.77 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_ARITH.ALL;
  4. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  5.  
  6. entity VideoBuffer is
  7.     port(
  8.         clk             :in Std_Logic;
  9.         reset               :in Std_Logic;
  10.         inputSelector   :in Std_Logic_Vector(1 downto 0);
  11.         dataIn          :in Std_Logic_Vector(7 downto 0);
  12.         dataLoad            :in Std_Logic;
  13.         output          :out Std_Logic
  14.     );
  15. end videobuffer;
  16.    
  17. architecture Behavioral of VideoBuffer is
  18.     signal A, B, C, D           :Std_Logic_Vector(7 downto 0);
  19.     signal outputSelector   :Std_Logic_Vector(1 downto 0);
  20.     signal step                 :Integer;
  21. begin
  22.     process (clk, reset, inputSelector, dataIn, dataLoad, A, B, C, D, outputSelector, step) is
  23.     begin
  24.         if reset = '0' then
  25.             A <= "00000000";
  26.             B <= "00000000";
  27.             C <= "00000000";
  28.             D <= "00000000";
  29.             output <= '0';
  30.             outputSelector <= "11";
  31.             step <= 7;
  32.         else
  33.             if dataload = '1' then
  34.                 case inputSelector is
  35.                     when "00"   => A <= dataIn; B <= B; C <= C; D <= D;
  36.                     when "01"   => B <= dataIn; A <= A; C <= C; D <= D;
  37.                     when "10"   => C <= dataIn; A <= A; B <= B; D <= D;
  38.                     when "11"   => D <= dataIn; A <= A; B <= B; C <= C;
  39.                     when others => A <= A; B <= B; C <= C; D <= D;
  40.                 end case;
  41.             else
  42.                 A <= A;
  43.                 B <= B;
  44.                 C <= C;
  45.                 D <= D;
  46.             end if;
  47.             if rising_edge(clk) then
  48.                 if step < 7 then
  49.                     step <= step + 1;
  50.                     outputSelector <= outputSelector;
  51.                 else
  52.                     step <= 0;
  53.                     outputSelector <= outputSelector + 1;
  54.                 end if;
  55.             else
  56.                 step <= step;
  57.                 outputSelector <= outputSelector;
  58.             end if;
  59.             case outputSelector is
  60.                 when "00"   => output <= A(step);
  61.                 when "01"   => output <= B(step);
  62.                 when "10"   => output <= C(step);
  63.                 when "11"   => output <= D(step);
  64.                 when others => output <= '0';
  65.             end case;
  66.         end if;
  67.     end process;
  68. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment