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_ARITH.ALL;
- use IEEE.STD_LOGIC_UNSIGNED.ALL;
- use IEEE.numeric_std.all;
- entity cw6 is
- port (
- clk_i : in std_logic;
- led7_seg_o : out std_logic_vector(7 downto 0) := "11111111";
- led7_an_o : out std_logic_vector(3 downto 0) := "1111";
- sw_i : in std_logic_vector(7 downto 0) := "00000000";
- btn_i : in std_logic_vector(3 downto 0) := "0000"
- );
- end cw6;
- architecture Behavioral of cw6 is
- signal an0 : std_logic_vector(7 downto 0);
- signal an1 : std_logic_vector(7 downto 0);
- signal an2 : std_logic_vector(7 downto 0);
- signal an3 : std_logic_vector(7 downto 0);
- component wyswietlacz is
- port (
- clk_i : in std_logic;
- led7_seg_o : out std_logic_vector(7 downto 0):= "11111111";
- led7_an_o : out std_logic_vector(3 downto 0):= "1111";
- an0 : in std_logic_vector(7 downto 0) := "11111111";
- an1 : in std_logic_vector(7 downto 0) := "11111111";
- an2 : in std_logic_vector(7 downto 0) := "11111111";
- an3 : in std_logic_vector(7 downto 0) := "11111111"
- );
- end component;
- component zad6 is
- port (
- clk_i : in std_logic;
- an0 : out std_logic_vector(7 downto 0);
- an1 : out std_logic_vector(7 downto 0);
- an2 : out std_logic_vector(7 downto 0);
- an3 : out std_logic_vector(7 downto 0);
- sw_i : in std_logic_vector(7 downto 0) := "00000000";
- btn_i : in std_logic_vector(3 downto 0) := "0000"
- );
- end component;
- begin
- wysw: wyswietlacz
- port map(
- clk_i => clk_i,
- led7_seg_o => led7_seg_o,
- led7_an_o =>led7_an_o,
- an0 => an0,
- an1 => an1,
- an2 => an2,
- an3 => an3
- );
- wysw1: zad6
- port map(
- clk_i => clk_i,
- an0 => an0,
- an1 => an1,
- an2 => an2,
- an3 => an3,
- sw_i => sw_i,
- btn_i => btn_i
- );
- end Behavioral;
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use IEEE.STD_LOGIC_ARITH.ALL;
- use IEEE.STD_LOGIC_UNSIGNED.ALL;
- use IEEE.numeric_std.all;
- entity wyswietlacz is
- port (
- clk_i : in std_logic;
- led7_seg_o : out std_logic_vector(7 downto 0):= "11111111";
- led7_an_o : out std_logic_vector(3 downto 0):= "1111";
- an0 : in std_logic_vector(7 downto 0) := "11111111";
- an1 : in std_logic_vector(7 downto 0) := "11111111";
- an2 : in std_logic_vector(7 downto 0) := "11111111";
- an3 : in std_logic_vector(7 downto 0) := "11111111"
- );
- end wyswietlacz;
- architecture Behavioral of wyswietlacz is
- signal i: integer :=0;
- begin
- lcd: process (clk_i) is
- begin
- if rising_edge (clk_i) then
- i<=i+1;
- if i=1 then
- led7_an_o <= "0111";
- led7_seg_o <= an3;
- elsif i=100 then
- led7_an_o <= "1011";
- led7_seg_o <= an2;
- elsif i=200 then
- led7_an_o <= "1101";
- led7_seg_o <= an1;
- elsif i=300 then
- led7_an_o <= "1110";
- led7_seg_o <= an0;
- elsif i=400 then
- i<=0;
- end if;
- end if;
- end process lcd;
- end Behavioral;
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use IEEE.STD_LOGIC_ARITH.ALL;
- use IEEE.STD_LOGIC_UNSIGNED.ALL;
- use IEEE.numeric_std.all;
- entity zad6 is
- port (
- clk_i : in std_logic;
- an0 : out std_logic_vector(7 downto 0);
- an1 : out std_logic_vector(7 downto 0);
- an2 : out std_logic_vector(7 downto 0);
- an3 : out std_logic_vector(7 downto 0);
- sw_i : in std_logic_vector(7 downto 0);
- btn_i : in std_logic_vector(3 downto 0)
- );
- end zad6;
- architecture Behavioral of zad6 is
- signal cyfra : std_logic_vector(3 downto 0);
- signal ledbuf : std_logic_vector(6 downto 0);
- begin
- liczba: process (clk_i) is
- begin
- --KROPKA
- if rising_edge (clk_i) then
- an3(0) <= not sw_i(7);
- an2(0) <= not sw_i(6);
- an1(0) <= not sw_i(5);
- an0(0) <= not sw_i(4);
- cyfra <= sw_i (3 downto 0);
- case CONV_INTEGER (cyfra) is
- when 0 => ledbuf <= "0000001";
- when 1 => ledbuf <= "1001111";
- when 2 => ledbuf <= "0010010";
- when 3 => ledbuf <= "0000110";
- when 4 => ledbuf <= "1001100";
- when 5 => ledbuf <= "0100100";
- when 6 => ledbuf <= "0100000";
- when 7 => ledbuf <= "0001111";
- when 8 => ledbuf <= "0000000";
- when 9 => ledbuf <= "0000100";
- when 10 => ledbuf <= "0001000";
- when 11 => ledbuf <= "0000000";
- when 12 => ledbuf <= "0110001";
- when 13 => ledbuf <= "0000001";
- when 14 => ledbuf <= "0110000";
- when others => ledbuf <= "0111000";
- end case;
- if btn_i(3)='1' then
- an3(7 downto 1) <= ledbuf;
- elsif btn_i(2)='1' then
- an2(7 downto 1) <= ledbuf;
- elsif btn_i(1)='1' then
- an1(7 downto 1) <= ledbuf;
- elsif btn_i(0)='1' then
- an0(7 downto 1) <= ledbuf;
- end if;
- end if;
- end process liczba;
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement