Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.85 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.NUMERIC_STD.ALL;
  4.  
  5. -- Uncomment the following library declaration if instantiating
  6. -- any Xilinx leaf cells in this code.
  7. --library UNISIM;
  8. --use UNISIM.VComponents.all;
  9.  
  10. entity gownowkiblu is
  11.     generic(
  12.         granica_gorna : std_logic_vector(7 downto 0):= "00000010";
  13.         granica_dolna : std_logic_vector(7 downto 0):= "00000000"
  14.     );
  15.     port(
  16.         wartosc : out std_logic_vector(7 downto 0);
  17.         reset : in std_logic;
  18.         kierunek : in std_logic;
  19.         clk : in std_logic
  20.     );
  21. end gownowkiblu;
  22.  
  23. architecture witamwszystkiepolskiekurwy of gownowkiblu is
  24.     signal wartosc_buforowana : std_logic_vector(7 downto 0):=granica_dolna;
  25. begin
  26.     process(clk, reset, kierunek) begin
  27.         case kierunek is
  28.             when '1' =>
  29.                 if(reset = '1') then
  30.                     wartosc_buforowana <= granica_dolna;
  31.                 elsif(rising_edge(clk)) then
  32.                     if(wartosc_buforowana = granica_gorna) then
  33.                         wartosc_buforowana <= granica_dolna;
  34.                     else
  35.                         wartosc_buforowana <= std_logic_vector( unsigned(wartosc_buforowana) + 1 );
  36.                     end if;
  37.                 end if;
  38.             when '0' =>
  39.                 if(reset = '1') then
  40.                     wartosc_buforowana <= granica_gorna;
  41.                 elsif(rising_edge(clk)) then
  42.                     if(wartosc_buforowana = granica_dolna) then
  43.                         wartosc_buforowana <= granica_gorna;
  44.                     else
  45.                         wartosc_buforowana <= std_logic_vector( unsigned(wartosc_buforowana) - 1 );
  46.                     end if;
  47.                 end if;
  48.              when others =>
  49.         end case;
  50.     end process;
  51.     wartosc <= wartosc_buforowana;
  52. end witamwszystkiepolskiekurwy;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement