Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.numeric_std.all;
- use work.func_lib.all;
- entity Switches_To_LEDs is
- port (
- -- Clock
- i_Clk : in std_logic;
- -- Push-Button Switches:
- i_Switch_1 : in std_logic;
- i_Switch_2 : in std_logic;
- i_Switch_3 : in std_logic;
- i_Switch_4 : in std_logic;
- i_Switch_5 : in std_logic;
- i_Switch_6 : in std_logic;
- i_Switch_7 : in std_logic;
- i_Switch_8 : in std_logic;
- -- LED Pins:
- o_LED_1 : out std_logic;
- o_LED_2 : out std_logic;
- o_LED_3 : out std_logic;
- o_LED_4 : out std_logic;
- o_LED_5 : out std_logic;
- o_LED_6 : out std_logic;
- o_LED_7 : out std_logic;
- o_LED_8 : out std_logic;
- -- 7-Segment:
- o_Segment3_A : out std_logic;
- o_Segment3_B : out std_logic;
- o_Segment3_C : out std_logic;
- o_Segment3_D : out std_logic;
- o_Segment3_E : out std_logic;
- o_Segment3_F : out std_logic;
- o_Segment3_G : out std_logic;
- o_Segment3_DP : out std_logic;
- o_Segment2_A : out std_logic;
- o_Segment2_B : out std_logic;
- o_Segment2_C : out std_logic;
- o_Segment2_D : out std_logic;
- o_Segment2_E : out std_logic;
- o_Segment2_F : out std_logic;
- o_Segment2_G : out std_logic;
- o_Segment2_DP : out std_logic
- );
- end entity Switches_To_LEDs;
- architecture RTL of Switches_To_LEDs is
- signal w_decode0 : std_logic_vector(7 downto 0) := (others => '0');
- signal w_decode1 : std_logic_vector(7 downto 0) := (others => '0');
- signal w_segment0 : integer range 0 to 15 := 0;
- signal w_segment1 : integer range 0 to 15 := 0;
- signal delay : integer range 0 to 12000000 := 0;
- signal w_switch_1 : std_logic;
- signal w_switch_2 : std_logic;
- signal w_switch_3 : std_logic;
- signal w_switch_4 : std_logic;
- signal w_switch_5 : std_logic;
- signal w_switch_6 : std_logic;
- signal w_switch_7 : std_logic;
- signal w_switch_8 : std_logic;
- begin
- Debounce_1 : entity work.Debounce_Switch
- port map (
- i_clk => i_Clk,
- i_Switch => i_Switch_1,
- o_Switch => w_switch_1
- );
- Debounce_2 : entity work.Debounce_Switch
- port map (
- i_clk => i_Clk,
- i_Switch => i_Switch_2,
- o_Switch => w_switch_2
- );
- Debounce_3 : entity work.Debounce_Switch
- port map (
- i_clk => i_Clk,
- i_Switch => i_Switch_3,
- o_Switch => w_switch_3
- );
- Debounce_4 : entity work.Debounce_Switch
- port map (
- i_clk => i_Clk,
- i_Switch => i_Switch_4,
- o_Switch => w_switch_4
- );
- Debounce_5 : entity work.Debounce_Switch
- port map (
- i_clk => i_Clk,
- i_Switch => i_Switch_5,
- o_Switch => w_switch_5
- );
- Debounce_6 : entity work.Debounce_Switch
- port map (
- i_clk => i_Clk,
- i_Switch => i_Switch_6,
- o_Switch => w_switch_6
- );
- Debounce_7 : entity work.Debounce_Switch
- port map (
- i_clk => i_Clk,
- i_Switch => i_Switch_7,
- o_Switch => w_switch_7
- );
- Debounce_8 : entity work.Debounce_Switch
- port map (
- i_clk => i_Clk,
- i_Switch => i_Switch_8,
- o_Switch => w_switch_8
- );
- o_LED_1 <= w_switch_1;
- o_LED_2 <= w_switch_2;
- o_LED_3 <= w_Switch_3;
- o_LED_4 <= w_Switch_4;
- o_LED_5 <= w_Switch_5;
- o_LED_6 <= w_Switch_6;
- o_LED_7 <= w_Switch_7;
- o_LED_8 <= w_Switch_8;
- -- 7-Segment count
- -- synchronous process, asynchronous reset
- seg_count : process (i_Clk) is
- begin
- if rising_edge(i_Clk) then
- if w_Switch_7 = '1' then
- w_segment0 <= 0;
- w_segment1 <= 0;
- else
- delay <= delay + 1;
- if delay = 12000000 then
- w_segment0 <= w_segment0 + 1;
- if w_segment0 = 15 then
- w_segment1 <= w_segment1 + 1;
- end if;
- end if;
- end if;
- end if;
- end process seg_count;
- -- 7-Segment decode
- -- asynchronous process
- seg_decode : process (w_segment0, w_segment1) is
- begin
- w_decode0 <= f_hex_seg(w_segment0);
- w_decode1 <= f_hex_seg(w_segment1);
- end process seg_decode;
- o_Segment3_A <= w_decode0(6);
- o_Segment3_B <= w_decode0(5);
- o_Segment3_C <= w_decode0(4);
- o_Segment3_D <= w_decode0(3);
- o_Segment3_E <= w_decode0(2);
- o_Segment3_F <= w_decode0(1);
- o_Segment3_G <= w_decode0(0);
- o_Segment2_A <= w_decode1(6);
- o_Segment2_B <= w_decode1(5);
- o_Segment2_C <= w_decode1(4);
- o_Segment2_D <= w_decode1(3);
- o_Segment2_E <= w_decode1(2);
- o_Segment2_F <= w_decode1(1);
- o_Segment2_G <= w_decode1(0);
- end RTL;
Advertisement
Add Comment
Please, Sign In to add comment