⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user_logic3.vhd

📁 基于FPGA嵌入式开发实现的VGA接口
💻 VHD
字号:
-------------------------------------------------------------------------------- user_logic.vhd - entity/architecture pair---------------------------------------------------------------------------------- ***************************************************************************-- ** Copyright (c) 1995-2006 Xilinx, Inc.  All rights reserved.            **-- **                                                                       **-- ** Xilinx, Inc.                                                          **-- ** XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"         **-- ** AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND       **-- ** SOLUTIONS FOR XILINX DEVICES.  BY PROVIDING THIS DESIGN, CODE,        **-- ** OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,        **-- ** APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION           **-- ** THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,     **-- ** AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE      **-- ** FOR YOUR IMPLEMENTATION.  XILINX EXPRESSLY DISCLAIMS ANY              **-- ** WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE               **-- ** IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR        **-- ** REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF       **-- ** INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS       **-- ** FOR A PARTICULAR PURPOSE.                                             **-- **                                                                       **-- ***************************************************************************---------------------------------------------------------------------------------- Filename:          user_logic.vhd-- Version:           1.00.a-- Description:       User logic.-- Date:              Tue Jun 19 00:23:46 2007 (by Create and Import Peripheral Wizard)-- VHDL Standard:     VHDL'93-------------------------------------------------------------------------------- Naming Conventions:--   active low signals:                    "*_n"--   clock signals:                         "clk", "clk_div#", "clk_#x"--   reset signals:                         "rst", "rst_n"--   generics:                              "C_*"--   user defined types:                    "*_TYPE"--   state machine next state:              "*_ns"--   state machine current state:           "*_cs"--   combinatorial signals:                 "*_com"--   pipelined or register delay signals:   "*_d#"--   counter signals:                       "*cnt*"--   clock enable signals:                  "*_ce"--   internal version of output port:       "*_i"--   device pins:                           "*_pin"--   ports:                                 "- Names begin with Uppercase"--   processes:                             "*_PROCESS"--   component instantiations:              "<ENTITY_>I_<#|FUNC>"-------------------------------------------------------------------------------- DO NOT EDIT BELOW THIS LINE --------------------library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;library proc_common_v2_00_a;use proc_common_v2_00_a.proc_common_pkg.all;-- DO NOT EDIT ABOVE THIS LINE ----------------------USER libraries added here-------------------------------------------------------------------------------- Entity section-------------------------------------------------------------------------------- Definition of Generics:--   C_DWIDTH                     -- User logic data bus width--   C_NUM_CE                     -- User logic chip enable bus width---- Definition of Ports:--   Bus2IP_Clk                   -- Bus to IP clock--   Bus2IP_Reset                 -- Bus to IP reset--   Bus2IP_Data                  -- Bus to IP data bus for user logic--   Bus2IP_BE                    -- Bus to IP byte enables for user logic--   Bus2IP_RdCE                  -- Bus to IP read chip enable for user logic--   Bus2IP_WrCE                  -- Bus to IP write chip enable for user logic--   IP2Bus_Data                  -- IP to Bus data bus for user logic--   IP2Bus_Ack                   -- IP to Bus acknowledgement--   IP2Bus_Retry                 -- IP to Bus retry response--   IP2Bus_Error                 -- IP to Bus error response--   IP2Bus_ToutSup               -- IP to Bus timeout suppress------------------------------------------------------------------------------entity user_logic is  generic  (    -- ADD USER GENERICS BELOW THIS LINE ---------------    --USER generics added here    -- ADD USER GENERICS ABOVE THIS LINE ---------------    -- DO NOT EDIT BELOW THIS LINE ---------------------    -- Bus protocol parameters, do not add to or delete    C_DWIDTH                       : integer              := 32;    C_NUM_CE                       : integer              := 1    -- DO NOT EDIT ABOVE THIS LINE ---------------------  );  port  (    -- ADD USER PORTS BELOW THIS LINE ------------------    KB_CLK								  : in std_logic;	 KB_DATA								  : in std_logic;    -- ADD USER PORTS ABOVE THIS LINE ------------------    -- DO NOT EDIT BELOW THIS LINE ---------------------    -- Bus protocol ports, do not add to or delete    Bus2IP_Clk                     : in  std_logic;    Bus2IP_Reset                   : in  std_logic;    Bus2IP_Data                    : in  std_logic_vector(0 to C_DWIDTH-1);    Bus2IP_BE                      : in  std_logic_vector(0 to C_DWIDTH/8-1);    Bus2IP_RdCE                    : in  std_logic_vector(0 to C_NUM_CE-1);    Bus2IP_WrCE                    : in  std_logic_vector(0 to C_NUM_CE-1);    IP2Bus_Data                    : out std_logic_vector(0 to C_DWIDTH-1);    IP2Bus_Ack                     : out std_logic;    IP2Bus_Retry                   : out std_logic;    IP2Bus_Error                   : out std_logic;    IP2Bus_ToutSup                 : out std_logic    -- DO NOT EDIT ABOVE THIS LINE ---------------------  );end entity user_logic;-------------------------------------------------------------------------------- Architecture section------------------------------------------------------------------------------architecture IMP of user_logic is  --USER signal declarations added here, as needed for user logic  signal CLK : std_logic;  signal NUM : std_logic_vector(0 to 6);  signal Scan_Code : std_logic_vector(0 to 31);  signal counter :  std_logic_vector(0 to 3);  signal S_Reg     : std_logic_vector(0 to 8);  Type   State_t is (Idle, Shifting);  signal State : State_t;  ------------------------------------------  -- Signals for user logic slave model s/w accessible register example  ------------------------------------------  signal slv_reg0                       : std_logic_vector(0 to C_DWIDTH-1);  signal slv_reg_write_select           : std_logic_vector(0 to 0);  signal slv_reg_read_select            : std_logic_vector(0 to 0);  signal slv_ip2bus_data                : std_logic_vector(0 to C_DWIDTH-1);  signal slv_read_ack                   : std_logic;  signal slv_write_ack                  : std_logic;begin  --USER logic implementation added hereprocess(Bus2IP_CLK)beginif (Bus2IP_Reset='1' ) then		CLK<= '1';elsif (Bus2IP_Clk'event and Bus2IP_Clk='1') then	if KB_CLK='0' then			CLK <= KB_CLK;	else  			CLK <= '1';	end if;end if;end process;	process(CLK, KB_DATA, Bus2IP_Reset)beginif Bus2IP_Reset='1' then 		State <= Idle;		counter <= (others => '0');		S_Reg <= (others => '0');		Scan_Code <= (others => '0');--		read_ce <= '0';elsif (CLK'event and CLK='0') then	case State is      when Idle =>			counter <= (others => '0');--			read_ce <= '0';			if kb_data ='0' then -- Start bit					State <= Shifting;			end if;      when Shifting =>          if counter >= 9 then              Scan_Code(24 to 31) <= S_Reg(1 to 8);--				  d <= S_reg(1 to 8);				  State <= Idle;--					read_ce <= '1';			--'0';          elsif counter < 9 then			   S_Reg <= kb_data & S_Reg (0 to 7); -- Shift right            counter  <= counter + 1;          end if;      when others =>         State <= Idle;    end case;  	case S_reg(1 to 8) is		when "00010110" => NUM <= "0000110";	--"1111001";		when "00011110" => NUM <= "1011011";	--"0100100";	  	when "00100110" => NUM <= "1001111";	--"0110000";	  	when "00100101" => NUM <= "1100110";	--"0011001";	  	when "00101110" => NUM <= "1101101";	--"0010010";	  	when "00110110" => NUM <= "1111101";	--"0000010";	  	when "00111101" => NUM <= "0000111";	--"1111000";		when "00111110" => NUM <= "1111111";	--"0000000";		when "01000110" => NUM <= "1101111";	--"0010000";	  	when "01000101" => NUM <= "0111111";	--"1000000";		when "00011100" => NUM <= "1110111";	--"0001000";		when "00110010" => NUM <= "1111100";	--"0000011";		when "00100001" => NUM <= "0111001";	--"1000110";		when "00100011" => NUM <= "1011110";	--"0100001";		when "00100100" => NUM <= "1111001";	--"0000110";		when "00101011" => NUM <= "1110001";	--"0001110";		when others     => NUM <= "0000000";	--"1111111";	end case;		end if;end process;  ------------------------------------------  -- Example code to read/write user logic slave model s/w accessible registers  --   -- Note:  -- The example code presented here is to show you one way of reading/writing  -- software accessible registers implemented in the user logic slave model.  -- Each bit of the Bus2IP_WrCE/Bus2IP_RdCE signals is configured to correspond  -- to one software accessible register by the top level template. For example,  -- if you have four 32 bit software accessible registers in the user logic, you  -- are basically operating on the following memory mapped registers:  --   --    Bus2IP_WrCE or   Memory Mapped  --       Bus2IP_RdCE   Register  --            "1000"   C_BASEADDR + 0x0  --            "0100"   C_BASEADDR + 0x4  --            "0010"   C_BASEADDR + 0x8  --            "0001"   C_BASEADDR + 0xC  --   ------------------------------------------  slv_reg_write_select <= Bus2IP_WrCE(0 to 0);  slv_reg_read_select  <= Bus2IP_RdCE(0 to 0);  slv_write_ack        <= Bus2IP_WrCE(0);  slv_read_ack         <= Bus2IP_RdCE(0);  -- implement slave model register(s)  SLAVE_REG_WRITE_PROC : process( Bus2IP_Clk ) is  begin   if Bus2IP_Clk'event and Bus2IP_Clk = '1' then      if Bus2IP_Reset = '1' then        slv_reg0 <= (others => '0');      else        case slv_reg_write_select is          when "1" =>            for byte_index in 0 to (C_DWIDTH/8)-1 loop              if ( Bus2IP_BE(byte_index) = '1' ) then                slv_reg0(byte_index*8 to byte_index*8+7) <= Bus2IP_Data(byte_index*8 to byte_index*8+7);              end if;            end loop;          when others => null;        end case;      end if;    end if;  end process SLAVE_REG_WRITE_PROC;  -- implement slave model register read mux  SLAVE_REG_READ_PROC : process( slv_reg_read_select, slv_reg0 ) is  begin    case slv_reg_read_select is      when "1" => slv_ip2bus_data <= Scan_Code;      when others => slv_ip2bus_data <= (others => '0');    end case;  end process SLAVE_REG_READ_PROC;  ------------------------------------------  -- Example code to drive IP to Bus signals  ------------------------------------------  IP2Bus_Data        <= slv_ip2bus_data;  IP2Bus_Ack         <= slv_write_ack or slv_read_ack;  IP2Bus_Error       <= '0';  IP2Bus_Retry       <= '0';  IP2Bus_ToutSup     <= '0';end IMP;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -