TWiki
>
P1076 Web
>
Vhdl2019CollectedRequirements
>
VectorLiteralntrospection
(2020-02-17,
JimLewis
)
(raw view)
E
dit
A
ttach
---+ Type Introspection on Vector Literals %TOC% ---++ Proposal Information * Who Updates: Main.JimLewis, ... * Date Proposed: 2011-07-15 * Date Last Updated: 2011-07-15 * Priority: * Complexity: * Focus: General Language, but specifically Testbench ---++ Requirement Summary Do introspection on vector (single dimensional array) literal values ---++ Rationale Vectors can be used to create an "argv" like set of values to an interface (such as a subprogram). To effectively use this capability within an overloaded subprogram environment, we need introspection of vector literals ---++ Related Issues: None = General ---++ Competing Issues: None at this time ---++ Requirement details ---++ Use Models ---+++ Use Model: Simplify use of aggregates in subprogram calls ---++++ Current Situation Consider the following two subprogram declarations: <verbatim> function to_integer_vector (BV : in boolean_vector ) return integer_vector ; function to_integer_vector (SLV : in std_logic_vector ) return integer_vector ;</verbatim> Calling the subprograms with an aggregate results in an ambiguous expression. Note since they return a variable number of values, generally they are used within the call to another subprogram. <verbatim> --! CrossCovBin1.ICover(to_integer_vector( ((Empty='1'),(Rdy='1')) )); -- ambiguous</verbatim> One way to address this is to use a type qualifier. <verbatim> CrossCovBin1.ICover(to_integer_vector( boolean_vector'((Empty='1'),(Rdy='1')) )); </verbatim> Ironically, the language already does introspection of vectors when concatenation is used instead of aggregates. <verbatim> CrossCovBin1.ICover(to_integer_vector( ((Empty='1') & (Rdy='1')) )); -- not ambiguous</verbatim> ---++++ Code Simplification with Proposal With proposal, type qualifiers are not required with aggregates <verbatim> CrossCovBin1.ICover(to_integer_vector( ((Empty='1'),(Rdy='1')) )); -- enhanced support</verbatim> ---+++ Use Model: Simplify use of string literals? It would be nice if this solution also addressed string literals. If this proposal were to also include string literals, then the following would no longer be ambiguous. However, the main intent here is to solve the aggregate issue and this issue in particular was addressed in VHDL-2008 with std.textio.swrite. <verbatim> std.textio.write(buf, "This does not contain std_ulogic values") ; </verbatim> ---+++ Use Model: More effectively overload subprograms ---++++ Current Situation (from randomization package): In the my randomization package there are two flavors of creating discrete distributions. The first, DistInt, takes in a vector of weights and returns a value that is between 0 and N (where N = Weight'length-1). Where each weight will occur 100*(weight/Sumof(weights)) percent of the time. The second, DistValInt, takes in a vector of value and weight pairs. When a particular weight is selected, the corresponding value is returned. <verbatim> impure function DistInt ( Weight : integer_vector ) return integer ; impure function DistValInt ( A : DistType ) return integer ;</verbatim> The following shows two calls to these function methods. <verbatim> TestData1 := RV.DistInt ( (70, 10, 10, 5, 5) ) ; TestData2 := RV.DistValInt ( ((1,70), (5,10), (9,10), (13, 5), (17,5)) ) ;</verbatim> ---++++ Current Situation - Alternative Implementation: To facilitate remembering the name of the function required for weighted distribution, it would be easier if each were named DistInt . This is shown below. <verbatim> impure function DistInt ( Weight : integer_vector ) return integer ; impure function DistInt ( A : DistType ) return integer ;</verbatim> Unfortunately, the function method calls now require type qualifiers: <verbatim> TestData1 := RV.DistInt ( integer_vector'(70, 10, 10, 5, 5) ) ; TestData2 := RV.DistInt ( DistType'((1,70), (5,10), (9,10), (13, 5), (17,5)) ) ;</verbatim> ---++++ Code Simplification with Proposal The enhancements proposed, gives us the advantage of allowing both functions to have the same name and allows the call to be able to be done without type qualifiers. Function Declarations: <verbatim> impure function DistInt ( Weight : integer_vector ) return integer ; impure function DistInt ( A : DistType ) return integer ;</verbatim> Method calls without type qualifiers due to enhancements: <verbatim> TestData1 := RV.DistInt ( (70, 10, 10, 5, 5) ) ; TestData2 := RV.DistInt ( ((1,70), (5,10), (9,10), (13, 5), (17,5)) ) ;</verbatim> ---++ Arguments FOR * User-code simplification -- [[Main.BrentHahoe][BAH]] ---++ Arguments AGAINST * Compiler complexity? ---++ General Comments ---++ Supporters _Add your signature here to indicate your support for the proposal_ -- [[Main.BrentHahoe][Brent Hayhoe]] -2013-01-24 -- Main.JimLewis - 2014-12-03 -- Main.PatrickLehmann - 2016-02-19
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r9
<
r8
<
r7
<
r6
<
r5
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r9 - 2020-02-17 - 15:34:45 -
JimLewis
P1076
Log In
or
Register
P1076 Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
Webs
Main
P1076
Ballots
LCS2016_080
P10761
P1647
P16661
P1685
P1734
P1735
P1778
P1800
P1801
Sandbox
TWiki
VIP
VerilogAMS
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback