TWiki
>
P1076 Web
>
Vhdl2019CollectedRequirements
>
FunctionInterface
(revision 21) (raw view)
Edit
Attach
---+ Allow access and protected type parameters on function interfaces %TOC% ---++ Proposal Information * Current Owner: Main.JimLewis, ... * Contributors: Main.JimLewis, ... * Date Proposed: 2012-Aug-16 * Date Last Updated: 2012-Aug-16 * Priority: * Complexity: * Focus: Testbench * Related Issues: None * Competing Issues: None ---++ Language Change Specification Link [[LCS2016_002][LCS-2016-002]] ---++ Requirement Summary Allow access and protected types on function interfaces. Allowed for ADA functions. See: http://en.wikibooks.org/wiki/Ada_Programming/Subprograms#Functions ---++ Use Model: Access Types Currently it is not possible to create an !EmptyLine (named consistent with !EndFile and original name before removed) Usage: <verbatim>next when EmptyLine(buf) ; function EmptyLine ( variable L : inout Line ) return boolean is variable Valid : boolean ; variable Char : character ; begin skip_whitespace(L) ; return L = null or L.all'length = 0 ; end function EmptyLine ;</verbatim> Then we would also be able to create a to_string for type line that also deallocates a line: <verbatim>function to_string( variable L : inout line ) return string is variable result : string(L'range) ; begin result := L.all ; deallocate(L) ; return result ; end function to_string ; </verbatim> Then to create a to_string for composite types, such as integer_vector, where "write" is already defined can be done as follows: <verbatim>function to_string( IV : in integer_vector ) return string is variable L : line ; begin write(L, IV) ; return to_string(L) ; end function to_string ; </verbatim> Or alternately we can leverage generics: <verbatim>function generic_to_string generic( type AType ; procedure write(L : inout line ; A : AType ; JUSTIFIED : SIDE := right; FIELD : WIDTH := 0) is <> ) ; parameter( A : in AType ) return string is variable L : line ; begin write(L, A) ; return to_string(L) ; end function generic_to_string ; </verbatim> With generics, a to_string function for integer_vector becomes: <verbatim>function to_string is new generic_to_string generic map (AType => integer_vector) ; </verbatim> Another usage is within coverage modeling for the OSVVM package "CoveragePkg", however, the background information for the justification dives deeply into data structures for coverage modeling. ---+++ Extend Concatenation Allow concatenation of types that are access types or composites that contain access types. ---++ Use Model: Protected Type Motivation: Local customizations and extensions to a protected type interface ---+++ Layering on top of !CoveragePkg and !RandomPkg <verbatim>function RandCovPoint( variable RV : inout RandomPType ; constant Bin : in RangeArrayType ) return integer_vector is variable result : integer_vector(Bin'range) ; begin for i in Bin'range loop result(i) := RV.RandInt(Bin(i).min, Bin(i).max) ; end loop ; return result ; end procedure RandCovPoint ;</verbatim> ---+++ Modeling Semaphores See [[SemaphoreDataStructure]] Currently VHDL functions do not allow either access types or Protected Type inputs. ADA removed the requirement for not allowing access type inputs in ADA-95. This would allow overloads like the non-protected type procedure TryGet [SemaphorePType, Boolean, Integer] to be re-expressed as a function TryGet [SemaphorePType, Integer return boolean] which is a more natural way to use it. The code is as follows <verbatim> function TryGet (Semaphore : SemaphorePType ; Count : Integer := 1 ) return boolean is begin return Semaphore.TryGet(Count) ; end function TryGet ;</verbatim> ---++ Proposal ---++ Comments This relaxation should be limited to impure functions, because the function may have side effects. -- Main.PeterFlake - 2014-12-18 ---+++ General ---+++ Arguments Against ---++ Supporters _Add your signature here to indicate your support for the proposal_ -- Main.JimLewis -- Main.KevinJennings - 2013-04-12 -- [[Main.BrentHahoe][Brent Hayhoe]] - 2014-12-23 -- Main.MortenZilmer - 2015-01-21 -- Main.PatrickLehmann - 2016-02-19 -- Main.TorstenMeissner - 2016-05-18
Edit
|
Attach
|
P
rint version
|
H
istory
:
r22
<
r21
<
r20
<
r19
<
r18
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r1 - 2020-02-17 - 15:34:31 -
TWikiGuest
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-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback