Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library ieee ;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_unsigned.all;
- entity SkrzyzowanieKons is
- port( writedata: in std_logic_vector(31 downto 0);
- clk_clk, reset_reset_n: in std_logic;
- wr, cs : in std_logic;
- leds: out std_logic_vector(3 downto 0);
- hex: out std_logic_vector (6 downto 0)
- );
- end SkrzyzowanieKons;
- architecture rtl of SkrzyzowanieKons is
- signal reg: std_logic_vector(2 downto 0);
- signal licznik: natural range 0 to 99999999 := 0; -- licznik procesora
- type STATES_OF_LIGHTS is (HEX_01,HEX_00,HEX_3,HEX_2,HEX_1
- ) ; -- opis stanow swiatel oraz ich licznikow
- signal STATE , NEXT_ONE : STATES_OF_LIGHTS ;
- begin
- process(clk_clk)
- begin
- if (clk_clk'event and clk_clk='1') then
- if(wr='1' and cs='1') then
- reg <=writedata(2 downto 0);
- end if;
- end if;
- end process;
- process(clk_clk)
- begin
- if (reg="000") then leds <= "1001"; -- LED1: ON LED2: OFF LED3: OFF LED4: ON
- STATE<=HEX_3;
- licznik <= 00000000;
- elsif (reg="001") then leds <= "0110"; -- LED1: OFF LED2: ON LED3: ON LED4: OFF
- STATE<=HEX_3;
- licznik <= 00000000;
- elsif (reg="010") then leds <= "1111"; -- LED1: ON LED2: ON LED3: ON LED4: ON
- STATE<=HEX_01;
- licznik <= 00000000;
- elsif (reg="100") then leds <= "0000"; -- LED1: OFF LED2: OFF LED3: OFF LED4: OFF
- STATE<=HEX_01;
- licznik <= 00000000;
- elsif (rising_edge(clk_clk)) then
- licznik <= licznik + 1;
- if(licznik = 50000000) then
- STATE<=NEXT_ONE;
- licznik <= 00000000;
- end if;
- end if;
- end process;
- process(STATE, clk_clk) -- sprawdzac tylko zbocze narastajaca
- begin
- if (rising_edge(clk_clk)) then
- case STATE is
- when HEX_3 =>-- licznik pokazuje 3
- hex <= "0110000" ; -- trzy
- NEXT_ONE<=HEX_2;
- when HEX_2 =>-- licznik pokazuje 2
- hex <= "0100100" ;-- dwa
- NEXT_ONE<=HEX_1;
- when HEX_1 =>-- licznik pokazuje 1
- hex <= "1111001" ;-- jeden
- --______________________________________________________________________________________________________________________
- when HEX_00 =>-- licznik pokazuje 0
- hex <= "1000000" ;
- NEXT_ONE<= HEX_01;
- when HEX_01=>-- licznik pokazuje 1
- hex <= "1111001" ;-- jeden
- end case;
- end if;
- end process;
- end rtl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement