?? usb_new_pck_handlers.vhdl
字號:
-------------------------------------------------------------------------------------
---- File >>> usb_new_pck_handlers.vhdl
---- Iden >>> 980305-13:47:42
----
---- Project: USB Developement
---- Customer: Philips_ITCL
----
---- VHDL Design Unit: package PCK_HANDLERS
---- Written by: Geert Verbruggen
---- Easics nv
---- http://www.easics.com
---- mailto: vhdl@easics.be
----
---- Creation Date: Thu, 05 Mar 1998
----
---- Purpose:
----
---- Revision history:
----
-------------------------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
library work;
use work.PCK_GENERAL.all;
use work.PCK_USB.all;
use work.PCK_CONFIGURATION.all;
package PCK_HANDLERS is
--------------------------------------------------
-- Connection to SIE Interface --
--------------------------------------------------
-- DOC_BEGIN: Interfaces between the SIE Interface and the Handlers
-- Two different interfaces are used to transfer data and control signals:
-- * From the SIE Interface to the handlers
-- * From the handlers to the SIE Interface
--
-- The interfaces consist of a single signal of type record. The
-- following sections give an overview of the record.
--
--
-- DOC_BEGIN: From the SIE Interface to the handlers
-- The following type describes the signals in the interface that
-- are used to transfer data and control signals from the SIE Interface
-- module to all the handlers.
type T_SIE_to_Handlers is record
FrameNumber: eleven_bits;
LastError: T_PACKET_ERROR_ENUM;
Handler: integer range 0 to N_HANDLERS-1;
Endpoint: integer range 0 to MAX_ENDPOINT_NR;
Interrupts: S_Interrupt_bool;
RxData: byte;
RxDataValid: boolean;
TxDataFetched: boolean;
StartOfTransfer: boolean;
SetupPacket: boolean;
EndOfTransfer: boolean;
Success: boolean;
NAKed: boolean;
N_Data: integer range 0 to MAX_OVERFLOW_SIZE;
Error: boolean;
end record;
-- DOC_END
-- DOC_BEGIN: From the handlers to the SIE Interface
-- The following type describes the signals in the interface that
-- are used to transfer data and control signals from the handlers
-- module to the SIE Interface.
type T_Device_7bit is array(0 to N_DEVICES-1) of seven_bits;
type T_Handlers_to_SIE is record
USBAddress: T_Device_7bit;
DeviceEnabled: S_Device_bool;
DeviceConfigured: S_Device_bool;
Interrupts: S_Interrupt_bool;
RemoteWakeUp: boolean;
NeedClock: boolean;
TxData: byte;
TxDataValid: boolean;
DataPID: integer range 0 to 1;
Disabled: boolean;
Stalled: boolean;
Accepted: boolean;
IntMode: boolean;
end record;
-- DOC_END
-- DOC_END
function HandlersToSIEDefault return T_Handlers_to_SIE;
procedure SIEConnector(
ID: integer;
signal Output: out T_Handlers_to_SIE;
signal Input: in T_Handlers_to_SIE;
signal Common: in T_SIE_to_Handlers;
signal Own: in T_Handlers_to_SIE;
signal HandlerSelected: out boolean
);
procedure DummySIEConnector(
ID: integer;
signal Output: out T_Handlers_to_SIE;
signal Input: in T_Handlers_to_SIE;
signal Own: in T_Handlers_to_SIE
);
-------------------------------------------------
-- Connection to UC Interface --
-------------------------------------------------
-- DOC_BEGIN: Interfaces between the UC Interface and the Handlers
-- Two different interfaces are used to transfer data and control signals.
-- The UC Interface indicates the module that handles the interface
-- to the micro-controller.
-- * From the UC Interface to the handlers
-- * From the handlers to the UC Interface
--
-- The interfaces consist of a single signal of type record. The
-- following sections give an overview of the record.
--
--
-- DOC_BEGIN: From the UC Interface to the handlers
-- The following type describes the signals in the interface that
-- are used to transfer data and control signals from the UC Interface
-- module to all the handlers.
constant N_UC_ADDRESSES: integer := 2;
type T_Handlers_to_UC is record
Ready: boolean;
Data: byte;
end record;
-- DOC_END
-- DOC_BEGIN: From the handlers to the SIE Interface
-- The following type describes the signals in the interface that
-- are used to transfer data and control signals from the handlers
-- module to the SIE Interface.
type T_UC_to_Handlers is record
Data: byte;
Write: boolean;
Read: boolean;
Address: integer range 0 to 1;
end record;
-- DOC_END
-- DOC_END
function HandlersToUCDefault return T_Handlers_to_UC;
procedure UCConnector(signal Output: out T_Handlers_to_UC;
signal Input: in T_Handlers_to_UC;
signal Own: in T_Handlers_to_UC;
signal Selected:in boolean);
-------------------------------------------------
-- Connection to PI - Handler --
-------------------------------------------------
subtype S_Toggle is integer range 0 to 1;
type T_ToggleArray is array (integer range 0 to N_ENDPOINTS-1) of S_Toggle;
subtype S_Full is booleans(1 downto 0);
type T_Full is array (integer range 0 to N_ENDPOINTS -1) of S_Full;
type T_EPBufferInfo is record
UCToggle: T_ToggleArray;
USBToggle: T_ToggleArray;
Full: T_Full;
end record;
end PCK_HANDLERS;
package body PCK_HANDLERS is
procedure SIEConnector(
ID: integer;
signal Output: out T_Handlers_to_SIE;
signal Input: in T_Handlers_to_SIE;
signal Common: in T_SIE_to_Handlers;
signal Own: in T_Handlers_to_SIE;
signal HandlerSelected: out boolean
) is
variable Selected: boolean;
variable Index: integer;
begin
Output.USBAddress <= Input.USBAddress;
Output.DeviceEnabled <= Input.DeviceEnabled;
Output.DeviceConfigured <= Input.DeviceConfigured;
Output.TxData <= Input.TxData;
Output.TxDataValid <= Input.TxDataValid;
Output.DataPID <= Input.DataPID;
Output.Stalled <= Input.Stalled;
Output.Accepted <= Input.Accepted;
Output.Interrupts <= Input.Interrupts;
Output.Disabled <= Input.Disabled;
Output.IntMode <= Input.IntMode;
Selected := (Common.Handler = ID);
HandlerSelected <= Selected;
if Selected then
Output.TxData <= Own.TxData;
Output.TxDataValid <= Own.TxDataValid;
Output.DataPID <= Own.DataPID;
Output.Stalled <= Own.Stalled;
Output.Accepted <= Own.Accepted;
Output.Disabled <= Own.Disabled;
Output.IntMode <= Own.IntMode;
end if;
Output.NeedClock <= Input.NeedClock or Own.NeedClock;
Output.RemoteWakeUp <= Input.RemoteWakeUp or Own.RemoteWakeUp;
Index := 0;
for i in 0 to N_DEVICES-1 loop
if (ADDRESS_HANDLER(i) = ID) then
Output.USBAddress(i) <= Own.USBAddress(Index);
Index := Index+1;
end if;
end loop;
Index := 0;
for i in 0 to N_DEVICES-1 loop
if (ENABLE_HANDLER(i) = ID) then
Output.DeviceEnabled(i) <= Own.DeviceEnabled(Index);
Index := Index+1;
end if;
end loop;
Index := 0;
for i in 0 to N_DEVICES-1 loop
if (CONFIG_HANDLER(i) = ID) then
Output.DeviceConfigured(i) <= Own.DeviceConfigured(Index);
Index := Index+1;
end if;
end loop;
Index := 0;
for i in 0 to N_INTR_BITS-1 loop
if (INTR_HANDLER(i) = ID) then
Output.Interrupts(i) <= Own.Interrupts(Index);
Index := Index+1;
end if;
end loop;
end SIEConnector;
procedure DummySIEConnector(
ID: integer;
signal Output: out T_Handlers_to_SIE;
signal Input: in T_Handlers_to_SIE;
signal Own: in T_Handlers_to_SIE
) is
variable Index: integer;
begin
Output.USBAddress <= Input.USBAddress;
Output.DeviceEnabled <= Input.DeviceEnabled;
Output.DeviceConfigured <= Input.DeviceConfigured;
Output.Interrupts <= Input.Interrupts;
Output.TxData <= Input.TxData;
Output.TxDataValid <= Input.TxDataValid;
Output.DataPID <= Input.DataPID;
Output.Stalled <= Input.Stalled;
Output.Disabled <= Input.Disabled;
Output.Accepted <= Input.Accepted;
Output.IntMode <= Input.IntMode;
Output.NeedClock <= Input.NeedClock or Own.NeedClock;
Output.RemoteWakeUp <= Input.RemoteWakeUp or Own.RemoteWakeUp;
Index := 0;
for i in 0 to N_DEVICES-1 loop
if (ADDRESS_HANDLER(i) = ID) then
Output.USBAddress(i) <= Own.USBAddress(Index);
Output.DeviceEnabled(i) <= Own.DeviceEnabled(Index);
Index := Index+1;
end if;
end loop;
Index := 0;
for i in 0 to N_DEVICES-1 loop
if (CONFIG_HANDLER(i) = ID) then
Output.DeviceConfigured(i) <= Own.DeviceConfigured(Index);
Index := Index+1;
end if;
end loop;
Index := 0;
for i in 0 to N_INTR_BITS-1 loop
if (INTR_HANDLER(i) = ID) then
Output.Interrupts(i) <= Own.Interrupts(Index);
Index := Index+1;
end if;
end loop;
end DummySIEConnector;
procedure UCConnector(signal Output: out T_Handlers_to_UC;
signal Input: in T_Handlers_to_UC;
signal Own: in T_Handlers_to_UC;
signal Selected:in boolean) is
begin
Output.Ready <= Input.Ready and Own.Ready;
Output.Data <= Input.Data;
if Selected then
Output.Data <= Own.Data;
if Input.Data /= byte'(others => '0') then
assert (FALSE) report "2 Handlers driving UC bus" severity warning;
end if;
end if;
end UCConnector;
function HandlersToSIEDefault return T_Handlers_to_SIE is
variable ReturnValue: T_Handlers_to_SIE;
begin
ReturnValue.USBAddress := (others=>(others=>'0'));
ReturnValue.DeviceEnabled := (others=>FALSE);
ReturnValue.DeviceConfigured := (others=>FALSE);
ReturnValue.Interrupts := (others=>FALSE);
ReturnValue.TxData := (others => '0');
ReturnValue.TxDataValid := FALSE;
ReturnValue.DataPID := 0;
ReturnValue.Stalled := FALSE;
ReturnValue.Accepted := FALSE;
ReturnValue.IntMode := FALSE;
ReturnValue.NeedClock := FALSE;
ReturnValue.RemoteWakeUp := FALSE;
return ReturnValue;
end;
function HandlersToUCDefault return T_Handlers_to_UC is
variable ReturnValue: T_Handlers_to_UC;
begin
ReturnValue.Data := (others => '0');
ReturnValue.Ready := TRUE;
return ReturnValue;
end;
end PCK_HANDLERS;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -