jeremiah-c-leary / vhdl-style-guide

Style guide enforcement for VHDL
GNU General Public License v3.0
192 stars 39 forks source link

Add rules for package instantiation declarations #1306

Open JHertz5 opened 3 weeks ago

JHertz5 commented 3 weeks ago

Is your feature request related to a problem? Please describe. I am using package instantiations, e.g.

package my_pkg is new my_generic_pkg
  generic map (
   g_my_generic => 2
  );

and at the moment, it appears that very few rules act on this code. For example, I can refactor the above code to the following:

PACKAGE           MY_PKG              IS
      NEW         MY_GENERIC_PKG
  GENERIC
  MAP
                      (
G_MY_GENERIC=>
                     2
            );

which is very ugly, but when I run VSG on it, the only rule that reports an error is generic_map_003 (Move the ( to the same line as the *generic map* keywords.)

Describe the solution you'd like I would like a set of rules to be created for package instantiations to enforce case, alignment, whitespace, etc. (or if it makes more sense, for the existing ruleset to be expanded to include package instantiations. I feel that, in most cases, new rules would be more logical as package instantiation declarations are listed by the LRM as a separate construct from package declarations or package bodies).

JHertz5 commented 1 week ago

I'm planning to raise a PR for this change.

JHertz5 commented 1 week ago

I will aim to mirror the rules for package declarations. The ruleset will likely look something like this

package_instantiation rule based on package rule
package_instantiation_001 package_005
package_instantiation_100 package_002
package_instantiation_200 package_003
package_instantiation_300 package_001
package_instantiation_500 package_004
package_instantiation_501 package_010
package_instantiation_502 package_013
package_instantiation_600 package_016
package_instantiation_601 package_017

There may be a couple of extra rules included as required.

There are also a few generic map rules that are set up to apply only to component/entity instantiations rather than package instantiations. We may have to expand those rules to include package instantiations (but judging by the LRM, it is also possible to have generic maps in block and subprogram instantiations, so I think that I'll raise a new issue to make the generic map rules apply in all possible situations).

JHertz5 commented 1 week ago

In order to avoid a massive PR that would be thousands of line long and a pain to review, I will break this issue up into smaller issues:

Subtask Issue PR
Case rules (+ setup) #1322 #1326
Indent and blank line rules #1323 #1327
Structure rules #1324 #1328
Whitespace rules #1325 #1329
Naming rules #1330 #1331

I will close this issue once all of the PRs above have been merged.