Multiple Return Values in VHDL
VHDL has built-in support for multiple return values through the use of records. This feature is used often in idiomatic VHDL, for example to return both result and status values from a function.
In this VHDL code:
We define a record type
vals_type
to hold multiple return values.The
vals
function returns avals_type
record containing two integers.In the main process, we call the
vals
function and assign its result to a variable of typevals_type
.We can then access individual fields of the record using dot notation.
To demonstrate using only a subset of the returned values, we directly access the
b
field of the record returned byvals
.The
print
procedure is used to simulate the printing functionality, as VHDL doesn’t have built-in print functions like other languages.
When simulated, this VHDL code will produce output similar to:
This example demonstrates how VHDL can handle multiple return values using records, which is a common pattern in VHDL design.