Skip to content

Allow protected type declarations to be infered for simple protected types

Since shared variables must be of a protected types - in many instances I have seen something like the following to get around the problem, usually in an architecture.

type boolean_pt is protected
  procedure set(b : boolean);
  function get return boolean;
end protected;

type boolean_pt is protected body
  variable b_i : boolean;

  procedure set(b : boolean) b_i := n; end procedure;
  
  function get return boolean is return b_i; end function;
end protected body;

It would appear the initial declaration is superfluous. There are no "private" subprograms. In addition, for subprograms, we have the following paragraph in VHDL 2019 LRM - S4.3 Subprogram Bodies:

The declaration of a subprogram is optional. In the absence of such a declaration, the subprogram specification of the subprogram body acts as the declaration. For each subprogram declaration, there shall bea corresponding body. If both a declaration and a body are given, the subprogram specification of the body shall lexically conform (see 4.10) to the subprogram specification of the declaration. Furthermore, both the declaration and the body shall occur immediately within the same declarative region (see 12.1).

I propose that the text in S5.6.3 - Protected type bodies be re-worded to be in line with the subprogram declaration above:

The declaration of a simple protected type is optional. In the absence of such a declaration, the specification of the protected type body acts as the declaration. For each protected type declaration, there shall be a corresponding body. If both a declaration and a body are given, the protected type specification of the body shall lexically conform (see 4.10) to the subprogram specification of the declaration. Furthermore, both the declaration and the body shall occur immediately within the same declarative region (see 12.1).

Edited by Richard Head
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information