Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/configuring_blank_lines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ Rules Enforcing Blank Lines
* `package_instantiation_201 <package_instantiation_rules.html#package-instantiation-201>`_
* `port_001 <port_rules.html#port-001>`_
* `port_map_200 <port_map_rules.html#port-map-200>`_
* `port_map_201 <port_map_rules.html#port-map-201>`_
* `pragma_401 <pragma_rules.html#pragma-401>`_
* `pragma_403 <pragma_rules.html#pragma-403>`_
* `process_011 <process_rules.html#process-011>`_
Expand Down
41 changes: 41 additions & 0 deletions docs/port_map_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,47 @@ This rule checks for a blank line below the open parenthesis in a port map.
OVERFLOW => w_overflow
);

port_map_201
############

|phase_3| |error| |blank_line|

This rule checks for blank lines in a port map.

|configuring_blank_lines_link|

**Violation**

.. code-block:: vhdl

generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,

PORT_2 => w_port_2,
PORT_3 => w_port_3
);

**Fix**

.. code-block:: vhdl

generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,
PORT_2 => w_port_2,
PORT_3 => w_port_3
);


port_map_300
############

Expand Down
1 change: 1 addition & 0 deletions docs/rule_groups/blank_line_rule_group.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Rules Enforcing Blank Line Rule Group
* `port_022 <../port_rules.html#port-022>`_
* `port_024 <../port_rules.html#port-024>`_
* `port_map_200 <../port_map_rules.html#port-map-200>`_
* `port_map_201 <../port_map_rules.html#port-map-201>`_
* `pragma_400 <../pragma_rules.html#pragma-400>`_
* `pragma_401 <../pragma_rules.html#pragma-401>`_
* `pragma_402 <../pragma_rules.html#pragma-402>`_
Expand Down
45 changes: 45 additions & 0 deletions tests/port_map/rule_201_test_input.fixed.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

architecture ARCH of ENTITY1 is

begin

U_INST1 : INST1
generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,
PORT_2 => w_port_2,
PORT_3 => w_port_3
);

-- Violations below

U_INST1 : INST1
generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,
PORT_2 => w_port_2,
PORT_3 => w_port_3
);

U_INST1 : INST1
generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,
PORT_2 => w_port_2,
PORT_3 => w_port_3
);


end architecture ARCH;
49 changes: 49 additions & 0 deletions tests/port_map/rule_201_test_input.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

architecture ARCH of ENTITY1 is

begin

U_INST1 : INST1
generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,
PORT_2 => w_port_2,
PORT_3 => w_port_3
);

-- Violations below

U_INST1 : INST1
generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,

PORT_2 => w_port_2,
PORT_3 => w_port_3
);

U_INST1 : INST1
generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,

PORT_2 => w_port_2,


PORT_3 => w_port_3
);


end architecture ARCH;
49 changes: 49 additions & 0 deletions tests/port_map/test_rule_201.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-

import os
import unittest

from tests import utils
from vsg import vhdlFile
from vsg.rules import port_map

sTestDir = os.path.dirname(__file__)

lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_201_test_input.vhd"))

lExpected = []
lExpected.append("")
utils.read_file(os.path.join(sTestDir, "rule_201_test_input.fixed.vhd"), lExpected)


class test_port_map_rule(unittest.TestCase):

maxDiff = None

def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.assertIsNone(eError)

def test_rule_201(self):
oRule = port_map.rule_201()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "port_map")
self.assertEqual(oRule.identifier, "201")
self.assertEqual(oRule.groups, ["blank_line"])

lExpected = [28, 41, 43, 44]

oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))

def test_fix_rule_201(self):
oRule = port_map.rule_201()

oRule.fix(self.oFile)

lActual = self.oFile.get_lines()

self.assertEqual(lExpected, lActual)

oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])
1 change: 1 addition & 0 deletions vsg/rules/port_map/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .rule_100 import rule_100
from .rule_101 import rule_101
from .rule_200 import rule_200
from .rule_201 import rule_201
from .rule_300 import rule_300
from .rule_301 import rule_301
from .rule_302 import rule_302
49 changes: 49 additions & 0 deletions vsg/rules/port_map/rule_201.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-

from vsg import token
from vsg.rules import blank_lines_between_token_pairs as Rule

lTokenPairs = []
lTokenPairs.append([token.port_map_aspect.open_parenthesis, token.port_map_aspect.close_parenthesis])

class rule_201(Rule):
"""
This rule checks for blank lines in a port map.

|configuring_blank_lines_link|

**Violation**

.. code-block:: vhdl

generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,

PORT_2 => w_port_2,
PORT_3 => w_port_3
);

**Fix**

.. code-block:: vhdl

generic map (
G_GEN_1 => 3,
G_GEN_2 => 4,
G_GEN_3 => 5
)
port map (
PORT_1 => w_port_1,
PORT_2 => w_port_2,
PORT_3 => w_port_3
);

"""

def __init__(self):
super().__init__(lTokenPairs)