-- VHDL code position: p259_ex8_39_experiment8_3_board -- Note : This is code file of tennis play -- See Also: example 8_35(top module), 8_36, 8_37, 8_38, 8_39, 8_40, 8_41, 8_42 -- Debug : no debug --------------------------------------------------------------------------------- -- 乒乓拍模块 library ieee; use ieee.std_logic_1164.all; entity board is port ( ball : in std_logic; -- 接球点,也就是乒乓球灯的末端 net : in std_logic; -- 乒乓球灯的中点,乒乓球过中点时,counclk、serclk复位 bclk : in std_logic; -- 球拍接球信号 serve : in std_logic; -- 发球信号 couclk : out std_logic; -- 球计数时钟信号 serclk : out std_logic -- 正确接球信号, 接到球时为?'1' ); end board; architecture ful of board is begin process( bclk,net ) begin if( net = '1' ) then -- 乒乓球过中点时,counclk、serclk复位 serclk <= '0'; couclk <= '0'; elsif( bclk'event and bclk = '1' ) then -- 球拍接球时 if( serve = '1' ) then -- 系统处于发球状态时 serclk <= '1'; -- 发球成功 else -- 系统处于接球状态 if( ball = '1' ) then -- 乒乓球刚落在接球点上 serclk <= '1'; -- 接球成功 else -- 乒乓球没落在接球点上 serclk <= '0'; -- 发球失败 couclk<='1'; end if; end if; end if; end process; end architecture ful ;