0
\$\begingroup\$

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?

\$\endgroup\$
3
  • 2
    \$\begingroup\$ 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)." \$\endgroup\$ Commented Aug 21, 2022 at 2:20
  • 2
    \$\begingroup\$ 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." \$\endgroup\$ Commented Aug 21, 2022 at 5:02
  • \$\begingroup\$ 9. Expressions 9.1 General "An expression is a formula that defines the computation of a value." \$\endgroup\$ Commented Aug 22, 2022 at 20:07

1 Answer 1

3
\$\begingroup\$

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 ;
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.