?? usb_new_pck_general.vhdl
字號:
------------------------------------------------------------------------------------
---- File >>> usb_new_pck_general.vhdl
---- Iden >>> 950307-10:15:54
----
---- Copyright(c) 1995 by Easics NV. All rights reserved.
----
---- This source file is proprietary and confidential information
---- of Easics NV and may be used and disclosed only as authorized
---- in a consulting and/or subcontracting agreement where the
---- source code is part of the statement of work specified in
---- the agreement, or if Easics NV has given it's written consent
---- to such use or disclosure.
---- This source file remains the sole property of
---- Easics NV, Kapeldreef 60, B-3001 Leuven, Belgium.
----
----
---- Project: Easics Development
---- Customer: Easics
----
---- Module: GENERAL package with project definitions
---- Written by: VHDL User (e-mail: vhdl@easics.be)
---- Easics NV.
---- Kapeldreef 60
---- B-3001 Leuven
---- Belgium
---- Tel +32-16-270.400
---- Fax +32-16-270.319
---- e-mail: vhdl@easics.be
----
---- Creation Date: Tue, 07 Mar 1995
----
---- Purpose:
----
---- Revision history:
----
------------------------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
package PCK_GENERAL is
-- recommended bit type
subtype one_bit is std_logic;
-- recommended subtypes for arrays of bits
subtype two_bits is unsigned (1 downto 0);
subtype three_bits is unsigned (2 downto 0);
subtype nibble is unsigned (3 downto 0);
subtype four_bits is nibble;
subtype five_bits is unsigned (4 downto 0);
subtype six_bits is unsigned (5 downto 0);
subtype seven_bits is unsigned (6 downto 0);
subtype byte is unsigned (7 downto 0);
subtype nine_bits is unsigned (8 downto 0);
subtype ten_bits is unsigned (9 downto 0);
subtype eleven_bits is unsigned (10 downto 0);
subtype twelve_bits is unsigned (11 downto 0);
subtype thirteen_bits is unsigned (12 downto 0);
subtype fourteen_bits is unsigned (13 downto 0);
subtype fifteen_bits is unsigned (14 downto 0);
subtype sixteen_bits is unsigned (15 downto 0);
subtype two_bytes is sixteen_bits;
subtype seventeen_bits is unsigned (16 downto 0);
subtype eighteen_bits is unsigned (17 downto 0);
subtype nineteen_bits is unsigned (18 downto 0);
subtype twenty_bits is unsigned (19 downto 0);
subtype twenty_one_bits is unsigned (20 downto 0);
subtype twenty_two_bits is unsigned (21 downto 0);
subtype twenty_three_bits is unsigned (22 downto 0);
subtype twenty_four_bits is unsigned (23 downto 0);
subtype three_bytes is twenty_four_bits;
subtype twenty_five_bits is unsigned (24 downto 0);
subtype twenty_six_bits is unsigned (25 downto 0);
subtype twenty_seven_bits is unsigned (26 downto 0);
subtype twenty_eight_bits is unsigned (27 downto 0);
subtype twenty_nine_bits is unsigned (28 downto 0);
subtype thirty_bits is unsigned (29 downto 0);
subtype thirty_one_bits is unsigned (30 downto 0);
subtype thirty_two_bits is unsigned (31 downto 0);
subtype four_bytes is thirty_two_bits;
subtype thirty_three_bits is unsigned (32 downto 0);
subtype thirty_four_bits is unsigned (33 downto 0);
subtype thirty_five_bits is unsigned (34 downto 0);
subtype thirty_six_bits is unsigned (35 downto 0);
subtype thirty_seven_bits is unsigned (36 downto 0);
subtype thirty_eight_bits is unsigned (37 downto 0);
subtype thirty_nine_bits is unsigned (38 downto 0);
subtype forty_bits is unsigned (39 downto 0);
subtype five_bytes is forty_bits;
subtype forty_one_bits is unsigned (40 downto 0);
subtype forty_two_bits is unsigned (41 downto 0);
subtype forty_three_bits is unsigned (42 downto 0);
subtype forty_four_bits is unsigned (43 downto 0);
subtype forty_five_bits is unsigned (44 downto 0);
subtype forty_six_bits is unsigned (45 downto 0);
subtype forty_seven_bits is unsigned (46 downto 0);
subtype forty_eight_bits is unsigned (47 downto 0);
subtype six_bytes is forty_eight_bits;
subtype forty_nine_bits is unsigned (48 downto 0);
subtype fifty_bits is unsigned (49 downto 0);
subtype fifty_one_bits is unsigned (50 downto 0);
subtype fifty_two_bits is unsigned (51 downto 0);
subtype fifty_three_bits is unsigned (52 downto 0);
subtype fifty_four_bits is unsigned (53 downto 0);
subtype fifty_five_bits is unsigned (54 downto 0);
subtype fifty_six_bits is unsigned (55 downto 0);
subtype seven_bytes is fifty_six_bits;
subtype fifty_seven_bits is unsigned (56 downto 0);
subtype fifty_eight_bits is unsigned (57 downto 0);
subtype fifty_nine_bits is unsigned (58 downto 0);
subtype sixty_bits is unsigned (59 downto 0);
subtype sixty_one_bits is unsigned (60 downto 0);
subtype sixty_two_bits is unsigned (61 downto 0);
subtype sixty_three_bits is unsigned (62 downto 0);
subtype sixty_four_bits is unsigned (63 downto 0);
subtype eight_bytes is sixty_four_bits;
-- useful constants
-- use ACTIVE_LOW and INACTIVE_HIGH for active low signals
constant LOW: one_bit := '0';
constant ACTIVE_LOW: one_bit := '0';
constant HIGH: one_bit := '1';
constant INACTIVE_HIGH: one_bit := '1';
-- an array of booleans
type booleans is array (integer range <>) of boolean;
-- an array of bytes
type T_byte_array is array (integer range <>) of byte;
-- NOT SYNTHESIZABLE IN SYNERGY up till version 2.2
-- an array of integers
-- type integer_vector is array (integer range <>) of integer;
-- Function IntegerPositions returns an array of integers (integer_vector)
-- with Nr elements, with values equal to Offset + i*Distance
-- in which i=0..Nr-1.
-- function IntegerPositions (Nr: integer;
-- Offset: integer;
-- Distance: integer) return integer_vector;
-- Function IsNrInList returns:
-- TRUE: if argument Number is present in argument List
-- FALSE: otherwise.
-- e.g.: if List = (3, 15, 27, 29)
-- then IsNrInList(List, 12) returns FALSE
-- and IsNrInList(List, 27) returns TRUE
-- function IsNrInList (List: integer_vector; Number: integer)
-- return boolean;
-- Function GetIndexInList returns the position of the argument Number
-- in the argument List.
-- e.g.: if List = (3, 15, 27, 29), declared as integer_vector(0 to 3)
-- ^ ^ ^ ^
-- 0 1 2 3
-- then GetIndexInList(List, 27) returns 2;
-- e.g.: if List = (3, 15, 27, 29), declared as integer_vector(3 downto 0)
-- ^ ^ ^ ^
-- 3 2 1 0
-- then GetIndexInList(List, 27) returns 1;
-- function GetIndexInList (List: integer_vector; Number: integer)
-- return integer;
-- MSB detection
function GetMsbPosition (Arg: unsigned)
return integer;
-- LSB detection
function GetLsbPosition (Arg: unsigned)
return integer;
-- Function InsertWord inserts the InsWord in Target starting
-- from Position. If RevIns is given the bit order is reversed.
-- WORKS ONLY FOR DOWNTO RANGES!!! Examples are given below:
-- 7.6.5.4.3.2.1.0 Target 7.4.3.2.1.0.1.0 Result
-- 4.3.2.1.0 InsWord ^^^^^^^^^=InsWord
-- 2 Position
-- FALSE RevIns
-- 7.6.5.4.3.2.1.0 Target 7.6.0.1.2.3.4.0 Result
-- 4.3.2.1.0 InsWord ^^^^^^^^^=InsWord
-- 1 Position
-- TRUE RevIns
-- 7.6.5.4.3.2.1.0 Target 2.3.4.5.6.7.8.9 Result
-- 9.8.7.6.5.4.3.2 InsWord ^^^^^^^^^^^^^^^=InsWord
-- 0 Position
-- TRUE RevIns
function InsertWord (Target: unsigned;
InsWord: unsigned;
Position: natural;
RevIns: boolean := FALSE)
return unsigned;
-- extraction functions
function ExtractMSBits (Arg: unsigned; NrBits: integer)
return unsigned;
function ExtractMSB (Arg: unsigned)
return one_bit;
function ExtractLSBits (Arg: unsigned; NrBits: integer)
return unsigned;
function ExtractLSB (Arg: unsigned)
return one_bit;
-- assembling functions
function AssembleLSBits (Arg: unsigned; Target: unsigned)
return unsigned;
function AssembleLSB (Arg: one_bit; Target: unsigned)
return unsigned;
function AssembleMSBits (Arg: unsigned; Target: unsigned)
return unsigned;
-- Increment, Decrement modulo functions
function IncMod (Arg: natural; Modulo: positive)
return natural;
function DecMod (Arg: natural; Modulo: positive)
return natural;
-- Increment, Decrement modulo functions in range LB..UB
function IncModRange (Arg: integer; LB: integer; UB: integer)
return integer;
function DecModRange (Arg: integer; LB: integer; UB: integer)
return integer;
-- Saturatable increment function
function IncSat (Arg: natural; SatVal: positive)
return natural;
-- Is at maximum value, ie. Modulo - 1
function IsAtMaxValue (Arg: natural; Modulo: positive)
return boolean;
-- useful general functions
function Minimum (Arg1: integer; Arg2: integer)
return integer;
function Maximum (Arg1: integer; Arg2: integer)
return integer;
function Log2 (Arg: positive)
return natural;
function EventOccurred (Arg1: one_bit; Arg2: one_bit)
return boolean;
function EventOccurred (Arg1: boolean; Arg2: boolean)
return boolean;
function MakeEvent (Arg: one_bit)
return one_bit;
function MakeEvent (Arg: boolean)
return boolean;
-- DOC_BEGIN: function IsRisingEdge/IsFallingEdge
-- Description: Detect whether there is a rising/falling edge from
-- Previous to Current for both one_bit and Boolean objects
-- A rising edge on a Boolean object is defined as a transition
-- from FALSE to TRUE, a falling edge as the inverse.
-- Returns: TRUE if the condition holds, FALSE otherwise.
-- DOC_END
function IsRisingEdge (Current: one_bit; Previous: one_bit)
return boolean;
function IsRisingEdge (Current: boolean; Previous: boolean)
return boolean;
function IsFallingEdge (Current: one_bit; Previous: one_bit)
return boolean;
function IsFallingEdge (Current: boolean; Previous: boolean)
return boolean;
function conv_active_low (Arg: boolean)
return one_bit;
function conv_active_high (Arg: boolean)
return one_bit;
-- for compatibility reasons = conv_active_high
function conv_bit (Arg: boolean)
return one_bit;
function conv_active_low (Arg: one_bit)
return boolean;
function conv_active_high (Arg: one_bit)
return boolean;
function conv_active_low (Arg: booleans)
return unsigned;
function conv_active_high (Arg: booleans)
return unsigned;
function conv_active_low (Arg: unsigned)
return booleans;
function conv_active_high (Arg: unsigned)
return booleans;
-- overload to_integer for std_logic
function to_integer (Arg: std_logic)
return integer;
-- overload shl (shift left) and shr (shift right) from Synopsys'
-- arithmetic package, so that the shift value can be an integer
function shl (Arg: unsigned; count: natural) return unsigned;
function shr (Arg: unsigned; count: natural) return unsigned;
-- reduce functions
function and_reduce (Arg: unsigned) return one_bit;
function nand_reduce (Arg: unsigned) return one_bit;
function or_reduce (Arg: unsigned) return one_bit;
function nor_reduce (Arg: unsigned) return one_bit;
function xor_reduce (Arg: unsigned) return one_bit;
function xnor_reduce (Arg: unsigned) return one_bit;
function and_reduce (Arg: booleans) return boolean;
function nand_reduce (Arg: booleans) return boolean;
function or_reduce (Arg: booleans) return boolean;
function nor_reduce (Arg: booleans) return boolean;
function xor_reduce (Arg: booleans) return boolean;
function xnor_reduce (Arg: booleans) return boolean;
-- The following functions were defined in arithmetic in version2.2b
-- but where no longer defined in std_logic_arith package
-- therefore...
-- function "and" (L, R: unsigned) return unsigned;
-- function "nand" (L, R: unsigned) return unsigned;
-- function "or" (L, R: unsigned) return unsigned;
-- function "nor" (L, R: unsigned) return unsigned;
-- function "xor" (L, R: unsigned) return unsigned;
-- function xnor (L, R: unsigned) return unsigned;
-- function "not" (L: unsigned) return unsigned;
-- function "and" (L, R: signed) return signed;
-- function "nand" (L, R: signed) return signed;
-- function "or" (L, R: signed) return signed;
-- function "nor" (L, R: signed) return signed;
-- function "xor" (L, R: signed) return signed;
-- function xnor (L, R: signed) return signed;
-- function "not" (L: signed) return signed;
-- functions to reverse (mirror) an array of bits
function Reverse(Arg: signed) return signed;
function Reverse(Arg: unsigned) return unsigned;
-- functions to generate/check odd/even parity
function GenerateOddParity (Arg: unsigned)
return one_bit;
function GenerateEvenParity (Arg: unsigned)
return one_bit;
function CheckOddParity (Arg: unsigned)
return boolean;
function CheckEvenParity (Arg: unsigned)
return boolean;
end PCK_GENERAL;
package body PCK_GENERAL is
-- Integer array functions
-- function IntegerPositions (Nr: integer;
-- Offset: integer;
-- Distance: integer)
-- return integer_vector is
-- variable Result: integer_vector(0 to Nr-1);
-- begin
-- for i in 0 to Nr-1 loop
-- Result(i) := Offset + i * Distance;
-- end loop;
-- return Result;
-- end IntegerPositions;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -