Suche…
Einführung
Jede anständige Programmiersprache unterstützt Kommentare. In VHDL sind sie besonders wichtig, da das Verstehen eines VHDL-Codes, selbst wenn er nur mäßig komplex ist, häufig eine Herausforderung darstellt.
Einzeilige Kommentare
Ein einzeiliger Kommentar beginnt mit zwei Bindestrichen ( --
) und reicht bis zum Zeilenende. Beispiel:
-- 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;
Begrenzte Kommentare
Ab VHDL 2008 kann sich ein Kommentar auch auf mehrere Zeilen erstrecken. Mehrzeilige Kommentare beginnen mit /*
und enden mit */
. Beispiel:
/* 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;
Begrenzte Kommentare können auch für weniger als eine Zeile verwendet werden:
-- 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;
Verschachtelte Kommentare
Das Starten eines neuen Kommentars (einzeilig oder mit Trennzeichen) innerhalb eines Kommentars (einzeilig oder mit Trennzeichen) hat keine Auswirkungen und wird ignoriert. Beispiele:
-- 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
Lizenziert unter CC BY-SA 3.0
Nicht angeschlossen an Stack Overflow