How to Use Report Statement in VHDL for Debugging
In VHDL, use the
report statement to display messages during simulation for debugging or status updates. The syntax is report <message> severity <level>; where severity can be note, warning, error, or failure. This helps you track signal values or program flow while simulating your design.Syntax
The report statement syntax in VHDL is:
report <message> severity <level>;
Here:
<message>is a string to display.severityis optional and can benote,warning,error, orfailure.- If
severityis omitted, it defaults tonote.
This statement prints the message during simulation and helps identify issues or track progress.
vhdl
report "This is a message" severity warning;Example
This example shows how to use report inside a process to print a message when a signal changes.
vhdl
library ieee;
use ieee.std_logic_1164.all;
entity report_example is
port(
clk : in std_logic;
reset : in std_logic;
signal_in : in std_logic
);
end entity report_example;
architecture behavior of report_example is
begin
process(clk)
begin
if rising_edge(clk) then
if reset = '1' then
report "Reset is active" severity note;
else
if signal_in = '1' then
report "Signal is high" severity warning;
else
report "Signal is low" severity note;
end if;
end if;
end if;
end process;
end architecture behavior;Output
During simulation, messages like:
"Note: Reset is active"
"Warning: Signal is high"
"Note: Signal is low"
will appear in the simulator console depending on signal values.
Common Pitfalls
Common mistakes when using report include:
- Omitting the
severitykeyword and expecting an error (it's optional and defaults tonote). - Using
reportoutside a process or architecture body (it must be inside a process, procedure, or architecture). - Expecting
reportto stop simulation (onlyfailureseverity can stop simulation). - Using complex expressions directly in the message without converting to string.
Example of wrong and right usage:
vhdl
process
begin
-- Wrong: missing severity but with semicolon is okay
report "Message without severity";
-- Wrong: report outside process (illegal)
-- report "Outside process" severity error;
-- Right:
report "Proper message" severity note;
wait;
end process;Quick Reference
| Keyword | Description |
|---|---|
| report | Starts the message statement |
| "message" | Text string to display |
| severity | Optional keyword to specify message level |
| note | Informational message (default) |
| warning | Indicates a warning condition |
| error | Indicates an error, simulation continues |
| failure | Indicates a failure, simulation stops |
Key Takeaways
Use the report statement to print messages during simulation for debugging.
Severity levels control the importance and effect of the message.
Report statements must be inside processes or architectures.
Omitting severity defaults to note, which does not stop simulation.
Use report to track signal changes or important events in your design.