Docsity

Language Attributes - HDL Design - Lecture Slides, Slides of Verilog and VHDL

Partial preview of the text

Download Language Attributes - HDL Design - Lecture Slides and more Slides Verilog and VHDL in PDF only on Docsity!

Language Attributes and Package

Standard

A very useful aspect of the language.

Attributes

• What are attributes?

• VHDL Attributes

  • Types
  • Signal
  • Variables
  • Examples
  • Signal Specific
  • Other

• Package Standard

What are attributes?

• VHDL attributes provide additional

information on the language element to which

they are associated.

• For example

– They can tell you the size of an array and whether

the index is X to Y or Y downto X.

– They can tell you a signal’s last value

– Etc.

Attributes that relate to TYPES

• ATTRIBUTE: T’BASE

  • Kind: Type
  • Prefix: Any Type or Subtype T
  • Result Type: The base type of T
  • Result: Same – a type
  • Restrictions: This attribute is allowed only as a prefix of the

name of another attribute; T’BASE’LEFT

  • Example: BIT’BASE’LEFT is ‘0’
    • Base Type: The base type of a type is the type itself

Attributes that relate to TYPES

• ATTRIBUTE: T’RIGHT

– Kind: Value

– Prefix: Any scalar type or subtype T

– Result Type: Same type a T

– Result: The right bound of T

– Example: BIT’RIGHT has value ‘1’

Attributes that relate to TYPES

• ATTRIBUTE: T’HIGH

– Kind: Value

– Prefix: Any scalar type or subtype T

– Result Type: Same type a T

– Result: The upper bound of T

– Example: BIT’ HIGH has value ‘1’

Attributes that relate to TYPES

  • ATTRIBUTE: T’POS(X)
    • Kind: Function
    • Prefix: Any discrete or physical type or subtype T
      • A discrete type is an enumeration or intger type.
    • Parameter: Any expression whose type is the base type of T
    • Result Type: Universal Integer
      • Universal integer is an integer of an anonymous predefined integer type. An integer.
    • Result: The position number of the value of the parameter.
    • Example:
      • type operations is (OPADD, OPSUB, OPAND, OPOR);
      • signal oper : operations;
      • Then operations’POS(OPSUB) has value 2
      • operations’POS(OPOR) has value 4

Attributes that relate to TYPES

• ATTRIBUTE: T’VAL(X)

  • Kind: Function
  • Prefix: Any discrete or physical type or subtype T
  • Parameter: Any expression of any integer type
  • Result Type: The base type of T
  • Result: The value from the type whose position number is

the universal integer value corresponding to X

  • Example:
    • type operations is (OPADD, OPSUB, OPAND, OPOR);
    • signal oper : operations;
    • Then operations’VAL(2) has value OPSUB
    • operations’VAL(4) has value OPOR

Attributes that relate to TYPES

  • ATTRIBUTE: T’PRED(X)
    • Kind: Function
    • Prefix: Any discrete or physical type or subtype T
    • Parameter: Any expression whose type is the base type of T
    • Result Type: The base type of T
    • Result: The value whose position number is one less than that of the parameter.
    • Restricitons: An error occurs if X equals T’BASE’LOW
    • Example:
      • type operations is (OPADD, OPSUB, OPAND, OPOR);
      • signal oper : operations;
      • Then operations’PRED(OPSUB) has value OPADD
      • operations’PRED(OPAND) has value OPSUB

Attributes that relate to TYPES

  • ATTRIBUTE: T’LEFTOF(X)
    • Kind: Function
    • Prefix: Any discrete or physical type or subtype T
    • Parameter: Any expression whose type is the base type of T
    • Result Type: The base type of T
    • Result: The value which is to the left of the parameter in the range of T.
    • Restricitons: An error occurs if X equals T’BASE’LEFT
    • Example:
      • type operations is (OPADD, OPSUB, OPAND, OPOR);
      • signal oper : operations;
      • Then operations’LEFTOF(OPSUB) has value OPADD

Attributes that relate to ARRAYS

  • ATTRIBUTE: A’LEFT[(N)]
    • Kind: Function
    • Prefix: Any prefix A that is an array object
    • Parameter: Locally static expression of type integer. Defaults to 1.
    • Result Type: Type of the Nth index range of A
    • Result: Left bound of the Nth index range of A.
  • ATTRIBUTE: A’RIGHT[(N)]
    • Kind: Function
    • Prefix: Any prefix A that is an array object
    • Parameter: Locally static expression of type integer. Defaults to 1.
    • Result Type: Type of the Nth index range of A
    • Result: Right bound of the Nth index range of A.

Attributes that relate to ARRAYS

  • ATTRIBUTE: A’HIGH[(N)]
    • Kind: Function
    • Prefix: Any prefix A that is an array object
    • Parameter: Locally static expression of type integer. Defaults to 1.
    • Result Type: Type of the Nth index range of A
    • Result: Upper bound of the Nth index range of A.
  • ATTRIBUTE: A’LOW[(N)]
    • Kind: Function
    • Prefix: Any prefix A that is an array object
    • Parameter: Locally static expression of type integer. Defaults to 1.
    • Result Type: Type of the Nth index range of A
    • Result: Lower bound of the Nth index range of A.

Attributes that relate to ARRAYS

• ATTRIBUTE: A’LENGHT[(N)]

  • Kind: Range
  • Prefix: Any prefix A that is an array object
  • Parameter: Locally static expression of type integer.

Defaults to 1.

  • Result Type: Universal Integer
  • Result: Number of values in the Nth index range, i.e.,

A’HIGH(N) – A’LOW(N) +

Attributes that relate to ARRAYS

• EXAMPLE:

  • signal mydt : bit_vector (31 downto 0);
  • signal myto : bit_vector ( 0 to 15);

• Then the mydt myto

‘LEFT | | | ‘RIGHT | | | ‘HIGH | | | ‘LOW | | | ‘RANGE | | | ‘REVERSE_RANGE | | | ‘LENGTH | | |