TWiki
>
P1076/Ballots Web
>
Vhdl2019CollectedRequirements
>
MapSubprogramGenericOnCall
(revision 2) (raw view)
Edit
Attach
---+ Map Subprogram Generics on call %TOC% ---++ Proposal Editing Information * Who Updates: OPEN, Main.JimLewis * Date Proposed: 2012-08-17 * Date Last Updated: 2012-08-17 * Priority: * Complexity: * Focus: Testbench ---++ Summary Generics on a subprogram require a subprogram instance before usage. For some subprograms that are called only infrequently this is inconvenient. Suggested during [[2012_MeetingJuly19]] ---++ Related and/or Competing Issues: Yes Anonymous types on subprograms - this could be an alternative to it. ---++ Proposal Details Declaration: <verbatim>function Mux4 generic ( type DataType ) parameter ( MuxSel : in std_logic_vector(1 downto 0) ; A, B, C, D : in DataType ) return DataType is . . . end procedure Mux4; </verbatim> Usage of the function: <verbatim>Mux4 generic map (integer) (MuxSel, D1, D2, D3, D4) ; </verbatim> ---++ Questions ---++ General Comments [[Main.BrentHahoe][<Brent Hayhoe>]] 2014-03-27 - I think that this is a good idea, just slightly concerned that the usage syntax might seem a bit messy. Perhaps this might be a little clearer: <verbatim>generic map (integer) Mux4 (MuxSel, D1, D2, D3, D4) ; </verbatim> It seems slightly more like a normal function call (to me). [[Main.BrentHahoe][</Brent Hayhoe>]] Main.LievenLemiengre - 2016-03-11 - It is tricky to make this work with the type checker & overload resolution but it can be done. I don't like 'generic map' in expressions so I suggest you drop it completely. <verbatim> result := Mux4(integer)(MuxSel, D1, D2, D3, D4); result := Mux4(bit_vector)(MuxSel, D1, D2, D3, D4)(1); -- mux4, specialized for bit_vector, invoke it, take an element out of the array result := Mux4(integer)(MuxSelA, D1, D2, D3, D4) + Mux4(integer)(MuxSelB, D1, D2, D3, D4)</verbatim> ---++ Supporters -- [[Main.BrentHahoe][Brent Hayhoe]] - 2014-03-27 -- Main.JimLewis - 2014-12-03 _Add your signature here to indicate your support for the proposal_
Edit
|
Attach
|
P
rint version
|
H
istory
:
r5
<
r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r1 - 2020-02-17 - 15:34:56 -
TWikiGuest
P1076/Ballots
Log In
or
Register
P1076/Ballots 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