Monday, August 12, 2013

Print to STDOUT using REPORT Statement in VHDL


REPORT Statement  Usage :-


Report statement is used for printing debug messages to STDOUT (Best way for logging messages is to use textio package. It has print to STDOUT or FILE option ).

Note on T'Image(x) attribute :-
a textual representation of the value x of type T is returned.
usage :  T'Image(x)
Eg. integer'image(A)
return type : string

(A) To print integer value to STDOUT using REPORT :-
        variable A : integer :=10;
        report "A value is" & integer'image(A);
        output  >  A value is 10
(B) To print std_logic type values to STDOUT using REPORT :-
        variable B : std_logic := '1';
        report "B value is" & std_logic'image(B);
        output > B value is 1
(C) To print std_logic_vector type values to STDOUT using REPORT :-
       '&' operator is used for concatenation.
       variable vectB : std_logic_vector(3 downto 0) := "1000";
       for i in 0 to vectB'LENGTH loop
            report "vectB("&integer'image(i)&") value is" &   
                  std_logic'image(vectB(i));
       end loop;
        output >   vectB(0) value is 0
                       vectB(1) value is 0
                       vectB(2) value is 0
                       vectB(3) value is 1

5 comments:

  1. For the Vector it should be: LENGTH-1

    ReplyDelete
    Replies
    1. This is 3 years too late, but you are correct. There needs to be a minus 1.

      for i in 0 to rs'LENGTH - 1 loop
      report "rs("&integer'image(i)&") value is" & std_logic'image(rs(i));
      end loop;

      Delete
  2. Please tell me how to save vhdl output waveform results to console window

    ReplyDelete
  3. I want.. How vhdl output is saved to a text file.. Please

    ReplyDelete
  4. For std_logic_vector, to_hstring also works.
    For example, report "something =" & to_hstring(vector_signal);

    ReplyDelete