TWiki
>
P1076 Web
>
Vhdl2019CollectedRequirements
>
AbstractPackages
(2020-02-17,
JimLewis
)
(raw view)
E
dit
A
ttach
---+ Abstract Packages <br />%TOC% ---++ Proposal Editing Information * Who Updates: Main.JimLewis, <Add YourName >, ... * Date Proposed: 2012-08-17 * Date Last Updated: 2012-08-17 * Priority: * Complexity: * Focus: Testbench ---++ Requirement Summary Abstract packages are intended to be used with formal package generics. Rather than being a package with generic inputs, they are a methodology that indicate what subprograms a package implements to support. ---++ Related and/or Competing Issues: Protected Type Updates ---++ Issue A limitation to type generics is that we cannot make any assumptions about what operators and/or subprograms are supported for a given type. As a result, the type and subprograms must be passed as generics. This is shown below on the interface to RandomGenericPkg. <verbatim>package RandomGenericPkg is generic ( type RandomSeedType ; -- base type for randomization procedure Uniform (Result : out real ; Seed : inout RandomSeedType) ; function GenRandSeed(IV : integer_vector) return RandomSeedType ; function GenRandSeed(I : integer) return RandomSeedType ; function GenRandSeed(S : string) return RandomSeedType ) ; . . . end package RandomGenericPkg ; </verbatim> ---++ Use Model 1: The goal is to minimize the amount of information that needs to be sent. <verbatim>package RandomGenericPkg is generic ( package RandomBasePkg is abstract work.RandomBaseAbsPkg ) ; use RandomBasePkg.all ; . . . end package RandomGenericPkg ; ... package RandomBaseAbsPkg is abstract type RandomSeedType ; -- base type for randomization procedure Uniform (Result : out real ; Seed : inout RandomSeedType) ; function GenRandSeed(IV : integer_vector) return RandomSeedType ; function GenRandSeed(I : integer) return RandomSeedType ; function GenRandSeed(S : string) return RandomSeedType ; end package RandomBaseAbsPkg ; ... package RandomPkg is new RandomGenericPkg generic map (RandomBaseAbsPkg => RandomBasePkg) ; </verbatim> ---++ Use Model 2: -- There are issues in this that still need to be resolved. When we work with math types, there may be more than one type defined in the package, such as ieee.numeric_std.unsigned and ieee.numeric_std.signed. <verbatim>package NumericAbsPkg is abstract type NumericType ; function from_integer(I : integer) return NumericType ; function to_integer(N : NumericType) return integer ; function from_real(R : real) return NumericType ; function to_real(N : NumericType) return NumericType ; function "+"(l, r : NumericType) return NumericType ; function "+"(l : NumericType ; r : integer) return NumericType ; function "+"(l : integer ; r : NumericType ) return NumericType ; function "+"(l : NumericType ; r : real) return NumericType ; function "+"(l : real; r : NumericType ) return NumericType ; function "-"(l, r : NumericType) return NumericType ; function "-"(l : NumericType ; r : integer) return NumericType ; function "-"(l : integer ; r : NumericType ) return NumericType ; function "-"(l : NumericType ; r : real) return NumericType ; function "-"(l : real; r : NumericType ) return NumericType ; end package NumericAbsPkg ; package ComplexMathGenericPkg is generic ( package NumericPkg is abstract work.NumericAbsPkg ) ; use NumericPkg.all ; . . . end package ComplexMathGenericPkg ; . . . package ComplexMathUnsignedPkg is new ComplexMathGenericPkg generic map (NumericPkg => ieee.numeric_std with (NumericType => Unsigned ) ; -- Issues - NumericType not identified as a type that may need to be mapped. -- issues - from_real and from_integer need to be sized for array based types and -- perhaps does not work. So mixed overloading may need to be omitted.</verbatim> ---++ Proposal ---++ Questions ---++ General Comments An essential companion to generics on packages. Rust has a nice solution for this problem: https://doc.rust-lang.org/book/traits.html or on wikipedia the general description: https://en.wikipedia.org/wiki/Type_class -- Main.LievenLemiengre - 2016-04-07 ---++ Supporters _Add your signature here to indicate your support for the proposal_ -- Main.JimLewis - 2014-12-04 -- Main.PatrickLehmann - 2016-02-19
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r6
<
r5
<
r4
<
r3
<
r2
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r6 - 2020-02-17 - 15:34:25 -
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