1

I have a record in VHDL that contains a pointer (access). I need to create a function that receives this record as parameter and from its data write in a file.

But simulating with MODELSIM I get the following error:

**Error: (vcom-1462) Illegal declaration of constant "xxx" of type x_file_format (type is or contains access type).

How can I pass a pointer as parameter to a function?

jcc18
  • 11
  • 3
  • IEEE Std 1076-2008 4.2 Subprogram declarations, 4.2.2.1 Formal parameter lists "For those parameters with modes, the only mode that is allowed for formal parameters of a function is the mode **in** (whether this mode is specified explicitly or implicitly). The object class shall be **constant,** **signal**, or **file**. If no object class is explicitly given, **constant** is assumed." 5.4 Access types, 5.4.1 General "An object declared to be of an access type shall be an object of class variable. An object designated by an access value is always an object of class variable." –  Dec 09 '18 at 18:26
  • 5.3 Composite types, 5.3.1 General "An object of a composite type represents a collection of objects, one for each element of the composite object. It is an error if a composite type contains elements of file types or protected types. Thus an object of a composite type ultimately represents a collection of objects of scalar or access types, one for each noncomposite subelement of the composite object." –  Dec 09 '18 at 18:42
  • 6. Declarations, 6.4 Objects, 6.4.1 General "There are four classes of objects: constants, signals, variables, and files. The variable class of objects also has an additional subclass: shared variables. The class of an explicitly declared object is specified by the reserved word that shall or may appear at the beginning of the declaration of that object. For a given object of a composite type, each subelement of that object is itself an object of the same class and subclass, if any, as the given object. The value of a composite object is the aggregation of the values of its subelements." –  Dec 09 '18 at 18:52
  • Neither the function tag nor the parameters tag accurately convey definitions found within the VHDL standard. –  Dec 09 '18 at 19:10

1 Answers1

2

Function parameters can only be constant (or signal or file) inputs. Access types must be variables. Therefore you must write a procedure to do it, with the access type passed in as a variable.

Procedure proc ( variable ptr : someAccessType ) is
Tricky
  • 3,791
  • 3
  • 10
  • 23