📄 usb_new_sieinterface_rtl.vhdl
字号:
----------------------------------------------------------------------------------
---- File >>> usb_new_sieinterface_rtl.vhdl
---- Iden >>> 960312-17:09:39
----
---- Project: USB Development
---- Customer: Philips_ITCL
----
---- Module: architecture RTL of entity SIEINTERFACE
---- Written by: Geert Verbruggen (e-mail: geert@easics.be)
---- Easics nv
---- Kapeldreef 60
---- B-3001 Leuven
---- Belgium
---- Tel +32-16-298.400
---- Fax +32-16-298.319
---- e-mail: vhdl@easics.be
----
---- Creation Date: Tue, 12 Mar 1996
----
---- Purpose:
----
---- Revision history:
----
---- $Source: /tmp_mnt/psc/proj/asg/CoReUse/USB/WorkArea/USB_FINAL/RTL/SIEINTERFACE/RCS/SIEINTERFACE_RTL.vhdl,v $
---- $Revision: 2.1 $
---- $Log: SIEINTERFACE_RTL.vhdl,v $
---- Revision 2.1 99/10/29 10:07:12 10:07:12 wap
---- removed IsoEndpoint port
----
---- Revision 2.0 99/06/03 10:25:41 10:25:41 fma (Franck Martins 02/99 tijdel. NOITCL)
---- Latest version and new revision number for common database in USBFS26 project involving ITCL & Bangalore
---- Updating Libraries to be CoReUse compliant. Including change from Bangalore with IsoEndpoint checking port
----
---- Revision 1.29 99/05/17 11:42:02 11:42:02 wap (Wim Appermans)
---- changed to numeric_std
----
---- Revision 1.28 99/01/15 13:37:12 13:37:12 usb
---- changed tokenreceived
----
---- Revision 1.27 1998/12/09 06:33:11 usb
---- now also interrupt on out NAK
----
---- Revision 1.26 1998/11/10 15:55:31 usb
---- adaptation for feedback mode
----
---- Revision 1.25 1998/11/09 10:45:10 usb
---- fixed intmode bug
----
---- Revision 1.24 1998/11/06 12:54:35 usb
---- int mode added
----
---- Revision 1.23 1998/10/29 10:54:52 usb
---- fixed bug
----
---- Revision 1.22 1998/10/23 06:05:21 usb
---- fixed bug in transaction
----
---- Revision 1.21 1998/10/13 12:41:52 usb
---- adaptation for "disabled"
----
---- Revision 1.20 1998/06/22 14:08:04 filips
---- Fixed typo's
----
---- Revision 1.19 1998/06/22 13:47:31 filips
---- Some cosmetic changes
----
---- Revision 1.18 1998/06/19 13:47:59 usb
---- Fixed embedded babbled implementation
----
---- Revision 1.17 1998/06/16 09:14:23 usb
---- removed use LIB_PACKAGES.PCK_USBINT.all;
----
---- Revision 1.16 1998/06/08 07:13:15 usb
---- Added support for interrupt on NAK + cleaning up
----
---- Revision 1.15 1998/06/05 11:38:09 usb
---- removed MAX_OVERFLOW_SIZE
----
---- Revision 1.14 1998/05/22 13:06:05 usb
---- Fixed some bugs
----
---- Revision 1.13 1998/05/22 08:41:08 usb
---- Cleaning up
----
---- Revision 1.12 1998/05/22 08:31:40 usb
---- Small change for better synthesis
----
---- Revision 1.11 1998/05/18 09:39:37 usb
---- Fixed bug in blinking led
----
---- Revision 1.10 1998/04/09 14:49:21 geert
---- *** empty log message ***
----
---- Revision 1.9 1998/04/07 14:05:36 geert
---- Fixed some bugs
----
---- Revision 1.8 1998/04/03 11:23:52 geert
---- Small changes
----
---- Revision 1.7 1998/04/01 15:06:06 geert
---- Disable DataValid during token
---- ,
----
---- Revision 1.6 1998/03/31 11:21:15 geert
---- Fixed bug in handshake stage
----
---- Revision 1.5 1998/03/20 15:26:33 geert
---- Smaller changes
----
---- Revision 1.4 1998/03/19 15:18:59 geert
---- Added resets
----
---- Revision 1.3 1998/03/19 13:44:17 geert
---- *** empty log message ***
----
---- Revision 1.2 1998/03/19 13:11:28 geert
---- *** empty log message ***
----
---- Revision 1.1 1998/03/17 16:15:01 geert
---- Initial revision
----
---- Revision 1.1 1998/03/17 16:11:41 geert
---- Initial revision
----
----
----
-- DESCRIPTION_BEGIN
-- The SIE Handler handles all requests from the SIE. It takes care of
-- USB address and endpoint decoding, data flow control and storing data
-- in the buffer or retrieving data from the buffer.
-- DESCRIPTION_END
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
--library LIB_PACKAGES;
--use LIB_PACKAGES.PCK_GENERAL.all;
--use LIB_PACKAGES.PCK_USB.all;
--use LIB_PACKAGES.PCK_CONFIGURATION.all;
--use LIB_PACKAGES.PCK_SETUP.all;
library work;
use work.PCK_GENERAL.all;
use work.PCK_USB.all;
use work.PCK_CONFIGURATION.all;
use work.PCK_SETUP.all;
architecture RTL of SIEINTERFACE is
signal DataPid: integer range 0 to 1;
signal IgnoreData:boolean;
signal StopReceiving: boolean;
type T_AddressTable is array(0 to N_DEVICES-1) of seven_bits;
signal USBAddressTable: T_AddressTable;
signal DeviceEnabled: booleans(0 to N_DEVICES-1);
signal EndOfTransfer: boolean;
signal SetupPacket: boolean;
signal HandlerNumber: integer range 0 to N_HANDLERS - 1;
begin
MM_TxData1Pid <= (DataPid = 1);
SH_Configured <= DataFromHandlers_In.DeviceConfigured(0);
MM_NeedClock <= DataFromHandlers_In.NeedClock;
MM_Resume <= DataFromHandlers_In.RemoteWakeUp;
DataFromHandlers_Out <= HandlersToSIEDefault;
MM_TxData <= DataFromHandlers_In.TxData;
MM_TxDataRdy <= DataFromHandlers_In.TxDataValid;
MAIN: process (FsClk, Reset_N)
type T_SH_State_enum is (
DEVADDR_SEARCH,
WAIT_FOR_ENDPOINT,
WAIT_FOR_ENDOFTOKEN,
WAIT_FOR_DATA,
RECEIVE_OUT_PACKET,
SEND_IN_PACKET
);
variable SH_State: T_SH_State_enum;
variable DevAddrEnabled: boolean;
variable DevNr: S_EmbDev_range;
variable Data: byte;
variable N_Data: integer range 0 to MAX_BUFFER_SIZE+3;
variable N_Data_bits: eleven_bits;
variable BufferSize: integer range 0 to MAX_BUFFER_SIZE;
variable OverRunSize: integer range 0 to MAX_BUFFER_SIZE+2;
variable HandlingINBuffer: boolean;
variable SOFByte1: byte;
variable EndpNr: integer range 0 to 15;
variable TokenReceived: boolean;
variable DataSentReceived: boolean;
variable HandshakeSentReceived: boolean;
variable EndpSearchReady: boolean;
variable RxData1Pid: boolean;
variable EndpointType: T_EndpointType_enum;
variable IsIsoEndpoint: boolean;
-- DOC_BEGIN: Function GetPhysEndpNr
-- This function retrieves the physical endpoint number, given the
-- USB device and endpoint addresses and the data direction
function GetPhysEndpNr(Device: integer;
Endpoint: integer;
INBuffer: boolean;
ConfigArray: S_ConfigArray) return integer is
begin
if INBuffer then
return InPhysEndpoint(Device,Endpoint,ConfigArray);
else
return OutPhysEndpoint(Device,Endpoint,ConfigArray);
end if;
end;
function GetHandlerNr(Device: integer;
Endpoint: integer;
INBuffer: boolean;
ConfigArray: S_ConfigArray) return integer is
begin
if INBuffer then
return InHandler(Device,Endpoint,ConfigArray);
else
return OutHandler(Device,Endpoint,ConfigArray);
end if;
end;
-- DOC_END
function IsoEnabled(Device: integer;
Endpoint: integer;
INBuffer: boolean;
ConfigArray: S_ConfigArray) return boolean is
begin
if INBuffer then
return InIsoEnabled(Device,Endpoint,ConfigArray);
else
return OutIsoEnabled(Device,Endpoint,ConfigArray);
end if;
end;
function GetBufferSize(Device: integer;
Endpoint: integer;
INBuffer: boolean;
ConfigArray: S_ConfigArray) return integer is
begin
if INBuffer then
return InBufferSize(Device,Endpoint,ConfigArray);
else
return OutBufferSize(Device,Endpoint,ConfigArray);
end if;
end;
-- DOC_BEGIN: Procedure SetEndpointSelected
-- SetEndpointSelected sets all necessary signals to indicate to the
-- SIE that the addressed endpoint is part of the device.
procedure SetEndpointSelected is
begin
EndpSearchReady := TRUE;
MM_EndpSearchSelected <= TRUE;
end;
-- DOC_END
-- DOC_BEGIN: Procedure SetNoEndpointSelected
-- SetNoEndpointSelected sets all necessary signals to indicate to the
-- SIE that the addressed endpoint is not part of the device.
procedure SetNoEndpointSelected is
begin
EndpSearchReady := TRUE;
MM_EndpSearchSelected <= FALSE;
end;
-- DOC_END
-- DOC_BEGIN: Procedure SetError
-- SetError generates an error of the specified type.
procedure SetError(SetErrorType: T_PACKET_ERROR_enum) is
begin
DataToHandlers.Error <= TRUE;
DataToHandlers.LastError <= SetErrorType;
if SH_State = DEVADDR_SEARCH then
DataToHandlers.EndOfTransfer <= FALSE;
else
DataToHandlers.EndOfTransfer <= TRUE;
end if;
DataToHandlers.Success <= FALSE;
if SetErrorType = ERROR_SENT_RECEIVED_NAK then
DataToHandlers.NAKed <= TRUE;
end if;
SH_State := DEVADDR_SEARCH;
end;
-- DOC_END
procedure SetSuccessAtEOP is
begin
EndOfTransfer <= TRUE;
DataToHandlers.Success <= TRUE;
SH_State := DEVADDR_SEARCH;
SH_Succes <= TRUE;
end;
procedure SetSuccess is
begin
DataToHandlers.EndOfTransfer <= TRUE;
EndOfTransfer <= FALSE;
DataToHandlers.Success <= TRUE;
SH_State := DEVADDR_SEARCH;
SH_Succes <= TRUE;
end;
begin
if (Reset_N = ACTIVE_LOW) then
SH_State := DEVADDR_SEARCH;
SOFByte1 := (others => '0');
MM_EndpSearchReady <= FALSE;
EndpSearchReady := FALSE;
MM_EndpSearchSelected <= FALSE;
DevNr := 0;
EndpNr := 0;
MM_Stalled <= FALSE;
MM_Accepted <= FALSE;
DataPid <= 0;
IgnoreData <= FALSE;
N_Data := 0;
MM_ISO <= FALSE;
HandlingINBuffer := FALSE;
Data := (others => '0');
TokenReceived := FALSE;
DataSentReceived := FALSE;
HandshakeSentReceived := FALSE;
MM_EmbeddedBabbled <= FALSE;
SH_Succes <= FALSE;
DataToHandlers.Success <= FALSE;
DataToHandlers.StartOfTransfer <= FALSE;
DataToHandlers.EndOfTransfer <= FALSE;
DataToHandlers.FrameNumber <= (others => '0');
DataToHandlers.Error <= FALSE;
SetupPacket <= FALSE;
DataToHandlers.LastError <= ERROR_NO_ERROR;
DataToHandlers.Endpoint <= 0;
DataToHandlers.N_Data <= 0;
DataToHandlers.TxDataFetched <= FALSE;
DataToHandlers.NAKed <= FALSE;
EndOfTransfer <= FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -