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

📄 top.vhd

📁 用vhdl实现ps2鼠标的源程序
💻 VHD
字号:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity top is
    Port ( sysclk : in std_logic;
           reset : in std_logic;
           ps2clk : inout std_logic;
           ps2data : inout std_logic;
           ledA1 : out std_logic;
           ledA2 : out std_logic;
           ledA3 : out std_logic;
           ledA4 : out std_logic;
           leddata : out std_logic_vector(6 downto 0));
end top;

architecture Behavioral of top is

signal clk : std_logic;
signal left_button : std_logic;
signal right_button : std_logic;
signal xsign : std_logic;
signal ysign : std_logic;
signal x_increment : std_logic_vector(8 downto 0);
signal y_increment : std_logic_vector(8 downto 0);
signal error_no_ack : std_logic;

signal control_bus_0  : std_logic_vector(41 downto 0);
component icon
    port
    (
      CONTROL0    :   out std_logic_vector(41 downto 0)
    );
  end component;

signal data : std_logic_vector(15 downto 0);
signal trig : std_logic_vector(7 downto 0);
  component ila_dd256_dw16_tw8_e2
    port
    (
      CONTROL     : in    std_logic_vector(41 downto 0);
      CLK         : in    std_logic;
      DATA        : in    std_logic_vector(15 downto 0);
      TRIG        : in    std_logic_vector(7 downto 0)
    );
  end component;

--clock ferquence
component count64 
    Port ( sysclk : in std_logic;
           reset : in std_logic;
           clkout : out std_logic);
end component;

--show the data in led segment
component ledshow 
    Port ( clk : in std_logic;
           reset : in std_logic;
           xdot : in std_logic_vector(8 downto 0);
           ydot : in std_logic_vector(8 downto 0);
           ledA1 : out std_logic;
           ledA2 : out std_logic;
           ledA3 : out std_logic;
           ledA4 : out std_logic;
           leddata : out std_logic_vector(6 downto 0));
end component;

--mouse data receive
component mouse    
    Port (
	       clk : in std_logic;
          reset : in std_logic;
          ps2_clk : inout std_logic;
          ps2_data : inout std_logic;
          left_button : out std_logic;
          right_button : out std_logic;
			 xsign : out std_logic;
			 ysign : out std_logic;
          x_increment : out std_logic_vector(8 downto 0);
          y_increment : out std_logic_vector(8 downto 0);
          --data_ready : out std_logic;-- rx_read_o
          --read : in std_logic; -- rx_read_ack_i
          error_no_ack : out std_logic
			 );
end component;

begin

  testcontr: icon port map
    (
      CONTROL0 => control_bus_0
    );

  data <= x_increment(7 downto 0) & y_increment(7 downto 0);
  trig <= y_increment(7 downto 0);

  testout: ila_dd256_dw16_tw8_e2 port map
    (
      CONTROL => control_bus_0,
      CLK => sysclk,
      DATA => data,
      TRIG => trig
    );

  clocknum: count64 Port map
         ( sysclk => sysclk,
           reset => reset,
           clkout => clk
			  );
 
  mousedata: mouse Port map
       (  clk => clk,
          reset => reset,
          ps2_clk => ps2clk,
          ps2_data => ps2data,
          left_button => left_button,
          right_button => right_button,
			 xsign => xsign,
			 ysign => ysign,
          x_increment => x_increment,
          y_increment => y_increment,
          --data_ready : out std_logic;-- rx_read_o
          --read : in std_logic; -- rx_read_ack_i
          error_no_ack => error_no_ack
			 );

  showdata: ledshow Port map
         ( clk => clk,
           reset => reset,
           xdot => x_increment,
           ydot => y_increment,
           ledA1 => ledA1,
           ledA2 => ledA2,
           ledA3 => ledA3,
           ledA4 => ledA4,
           leddata => leddata
			  );
end Behavioral;

⌨️ 快捷键说明

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