switch_to_led7.vhd
上传用户:hbxtsdjs
上传日期:2022-07-03
资源大小:753k
文件大小:5k
- ----------------------------------------------------------------------------------
- -- Company:
- -- Engineer:
- --
- -- Create Date: 20:28:08 05/05/2010
- -- Design Name:
- -- Module Name: switch_to_led7 - Behavioral
- -- Project Name:
- -- Target Devices:
- -- Tool versions:
- -- Description:
- --
- -- Dependencies:
- --
- -- Revision:
- -- Revision 0.01 - File Created
- -- Additional Comments:
- --
- ----------------------------------------------------------------------------------
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use IEEE.STD_LOGIC_ARITH.ALL;
- use IEEE.STD_LOGIC_UNSIGNED.ALL;
- ---- Uncomment the following library declaration if instantiating
- ---- any Xilinx primitives in this code.
- --library UNISIM;
- --use UNISIM.VComponents.all;
- entity switch_to_led7 is
- Port ( clk_in : in STD_LOGIC;
- switch_in : in STD_LOGIC_VECTOR (7 downto 0);
- led7 : out STD_LOGIC_VECTOR (7 downto 0);
- sel : out STD_LOGIC_VECTOR (3 downto 0));
- end switch_to_led7;
- architecture Behavioral of switch_to_led7 is
- COMPONENT switch
- PORT(
- sw_in : IN std_logic_vector(7 downto 0);
- sw_out : OUT std_logic_vector(7 downto 0)
- );
- END COMPONENT;
- COMPONENT kcpsm3
- PORT(
- instruction : IN std_logic_vector(17 downto 0);
- in_port : IN std_logic_vector(7 downto 0);
- interrupt : IN std_logic;
- reset : IN std_logic;
- clk : IN std_logic;
- address : OUT std_logic_vector(9 downto 0);
- port_id : OUT std_logic_vector(7 downto 0);
- write_strobe : OUT std_logic;
- out_port : OUT std_logic_vector(7 downto 0);
- read_strobe : OUT std_logic;
- interrupt_ack : OUT std_logic
- );
- END COMPONENT;
- COMPONENT divid_200
- PORT(
- clk : IN std_logic;
- clk_200Hz : OUT std_logic
- );
- END COMPONENT;
- COMPONENT Latch
- PORT(
- data_in : IN std_logic_vector(7 downto 0);
- cs : IN std_logic;
- clk : IN std_logic;
- data_out : OUT std_logic_vector(7 downto 0)
- );
- END COMPONENT;
- COMPONENT LED_7scan
- PORT(
- i_led0 : IN std_logic_vector(7 downto 0);
- i_led1 : IN std_logic_vector(7 downto 0);
- i_led2 : IN std_logic_vector(7 downto 0);
- i_led3 : IN std_logic_vector(7 downto 0);
- clk : IN std_logic;
- ledout : OUT std_logic_vector(7 downto 0);
- sel : OUT std_logic_vector(3 downto 0)
- );
- END COMPONENT;
-
-
- COMPONENT sw_led
- PORT(
- address : IN std_logic_vector(9 downto 0);
- clk : IN std_logic;
- instruction : OUT std_logic_vector(17 downto 0)
- );
- END COMPONENT;
-
- signal address : std_logic_vector(9 downto 0);
- signal instruction : std_logic_vector(17 downto 0);
- signal clk : std_logic;
- signal port_id : std_logic_vector(7 downto 0);
- signal out_port : std_logic_vector(7 downto 0);
- signal write_strobe : std_logic;
- signal clk_200 : std_logic;
- signal sw_out : std_logic_vector(7 downto 0);
- signal led0 : std_logic_vector(7 downto 0);
- signal led1 : std_logic_vector(7 downto 0);
- signal led2 : std_logic_vector(7 downto 0);
- signal led3 : std_logic_vector(7 downto 0);
- signal cs0 : std_logic;
- signal cs1 : std_logic;
- signal cs2 : std_logic;
- signal cs3 : std_logic;
- signal in_port : std_logic_vector(7 downto 0);
- begin
- s1 : process(port_id)
- begin
-
- if port_id= "00000000" then
- in_port <= sw_out;
- else in_port <="00000000";
- end if;
-
- if port_id= "00000001" then
- cs0 <= '1';
- else cs0 <= '0';
- end if;
-
- if port_id= "00000010" then
- cs1 <= '1';
- else cs1 <= '0';
- end if;
-
- if port_id= "00000011" then
- cs2 <= '1';
- else cs2 <= '0';
- end if;
-
- if port_id= "00000100" then
- cs3 <= '1';
- else cs3 <= '0';
- end if;
-
- end process;
-
- Inst_sw_led: sw_led PORT MAP(
- address => address,
- instruction => instruction,
- clk => clk_in
- );
- Inst_Latch0: Latch PORT MAP(
- data_in => out_port,
- data_out => led0,
- cs => cs0,
- clk => write_strobe
- );
- Inst_Latch1: Latch PORT MAP(
- data_in => out_port,
- data_out => led1,
- cs => cs1,
- clk => write_strobe
- );
-
- Inst_Latch2: Latch PORT MAP(
- data_in => out_port,
- data_out => led2,
- cs => cs2,
- clk => write_strobe
- );
-
- Inst_Latch3: Latch PORT MAP(
- data_in => out_port,
- data_out => led3,
- cs => cs3,
- clk => write_strobe
- );
-
- Inst_kcpsm3: kcpsm3 PORT MAP(
- address => address,
- instruction => instruction,
- port_id => port_id,
- write_strobe => write_strobe,
- out_port => out_port,
- read_strobe => open,
- in_port => in_port,
- interrupt => '0',
- interrupt_ack => open,
- reset => '0',
- clk => clk_in
- );
-
- Inst_divid_200: divid_200 PORT MAP(
- clk => clk_in,
- clk_200Hz =>clk_200
- );
-
-
- Inst_LED_7scan: LED_7scan PORT MAP(
- i_led0 => led0,
- i_led1 => led1,
- i_led2 => led2,
- i_led3 => led3,
- clk => clk_200,
- ledout => led7,
- sel => sel
- );
- Inst_switch: switch PORT MAP(
- sw_in => switch_in,
- sw_out => sw_out
- );
- end Behavioral;