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

📄 usb_new_pck_configuration.vhdl

📁 实现USB接口功能的VHDL和verilog完整源代码
💻 VHDL
📖 第 1 页 / 共 3 页
字号:
--------------------------------------------------------------------------------------
---- File >>> usb_new_pck_configuration.vhdl 
---- Iden >>>							981130-10:32:49
----
---- Project:           USB Developement
---- Customer:          Philips_ITCL
----
---- VHDL Design Unit:  Configuration package
---- Written by:        Jo Degraef                                
----                    Easics nv
----                    http://www.easics.com      
----                    mailto: vhdl@easics.be
----
---- Creation Date:     Mon, 30 Nov 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;


package PCK_CONFIGURATION is


  -------------------------------------------------------
  -------          Constant Declarations          -------
  -------------------------------------------------------

  constant CHIPID_WIDTH: integer := 16;

  -- Total number of configuration bits
  constant CONFIG_RANGE: integer := 9;

  constant CONFIG_RESET: booleans := (FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE);

  -- Delay between edge of VBUS and disconnect of PU resistor in ms
  constant DISCONNECT_DELAY: integer := 128;

  -- Maximum data packet size
  --constant MAX_BUFFER_SIZE: integer := 294;
  constant MAX_BUFFER_SIZE: integer := 64; 

  -- Maximum value of clock divider
  constant MAX_CLK_DIV: integer := 1;

  -- Number of register configuration bits
  constant MAX_DEVICE_SPEED: T_UsbSpeed_enum := USB_FULL_SPEED;

  -- Max number of endpoints in one handler
  constant MAX_ENDPOINT_NR: integer := 9;

  -- Maximum data packet size +2
  --constant MAX_OVERFLOW_SIZE: integer := 296;
  constant MAX_OVERFLOW_SIZE: integer := 66; 

  -- Total number of configurations
  constant N_CONFIGURATIONS: integer := 1; -- changed by fma 99/07/13: only one configuration

  -- Total number of devices
  constant N_DEVICES: integer := 1;

  -- Number of downstream ports
  constant N_DOWNSTREAM_PORTS: integer := 1;

  -- Number of embedded ports
  constant N_EMBEDDED_PORTS: integer := 1;

  -- Total number of endpoints
  constant N_ENDPOINTS: integer := 10;

  -- Total number of handlers
  constant N_HANDLERS: integer := 2;

  -- Number of bits in interrupt register
  constant N_INTR_BITS: integer := 11;

  -- Number of pin configuration bits
  constant PINCONFIG_RANGE: integer := 1;

  -- RAM size needed for data buffering
  constant RAM_SIZE: integer := 256;

  -- Is GetFrameNumber command supported
  constant SUPPORT_C_GETFRAMENUMBER: boolean := TRUE;

  -- Support Hub functionality
  constant SUPPORT_HUB: boolean := FALSE;

  -- Device supports iso data
  constant SUPPORT_ISO: boolean := TRUE;

  -- Remote wakeup capability
  constant SUPPORT_RESUME: boolean := TRUE;

  -- Is SoftConnect Supported
  constant SUPPORT_SOFTCONNECT: boolean := TRUE;

  -- Number of register configuration bits
  constant UCCONFIG_RANGE: integer := 8;

  -- Debounce time for VBUS
  constant VBUS_DEBOUNCE_TIME: integer := 3;


  -------------------------------------------------------
  -------            Type Declarations            -------
  -------------------------------------------------------
  type T_fivebits_array is array (integer range <>) of five_bits;

  subtype S_EmbDev_range is integer range 0 to N_DEVICES-1;
  subtype S_ClkDivRange is integer range 0 to MAX_CLK_DIV;

  -- Endpoint Direction
  type T_Direction_enum is (DIR_OUT,DIR_IN,DIR_UNKNOWN);
     
  -- Ranges for different endpoint properties
  subtype S_BufferSizeRange is integer range 0 to MAX_OVERFLOW_SIZE;
  subtype S_PhysEndpointRange is integer range 0 to N_ENDPOINTS -1;
  subtype S_USBDeviceRange is integer range 0 to N_DEVICES -1;
  subtype S_USBEndpointRange is integer range 0 to 15;
  subtype S_HandlerRange is integer range 0 to N_HANDLERS - 1;
  subtype S_ConfigurationRange is integer range 0 to N_CONFIGURATIONS -1;


  type T_EndpointType_enum is (UNUSED, BULK_OR_INTERRUPT, CONTROL, ISOCHRONOUS); 
  type T_PhysEndpoint is record
    EndpointType: T_EndpointType_enum;
    BufferSize:   S_BufferSizeRange;
--    BufferStart:  S_RAMSizeRange;
    Mapped:       boolean;
    USBDevice:    S_USBDeviceRange;
    USBEndpoint:  S_USBEndpointRange;
    USBDirection: T_Direction_enum;
    HasCorrespondingEP: boolean;
    CorrespondingEP: S_PhysEndpointRange;
    DoubleBuffer: boolean; 
  end record;

  -- Types for Physical Endpoint properties
  type T_PhysEndpointPool is array (0 to N_ENDPOINTS-1) of T_PhysEndpoint;
  type T_PhysEndpointSetup is array (0 to N_CONFIGURATIONS-1) of T_PhysEndpointPool;

  -- types for boolean property
  type T_USBBoolean_1d is array (0 to 15) of boolean;
  type T_USBBoolean_2d is array (0 to N_DEVICES-1) of T_USBBoolean_1d;
  type T_USBBoolean is array (0 to N_CONFIGURATIONS-1) of T_USBBoolean_2d;

  -- types for Endpoint Type property
  type T_USBEPType_1d is array (0 to 15) of T_EndpointType_enum;
  type T_USBEPType_2d is array (0 to N_DEVICES-1) of T_USBEPType_1d;
  type T_USBEPType is array (0 to N_CONFIGURATIONS-1) of T_USBEPType_2d;

  -- types for physical endpoint mapping
  type T_USBPhysEndpoint_1d is array (0 to 15) of S_PhysEndpointRange;
  type T_USBPhysEndpoint_2d is array (0 to N_DEVICES-1) of T_USBPhysEndpoint_1d;
  type T_USBPhysEndpoint is array (0 to N_CONFIGURATIONS-1) of T_USBPhysEndpoint_2d;

  -- types for Buffer Size property
  type T_USBBufferSize_1d is array (0 to 15) of S_BufferSizeRange;
  type T_USBBufferSize_2d is array (0 to N_DEVICES-1) of T_USBBufferSize_1d;
  type T_USBBufferSize is array (0 to N_CONFIGURATIONS-1) of T_USBBufferSize_2d;

  -- types for handlers
  type T_USBHandler_1d is array (0 to 15) of S_HandlerRange;
  type T_USBHandler_2d is array (0 to N_DEVICES-1) of T_USBHandler_1d;
  type T_USBHandler is array (0 to N_CONFIGURATIONS-1) of T_USBHandler_2d;

  -- Properties of a unidirectional USB endpoint
  type T_HalfUSBEndpointSlice is record
    EndpointType: T_USBEPType;
    BufferSize:   T_USBBufferSize;
    DoubleBuffer: T_USBBoolean;
    PhysEndpoint: T_USBPhysEndpoint;
--    BufferStart:  T_USBBufferStart;
    Handler:      T_USBHandler;
  end record;

  -- Properties of a complete USB endpoint
  type T_USBEndpointSetup is record
    OUTEP: T_HalfUSBEndpointSlice;
    INEP : T_HalfUSBEndpointSlice;
  end record;


  
  type T_Handler_int is array(0 to N_HANDLERS-1) of integer;
  type T_Device_int is array(0 to N_DEVICES-1) of integer;
  type T_Config_int is array(0 to N_CONFIGURATIONS-1) of integer;
  subtype S_Device_bool is booleans(N_DEVICES-1 downto 0);
  type T_Interrupt_int is array(0 to N_INTR_BITS-1) of integer;
  subtype S_Interrupt_bool is booleans(N_INTR_BITS-1 downto 0);





  -- Types and function for Configuration info
  subtype S_ConfigArray is booleans(CONFIG_RANGE-1 downto 0);
  type T_Pattern_enum is (F,T,X);
  type T_PatternArray is array(CONFIG_RANGE-1 downto 0) of T_Pattern_enum;

  function Equal(ConfigArray: S_ConfigArray;
		 PatternArray: T_PatternArray) return boolean;

  -- Creation of USB Endpoint Setup
  function GetUSBEndpointSetup return T_USBEndpointSetup;  



  -------------------------------------------------------
  -------            Feature Definitions          -------
  -------------------------------------------------------

  -- Function for Interrupt Masking
  function InterruptMask(Endpoint: S_PhysEndpointRange;
			 ConfigArray: S_ConfigArray) return boolean;

  constant NUM_ENDPOINTS: T_Handler_int:= (
                                          0 => 10,
                                          1 => 0);

  constant N_HANDLER_INTR_BITS: T_Handler_int:= (
                                          0 => 10,
                                          1 => 1);

  constant N_HANDLER_ADDRESSES: T_Handler_int:= (
                                          0 => 1,
                                          1 => 0);

  constant N_HANDLER_CONFIG_BITS: T_Handler_int:= (
                                          0 => 1,
                                          1 => 0);

  constant N_HANDLER_ENABLE_BITS: T_Handler_int:= (
                                          0 => 1,
                                          1 => 0);

  constant ADDRESS_HANDLER: T_Device_int:= (
                                          0 => 0);

  constant ENABLE_RESET_ON: T_Config_int:= (
                                          0 => 0);
                                          --1 => 0); changed by fma 99/07/14 Only one configuration.

  constant N_HANDLER_DEVICES: T_Handler_int:= (
                                            0 => 1,
                                            1 => 0);

  constant CONFIG_HANDLER: T_Device_int:= (
                                          0 => 0);

  constant ENABLE_HANDLER: T_Device_int:= (
                                          0 => 0);

  constant INTR_HANDLER: T_Interrupt_int:= (
                                          0 => 0,
                                          1 => 0,
                                          2 => 0,
                                          3 => 0,
                                          4 => 0,
                                          5 => 0,
                                          6 => 0,
                                          7 => 0,
                                          8 => 0,
                                          9 => 0,
                                          10 => 1);

  constant HANDLERS_MAX_BUFFER_SIZE: T_Handler_int:= (
                                            0 => 196,
                                            1 => 0);

  type T_HANDLER_ENUM is (UC_HANDLER, DEVICE_HANDLER, HUB_HANDLER, DEVICE_HANDLER_SA, UCBARE_HANDLER, ISOIN_HANDLER, ISOOUT_HANDLER);

  type T_HANDLER_NAMES is array(0 to N_HANDLERS-1) of T_HANDLER_ENUM;

  constant HANDLER_NAMES: T_HANDLER_NAMES := (
                                            0 => UC_HANDLER,
                                            1 => DEVICE_HANDLER);

  function RemoteWakeUpEnable(Config: S_ConfigArray)
              return boolean;

  function NumberOfEmbeddedPorts(Config: S_ConfigArray)
              return integer;

  function GangModeOvercurrent(Config: S_ConfigArray)
              return boolean;

  function GetDeviceSpeed(Config: S_ConfigArray)
              return T_UsbSpeed_enum;

  function EdgeInterrupt(Config: S_ConfigArray)
              return boolean;

  function NoBlinkingLEDs(Config: S_ConfigArray)
              return boolean;

  function InterruptOnNAK(Config: S_ConfigArray)
              return boolean;

  function AlwaysPLLClock(Config: S_ConfigArray)
              return boolean;

⌨️ 快捷键说明

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