0

I have some existing code that is making use of a procedure for a bus functional model. I am going to add new functionality that will require me to add a new parameter into this procedure. I want, in order to keep the code backward compatible, the procedure to have a default value. In this way, if that parameter is omitted when the procedure is called, the testbench program will still work.

Is it possible to assign a default value for inputs into a procedure in VHDL?

ocrdu
  • 8,705
  • 21
  • 30
  • 42
quantum231
  • 11,218
  • 24
  • 99
  • 192
  • 2
    IEEE Std 1076-2008 10.7 Procedure call statement "For each formal parameter of a procedure, a procedure call shall specify exactly one corresponding actual parameter. This actual parameter is specified either explicitly, by an association element (other than the actual **open**) in the association list or, in the absence of such an association element, by a default expression (see 6.5.2)." – user16145658 Aug 21 '22 at 02:20
  • 2
    6.5.2 Interface object declarations "If an interface declaration contains a “:=” symbol followed by an expression, the expression is said to be the *default expression* of the interface object." – user16145658 Aug 21 '22 at 05:02
  • 9. Expressions 9.1 General "An expression is a formula that defines the computation of a value." – user16145658 Aug 22 '22 at 20:07

1 Answers1

3

Yes. You simply initialize it with ":= value" following the type. You can do this for any subprogram (procedure or function). For example:

  impure function NewID (
    Name          : String ;
    ParentID      : AlertLogIDType          := OSVVM_SCOREBOARD_ALERTLOG_ID ;
    ReportMode    : AlertLogReportModeType  := ENABLED ;
    Search        : NameSearchType          := NAME_AND_PARENT_ELSE_PRIVATE ;
    PrintParent   : AlertLogPrintParentType := PRINT_NAME_AND_PARENT
  ) return ScoreboardIDType ;
Jim Lewis
  • 894
  • 4
  • 10