Subject: Re: Proposal Ben_P2: Numeric_Unsigned,
From: VhdlCohen@aol.com
Date: Mon Oct 07 2002 - 18:31:12 PDT
Jim,
Your proposal looks good, but I do have the following comments:
Comparison operators (?language currently does not permit this?),
It would be problematic if we rely on the implicit comparison operators ("=
, "/=", ...) when we treat std_logic_vector as unsigned.
Not the Numeric function for the "=" for the Unsigned:
-- Id: C.25
function "=" (L, R: UNSIGNED) return BOOLEAN;
-- Result subtype: BOOLEAN
-- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly
-- of different lengths.
On the other hand, explicitly overloading the comparison operators for the
std_logic_[u]vector is also problematic, because we would not be compliant
with current operations (the implicit ones) for that type. That means that
old code would work differently.
This is a BIG issue of great concern!!!
damn if you do, damn if you don't!
That reason by itself would be sufficient to kill that Ben_P2 proposal. I
need help here. Any suggestions?
By the way we cannot rely on the user to make sure that the actual parameters
of the comparison operators are the same size, because if they are not, the
implicit operators will be exercised.
Logic Operators (in Std_logic_1164),
Shift Operators (in std_logic_1164 in the future),
Match Functions (in Numeric_Std now, moving to std_logic_1164?),
TO_01 (needs to be in std_logic_1164 - for parallel to numeric_std),
Questions
RESIZE should this be in std_logic_1164?
If we are in sync with the 1164 group, then we could do something like that.
Otherwise, we would need to define interim packages for the above functions.
Ben
----------------------------------------------------------------------------
Ben Cohen Publisher, Trainer, Consultant (310) 721-4830
<A HREF="http://www.vhdlcohen.com/">http://www.vhdlcohen.com/> vhdlcohen@aol.com
Author of following textbooks:
* Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn
0-9705394-2-8
* Component Design by Example ", 2001 isbn 0-9705394-0-1
* VHDL Coding Styles and Methodologies, 2nd Edition, 1999 isbn 0-7923-8474-1
* VHDL Answers to Frequently Asked Questions, 2nd Edition, isbn 0-7923-8115
------------------------------------------------------------------------------
In a message dated 10/7/02 5:34:00 PM Pacific Daylight Time,
jim@synthworks.com writes:
> We did not seem to reach consensus on the last proposal, so
> let me give this a shot. This one has no comparison functions
> and includes functions for both std_logic_vector and
> std_ulogic_vector.
>
>
> <BEN_P2>
> I would like to propose that we support an additional package
> named Numeric_Unsigned. This package will treat both std_logic_vector
> and std_ulogic_vector as unsigned and provide numeric operations
> for these types.
>
> -- Id: A.1
> function "abs" (ARG: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0).
> -- Result: Returns the absolute value of a STD_ULOGIC_VECTOR vector ARG.
>
> -- Id: A.2
> function "-" (ARG: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0).
> -- Result: Returns the value of the unary minus operation on a
> -- STD_ULOGIC_VECTOR vector ARG.
>
>
>
>
>
> --============================================================================
>
> -- Id: A.3
> function "+" (L, R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(MAX(L'LENGTH, R'LENGTH)-1 downto 0).
> -- Result: Adds two STD_LOGIC_VECTOR vectors that may be of different
> lengths.
>
> -- Id: A.4
> function "+" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(MAX(L'LENGTH, R'LENGTH)-1 downto 0).
> -- Result: Adds two STD_ULOGIC_VECTOR vectors that may be of different
> lengths.
>
> -- Id: A.5
> function "+" (L: STD_LOGIC_VECTOR; R: NATURAL) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(L'LENGTH-1 downto 0).
> -- Result: Adds an STD_LOGIC_VECTOR vector, L, with a non-negative
> INTEGER,
> R.
>
> -- Id: A.6
> function "+" (L: NATURAL; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'LENGTH-1 downto 0).
> -- Result: Adds a non-negative INTEGER, L, with an STD_LOGIC_VECTOR
> vector,
> R.
>
> -- Id: A.7
> function "+" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0).
> -- Result: Adds an INTEGER, L(may be positive or negative), to a
> STD_ULOGIC_VECTOR
> -- vector, R.
>
> -- Id: A.8
> function "+" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0).
> -- Result: Adds a STD_ULOGIC_VECTOR vector, L, to an INTEGER, R.
>
>
>
>
>
> --============================================================================
>
> -- Id: A.9
> function "-" (L, R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(MAX(L'LENGTH, R'LENGTH)-1 downto 0).
> -- Result: Subtracts two STD_LOGIC_VECTOR vectors that may be of different
> lengths.
>
> -- Id: A.10
> function "-" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(MAX(L'LENGTH, R'LENGTH)-1 downto 0).
> -- Result: Subtracts a STD_ULOGIC_VECTOR vector, R, from another
> STD_ULOGIC_VECTOR vector, L,
> -- that may possibly be of different lengths.
>
> -- Id: A.11
> function "-" (L: STD_LOGIC_VECTOR;R: NATURAL) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(L'LENGTH-1 downto 0).
> -- Result: Subtracts a non-negative INTEGER, R, from an STD_LOGIC_VECTOR
> vector, L.
>
> -- Id: A.12
> function "-" (L: NATURAL; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'LENGTH-1 downto 0).
> -- Result: Subtracts an STD_LOGIC_VECTOR vector, R, from a non-negative
> INTEGER, L.
>
> -- Id: A.13
> function "-" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0).
> -- Result: Subtracts an INTEGER, R, from a STD_ULOGIC_VECTOR vector, L.
>
> -- Id: A.14
> function "-" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0).
> -- Result: Subtracts a STD_ULOGIC_VECTOR vector, R, from an INTEGER, L.
>
>
>
>
>
> --============================================================================
>
> -- Id: A.15
> function "*" (L, R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR((L'LENGTH+R'LENGTH-1) downto 0).
> -- Result: Performs the multiplication operation on two STD_LOGIC_VECTOR
> vectors
> -- that may possibly be of different lengths.
>
> -- Id: A.16
> function "*" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR((L'LENGTH+R'LENGTH-1) downto 0)
> -- Result: Multiplies two STD_ULOGIC_VECTOR vectors that may possibly be
> of
> -- different lengths.
>
> -- Id: A.17
> function "*" (L: STD_LOGIC_VECTOR; R: NATURAL) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR((L'LENGTH+L'LENGTH-1) downto 0).
> -- Result: Multiplies an STD_LOGIC_VECTOR vector, L, with a non-negative
> -- INTEGER, R. R is converted to an STD_LOGIC_VECTOR vector of
> -- SIZE L'LENGTH before multiplication.
>
> -- Id: A.18
> function "*" (L: NATURAL; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR((R'LENGTH+R'LENGTH-1) downto 0).
> -- Result: Multiplies an STD_LOGIC_VECTOR vector, R, with a non-negative
> -- INTEGER, L. L is converted to an STD_LOGIC_VECTOR vector of
> -- SIZE R'LENGTH before multiplication.
>
> -- Id: A.19
> function "*" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR((L'LENGTH+L'LENGTH-1) downto 0)
> -- Result: Multiplies a STD_ULOGIC_VECTOR vector, L, with an INTEGER, R. R
> is
> -- converted to a STD_ULOGIC_VECTOR vector of SIZE L'LENGTH before
> -- multiplication.
>
> -- Id: A.20
> function "*" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR((R'LENGTH+R'LENGTH-1) downto 0)
> -- Result: Multiplies a STD_ULOGIC_VECTOR vector, R, with an INTEGER, L. L
> is
> -- converted to a STD_ULOGIC_VECTOR vector of SIZE R'LENGTH before
> -- multiplication.
>
>
>
>
>
> --============================================================================
> --
> -- NOTE: If second argument is zero for "/" operator, a severity level
> -- of ERROR is issued.
>
> -- Id: A.21
> function "/" (L, R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(L'LENGTH-1 downto 0)
> -- Result: Divides an STD_LOGIC_VECTOR vector, L, by another
> STD_LOGIC_VECTOR vector, R.
>
> -- Id: A.22
> function "/" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0)
> -- Result: Divides an STD_ULOGIC_VECTOR vector, L, by another
> STD_ULOGIC_VECTOR vector, R.
>
> -- Id: A.23
> function "/" (L: STD_LOGIC_VECTOR; R: NATURAL) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(L'LENGTH-1 downto 0)
> -- Result: Divides an STD_LOGIC_VECTOR vector, L, by a non-negative
> INTEGER,
> R.
> -- If NO_OF_BITS(R) >L'LENGTH, result is truncated to L'LENGTH.
>
> -- Id: A.24
> function "/" (L: NATURAL; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'LENGTH-1 downto 0)
> -- Result: Divides a non-negative INTEGER, L, by an STD_LOGIC_VECTOR
> vector,
> R.
> -- If NO_OF_BITS(L) >R'LENGTH, result is truncated to R'LENGTH.
>
> -- Id: A.25
> function "/" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0)
> -- Result: Divides a STD_ULOGIC_VECTOR vector, L, by an INTEGER, R.
> -- If NO_OF_BITS(R) >L'LENGTH, result is truncated to L'LENGTH.
>
> -- Id: A.26
> function "/" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0)
> -- Result: Divides an INTEGER, L, by a STD_ULOGIC_VECTOR vector, R.
> -- If NO_OF_BITS(L) >R'LENGTH, result is truncated to R'LENGTH.
>
>
>
>
>
> --============================================================================
> --
> -- NOTE: If second argument is zero for "rem" operator, a severity level
> -- of ERROR is issued.
>
> -- Id: A.27
> function "rem" (L, R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'LENGTH-1 downto 0)
> -- Result: Computes "L rem R" where L and R are STD_LOGIC_VECTOR vectors.
>
> -- Id: A.28
> function "rem" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0)
> -- Result: Computes "L rem R" where L and R are STD_ULOGIC_VECTOR vectors.
>
> -- Id: A.29
> function "rem" (L: STD_LOGIC_VECTOR; R: NATURAL) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(L'LENGTH-1 downto 0)
> -- Result: Computes "L rem R" where L is an STD_LOGIC_VECTOR vector and R
> is
> a
> -- non-negative INTEGER.
> -- If NO_OF_BITS(R) >L'LENGTH, result is truncated to L'LENGTH.
>
> -- Id: A.30
> function "rem" (L: NATURAL; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'LENGTH-1 downto 0)
> -- Result: Computes "L rem R" where R is an STD_LOGIC_VECTOR vector and L
> is
> a
> -- non-negative INTEGER.
> -- If NO_OF_BITS(L) >R'LENGTH, result is truncated to R'LENGTH.
>
> -- Id: A.31
> function "rem" (L: STD_ULOGIC_VECTOR; R: NATURAL) return
> STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0)
> -- Result: Computes "L rem R" where L is STD_ULOGIC_VECTOR vector and R is
> an INTEGER.
> -- If NO_OF_BITS(R) >L'LENGTH, result is truncated to L'LENGTH.
>
> -- Id: A.32
> function "rem" (L: NATURAL; R: STD_ULOGIC_VECTOR) return
> STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0)
> -- Result: Computes "L rem R" where R is STD_ULOGIC_VECTOR vector and L is
> an INTEGER.
> -- If NO_OF_BITS(L) >R'LENGTH, result is truncated to R'LENGTH.
>
>
>
>
>
> --============================================================================
> --
> -- NOTE: If second argument is zero for "mod" operator, a severity level
> -- of ERROR is issued.
>
> -- Id: A.33
> function "mod" (L, R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'LENGTH-1 downto 0)
> -- Result: Computes "L mod R" where L and R are STD_LOGIC_VECTOR vectors.
>
> -- Id: A.34
> function "mod" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0)
> -- Result: Computes "L mod R" where L and R are STD_ULOGIC_VECTOR vectors.
>
> -- Id: A.35
> function "mod" (L: STD_LOGIC_VECTOR; R: NATURAL) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(L'LENGTH-1 downto 0)
> -- Result: Computes "L mod R" where L is an STD_LOGIC_VECTOR vector and R
> -- is a non-negative INTEGER.
> -- If NO_OF_BITS(R) >L'LENGTH, result is truncated to L'LENGTH.
>
> -- Id: A.36
> function "mod" (L: NATURAL; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'LENGTH-1 downto 0)
> -- Result: Computes "L mod R" where R is an STD_LOGIC_VECTOR vector and L
> -- is a non-negative INTEGER.
> -- If NO_OF_BITS(L) >R'LENGTH, result is truncated to R'LENGTH.
>
> -- Id: A.37
> function "mod" (L: STD_ULOGIC_VECTOR; R: NATURAL) return
> STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0)
> -- Result: Computes "L mod R" where L is a STD_ULOGIC_VECTOR vector and
> -- R is an INTEGER.
> -- If NO_OF_BITS(R) >L'LENGTH, result is truncated to L'LENGTH.
>
> -- Id: A.38
> function "mod" (L: NATURAL; R: STD_ULOGIC_VECTOR) return
> STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0)
> -- Result: Computes "L mod R" where L is an INTEGER and
> -- R is a STD_ULOGIC_VECTOR vector.
> -- If NO_OF_BITS(L) >R'LENGTH, result is truncated to R'LENGTH.
>
>
>
> --================
> ============================================================
> -- RESIZE Functions
>
>
>
>
> --============================================================================
>
> -- Id: R.1
> function RESIZE (ARG: STD_ULOGIC_VECTOR; NEW_SIZE: NATURAL) return
> STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(NEW_SIZE-1 downto 0)
> -- Result: Resizes the STD_ULOGIC_VECTOR vector ARG to the specified size.
> -- To create a larger vector, the new [leftmost] bit positions
> -- are filled with the sign bit (ARG'LEFT). When truncating,
> -- the sign bit is retained along with the rightmost part.
>
> -- Id: R.2
> function RESIZE (ARG: STD_LOGIC_VECTOR; NEW_SIZE: NATURAL) return
> STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(NEW_SIZE-1 downto 0)
> -- Result: Resizes the STD_ULOGIC_VECTOR vector ARG to the specified size.
> -- To create a larger vector, the new [leftmost] bit positions
> -- are filled with '0'. When truncating, the leftmost bits
> -- are dropped.
>
>
>
>
>
> --============================================================================
> -- Conversion Functions
>
>
>
>
> --============================================================================
>
> -- Id: D.1
> function TO_INTEGER (ARG: STD_LOGIC_VECTOR) return NATURAL;
> -- Result subtype: NATURAL. Value cannot be negative since parameter is an
> -- STD_LOGIC_VECTOR vector.
> -- Result: Converts the STD_LOGIC_VECTOR vector to an INTEGER.
>
> -- Id: D.2
> function TO_INTEGER (ARG: STD_ULOGIC_VECTOR) return NATURAL;
> -- Result subtype: NATURAL
> -- Result: Converts a STD_ULOGIC_VECTOR vector to an INTEGER.
>
>
>
>
>
>
>
> --==============================================================================
> --============================= New subprograms
> ================================
>
>
>
>
>
> --==============================================================================
>
> -- Id: A.3R
> function "+"(L: STD_LOGIC_VECTOR; R: STD_ULOGIC) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(L'RANGE)
> -- Result: Similar to A.3 where R is a one bit STD_LOGIC_VECTOR
>
> -- Id: A.3L
> function "+"(L: STD_ULOGIC; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'RANGE)
> -- Result: Similar to A.3 where L is a one bit STD_LOGIC_VECTOR
>
> -- Id: A.4R
> function "+"(L: STD_ULOGIC_VECTOR; R: STD_ULOGIC) return
> STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(L'RANGE)
> -- Result: Similar to A.4 where R is bit 0 of a non-negative
> -- STD_ULOGIC_VECTOR
>
> -- Id: A.4L
> function "+"(L: STD_ULOGIC; R: STD_ULOGIC_VECTOR) return
> STD_ULOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'RANGE)
> -- Result: Similar to A.4 where L is bit 0 of a non-negative
> -- STD_ULOGIC_VECTOR
>
> -- Id: A.9R
> function "-"(L: STD_LOGIC_VECTOR; R: STD_ULOGIC) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(L'RANGE)
> -- Result: Similar to A.9 where R is a one bit STD_LOGIC_VECTOR
>
> -- Id: A.9L
> function "-"(L: STD_ULOGIC; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'RANGE)
> -- Result: Similar to A.9 where L is a one bit STD_LOGIC_VECTOR
>
> -- Id: A.10R
> function "-"(L: STD_ULOGIC_VECTOR; R: STD_ULOGIC) return
> STD_ULOGIC_VECTOR;
> -- Result subtype: STD_ULOGIC_VECTOR(L'RANGE)
> -- Result: Similar to A.10 where R is bit 0 of a non-negative
> -- STD_ULOGIC_VECTOR
>
> -- Id: A.10L
> function "-"(L: STD_ULOGIC; R: STD_ULOGIC_VECTOR) return
> STD_ULOGIC_VECTOR;
> -- Result subtype: STD_LOGIC_VECTOR(R'RANGE)
> -- Result: Similar to A.10 where R is bit 0 of a non-negative
> -- STD_ULOGIC_VECTOR
>
> </BEN_P2>
>
>
> Note, this is Numeric_Std functions with the following removed:
> Comparison operators (?language currently does not permit this?),
> Logic Operators (in Std_logic_1164),
> Shift Operators (in std_logic_1164 in the future),
> Match Functions (in Numeric_Std now, moving to std_logic_1164?),
> TO_01 (needs to be in std_logic_1164 - for parallel to numeric_std),
>
> Questions
> RESIZE should this be in std_logic_1164?
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Jim Lewis
> Director of Training mailto:Jim@SynthWorks.com
> SynthWorks Design Inc. http://www.SynthWorks.com
> 1-503-590-4787
>
> Expert VHDL Training for Hardware Design and Verification
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> --
>
This archive was generated by hypermail 2b28 : Mon Oct 07 2002 - 18:31:53 PDT