Contact us Start a Trial

Subtype indications

A subtype indication names a type or a subtype and can add a constraint to it. Sigasi checks the subtype indications of signals, variables, constants, ports, parameters, generics, aliases, attributes, record elements, array elements, access types, file types, allocators, and external names for the following problems:

Type mark does not denote a type or subtype

The name in a subtype indication must denote a type or a subtype. If it denotes anything else, Sigasi will flag this as an error (rule 264).

VHDL
constant width : integer := 8;

signal a : width;     -- width is a constant, not a type
signal b : integer;

Subtype of object is not fully constrained

The subtype of a signal, a variable, or a constant must be fully constrained, and so must the subtype indication of an allocator. If any index range is missing, Sigasi will flag this as an error (rule 265).

VHDL
signal a : bit_vector;               -- no index range
signal b : bit_vector(7 downto 0);

An initial value determines the index ranges, so Sigasi does not report a constant with an initial value. Since VHDL-2019, the same holds for signals and variables. A deferred constant is not reported either, because its full declaration in the package body provides the index ranges.

Before VHDL-2008, the subtypes of array elements and record elements also had to be fully constrained.

Index constraint not compatible with index subtype

Each range in an index constraint must lie within the index subtype of the array type. Sigasi will flag a range outside the index subtype as an error (rule 266). A null range is always allowed.

VHDL
subtype small is integer range 0 to 3;
type memory is array (small range <>) of bit;

signal a : memory(0 to 7);   -- 7 is outside small's "0 to 3" range
signal b : memory(0 to 3);

File type with a not fully constrained element

The values in a file must have a fully constrained subtype. For a file of arrays, this applies to the element subtype of the array, the index range of the array itself can remain unconstrained. Sigasi will flag other file types as an error (rule 267).

VHDL
type table is array (natural range <>) of bit_vector;

type table_file is file of table;        -- the elements of table have no index range
type text_file  is file of bit_vector;

File type of a multidimensional array

A file can store arrays, but only one-dimensional ones. Sigasi will flag a file type of a multidimensional array as an error (rule 268).

VHDL
type matrix is array (natural range <>, natural range <>) of bit;

type matrix_file is file of matrix;

Subtype indication in a non-object alias

An alias of an object, such as a signal or a slice of a variable, can have a subtype indication. An alias of anything else, for example a type, a subprogram, or a package, cannot. Sigasi will flag a subtype indication in a non-object alias as an error (rule 269).

VHDL
subtype byte is bit_vector(7 downto 0);
signal data : bit_vector(7 downto 0);

alias a : bit_vector(7 downto 0) is byte;   -- byte is a subtype, not an object
alias b is byte;
alias c : bit_vector(7 downto 0) is data;