Ricerca…
introduzione
Qualsiasi linguaggio di programmazione decente supporta i commenti. In VHDL sono particolarmente importanti perché la comprensione di un codice VHDL, anche moderatamente sofisticato, è spesso difficile.
Commenti a riga singola
Un commento a riga singola inizia con due trattini ( --
) e si estende fino alla fine della riga. Esempio :
-- 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;
Commenti delimitati
A partire da VHDL 2008, un commento può anche estendersi su più righe. I commenti su più righe iniziano con /*
e terminano con */
. Esempio :
/* 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;
I commenti delimitati possono essere utilizzati anche su meno di una riga:
-- 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;
Commenti nidificati
L'avvio di un nuovo commento (riga singola o delimitato) all'interno di un commento (riga singola o delimitato) non ha alcun effetto e viene ignorato. Esempi:
-- 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
Autorizzato sotto CC BY-SA 3.0
Non affiliato con Stack Overflow