Configuring Previous Line Rules

There are rules which will check the contents on lines above code structures. These rules allow enforcement of comments and blank lines.

There are several options to these rules, which can be selected by using the style option:

Option

Values

Default Value

Description

style

no_blank_line, require_blank_line, no_code, allow_comment, require_comment, require_blank_line

require_blank_line

  • no_blank_line = Removes blank lines on the line above.

  • require_blank_line = Requires a blank line on the line above.

  • no_code = Either a blank line; or comment(s) on the line(s) above.

  • allow_comment = Either a blank line; or comment(s) on the line(s) above and a blank line above the comment(s).

  • require_comment = Comment(s) required on the line(s) above and a blank line above the comment(s).

  • no_blank_line_unless_different_library = Removes blank lines on lines above unless the library is different.

Note

Unless stated in the rule description, the default style is require_blank_line.

Warning

It is important to be aware these rules may conflict with rules that enforce blank lines below keywords. This can occur when a below rule is applied and then on the next line a previous rule applies. Resolve any conflicts by changing the configuration of either rule.

This is an example of how to configure these options.

rule :
  entity_003:
     style : require_blank_line

Note

All examples below are using the rule entity_004.

Example: style set to no_blank_line

The following code would fail with this option:

library fifo_dsn;
-- Define entity

entity fifo is

The following code would pass with this option:

library fifo_dsn;
-- Define entity
entity fifo is

Example: style set to require_blank_line

The following code would fail with this option:

library fifo_dsn;
-- Define entity
entity fifo is

The following code would pass with this option:

library fifo_dsn;
-- Define entity

entity fifo is

Example: style set to no_code

The following code would fail with this option:

library fifo_dsn;
entity fifo is

The following code would pass with this option:

library fifo_dsn;

entity fifo is

library fifo_dsn;
-- Comment

entity fifo is

library fifo_dsn;
-- Comment
entity fifo is

Example: style set to allow_comment

The following code would fail with this option:

library fifo_dsn;
entity fifo is

library fifo_dsn;
-- Comment
entity fifo is

The following code would pass with this option:

library fifo_dsn;

entity fifo is

library fifo_dsn;
-- Comment

entity fifo is

library fifo_dsn;

-- Comment
entity fifo is

Example: style set to require_comment

The following code would fail these options:

library fifo_dsn;
entity fifo is

library fifo_dsn;
-- Comment
entity fifo is

The following code would pass these options:

library fifo_dsn;

-- Comment
entity fifo is

Example: style set to no_blank_line_unless_different_library

This option provides grouping of use clauses based on library.

The following code:

library ieee;

use ieee.std_logic_1164.all;

use ieee.numeric_std.all;

use work.axi4_stream_pkg.all;

use work.axi4_lite_pkg.all;

will be fixed to:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

use work.axi4_stream_pkg.all;
use work.axi4_lite_pkg.all;

Rules Enforcing Previous Lines