Advertisement
Vedro

Zegar

Mar 24th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.90 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity Dzielnik_kod is    
  5.     Port ( CLK : in  STD_LOGIC;
  6.         RST : in  STD_LOGIC;          
  7.         LED : out  STD_LOGIC);
  8. end Dzielnik_kod;
  9.  
  10. architecture Behavioral of Dzielnik_kod is 
  11.     constant N : integer := 3; 
  12.     signal licznik : INTEGER range 0 to (N-1); 
  13.     signal wyjscie : STD_LOGIC;
  14.  
  15.     begin      
  16.     dzielnik: process (CLK, RST) is
  17.         begin      
  18.             if RST = '1' then          
  19.                 licznik <= 0;          
  20.                 wyjscie <= '0';        
  21.             elsif rising_edge(CLK) then
  22.                 licznik <= licznik + 1;
  23.                 if (N = 2) then                         -- my
  24.                     wyjscie <= not(wyjscie);            -- zrobiliśmy
  25.                     licznik <= 0;                       -- to xD
  26.                 else
  27.                     if (licznik = (N/2)) then                  
  28.                         wyjscie <= '1';    
  29.                     elsif (licznik = (N - 1)) then                 
  30.                         wyjscie <= '0';            
  31.                         licznik <= 0;                              
  32.                     end if;
  33.                 end if;
  34.             end if;
  35.         end process dzielnik;
  36.  
  37.     LED <= wyjscie;
  38.  
  39. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement