Поиск…


Вступление

Любой достойный язык программирования поддерживает комментарии. В VHDL они особенно важны, потому что понимание кода VHDL, даже умеренно сложного, часто бросает вызов.

Комментарии к одной строке

Однострочный комментарий начинается с двух дефисов ( -- ) и продолжается до конца строки. Пример :

-- 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;

Ограниченные комментарии

Начиная с VHDL 2008, комментарий может также распространяться на несколько строк. Многострочные комментарии начинаются с /* и заканчиваются на */ . Пример :

/* 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;

Обобщенные комментарии также могут использоваться на менее чем одной строке:

-- 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;

Вложенные комментарии

Запуск нового комментария (отдельной строки или разделителя) внутри комментария (отдельная строка или разделитель) не имеет эффекта и игнорируется. Примеры:

-- 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
Лицензировано согласно CC BY-SA 3.0
Не связан с Stack Overflow