?? requesthandler.vhd
字號:
---------------------------------------------------------------------------------------------------
--
-- File : e:\Courses\ComputerHardwareInterface\USB_IF_DESIGN\USB_IF\src\RequestHandler.vhd
-- Create Time : Sun Apr 18 22:13:51 2004
-- Title : RequestHandler
-- Design : USB Interface IP Core
-- Author : Lou Xinghua (louxinghua99@mails.tsinghua.edu.cn)
-- Company : Department of Engineering Physics in Tsinghua Unversity, Beijing, China
-- Version : 1.0
--
---------------------------------------------------------------------------------------------------
--
-- Description : This module works each time when the whole packet is received. It will
-- analyze the packet data and deal with the data.
--
---------------------------------------------------------------------------------------------------
--{{ Section below this comment is automatically maintained
-- and may be overwritten
--{entity {RequestHandler} architecture {RequestHandler}}
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use WORK.USB_PACKAGE.all;
use WORK.PDIUSBD12_PACKAGE.all;
entity RequestHandler is
port(
reset_n : in STD_LOGIC;
clk : in STD_LOGIC;
recv_n : in STD_LOGIC;
req_type : in STD_LOGIC_VECTOR(7 downto 0);
cmd : out STD_LOGIC_VECTOR(7 downto 0);
exec_n : out STD_LOGIC
);
end RequestHandler;
--}} End of automatically maintained section
architecture RequestHandler of RequestHandler is
-- Internal Signals
-- State Machine
signal rh_state: REQUEST_HANDLER_STATE := RH_IDLE;
signal address_set: STD_LOGIC := '0';
begin
-- enter your statements here --
-- main process
main_process:
process( reset_n, clk )
begin
if reset_n = '0' then
-- reset output signals
cmd <= X"00";
exec_n <= '1';
address_set <= '0';
-- reset state machine
rh_state <= RH_IDLE;
elsif falling_edge(clk) then
case rh_state is
when RH_IDLE =>
if recv_n = '0' then
case req_type is
when REQUEST_GET_DESCRIPTOR =>
-- get descriptor request
-- send different command according to device address
if address_set = '0' then
cmd <= RH_SEND_DESCRIPTOR_1ST;
else
cmd <= RH_SEND_DESCRIPTOR;
end if;
exec_n <= '0';
when REQUEST_GET_STATUS =>
-- get status request
cmd <= RH_SEND_STATUS;
exec_n <= '0';
when REQUEST_SET_ADDRESS =>
-- set address request
address_set <= '1';
cmd <= RH_SET_ADDRESS;
exec_n <= '0';
when REQUEST_SET_FEATURE =>
-- set feature
cmd <= RH_SET_FEATURE;
exec_n <= '0';
when REQUEST_CLEAR_FEATURE =>
-- clear feature
cmd <= RH_CLEAR_FEATURE;
exec_n <= '0';
when REQUEST_SET_CONFIGURATION | REQUEST_SET_DESCRIPTOR =>
-- set configuration request
cmd <= RH_SET_CONFIGURATION;
exec_n <= '0';
when REQUEST_GET_CONFIGURATION =>
-- get configuration request
cmd <= RH_SEND_CONFIGURATION;
exec_n <= '0';
when REQUEST_SET_INTERFACE =>
-- set interface request
cmd <= RH_SET_INTERFACE;
exec_n <= '0';
when others =>
NULL;
end case;
else
exec_n <= '1';
cmd <= RH_INVALID_COMMAND;
end if;
when others =>
NULL;
end case;
end if;
end process;
end RequestHandler;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -