Recherche…


Introduction

Tout langage de programmation décent prend en charge les commentaires. Dans VHDL, ils sont particulièrement importants car la compréhension d’un code VHDL, même modérément sophistiqué, est souvent difficile.

Commentaires sur une seule ligne

Un commentaire sur une seule ligne commence par deux tirets ( -- ) et s’étend jusqu’à la fin de la ligne. Exemple :

-- This process models the state register
process(clock, aresetn)
begin
  if aresetn = '0' then         -- Active low, asynchronous reset
    state <= IDLE;
  elsif rising_edge(clock) then -- Synchronized on the rising edge of the clock
    state <= next_state;
  end if;
end process;

Commentaires délimités

À partir de VHDL 2008, un commentaire peut également s'étendre sur plusieurs lignes. Les commentaires sur plusieurs lignes commencent par /* et se terminent par */ . Exemple :

/* This process models the state register.
   It has an active low, asynchronous reset
   and is synchronized on the rising edge
   of the clock. */
process(clock, aresetn)
begin
  if aresetn = '0' then
    state <= IDLE;
  elsif rising_edge(clock) then
    state <= next_state;
  end if;
end process;

Les commentaires délimités peuvent également être utilisés sur moins d'une ligne:

-- Finally, we decided to skip the reset...
process(clock/*, aresetn*/)
begin
  /*if aresetn = '0' then
    state <= IDLE;
  els*/if rising_edge(clock) then
    state <= next_state;
  end if;
end process;

Commentaires imbriqués

Lancer un nouveau commentaire (simple ligne ou délimité) dans un commentaire (simple ligne ou délimité) n'a aucun effet et est ignoré. Exemples:

-- This is a single-line comment. This second -- has no special meaning.

-- This is a single-line comment. This /* has no special meaning.

/* This is not a
single-line comment.
And this -- has no
special meaning. */

/* This is not a
single-line comment.
And this second /* has no
special meaning. */


Modified text is an extract of the original Stack Overflow Documentation
Sous licence CC BY-SA 3.0
Non affilié à Stack Overflow