Tag Archives: Transcript Files

Testbench Transcripting

TranscriptPkg allows different parts of a testbench to print to a common transcript file.

TranscriptPkg provides an internal file identifier (TranscriptFile), subprograms for opening (TranscriptOpen) files, closing (TranscriptClose) files, printing (print and writeline), and checking if the file is open (IsTranscriptOpen).

Print prints a string to TranscriptFile when it is open, otherwise, it prints to std.textio.OUTPUT. Writeline does the same thing for an object of type line.

Below is a short program that references the TranscriptPkg, opens a transcript file, and prints using both print and writeline.

use osvvm.TranscriptPkg.all ; 
architecture Test1 of tb is

  process
  begin
    -- Open TranscriptFile
    TranscriptOpen("./results/Transcript_t1_nominal.txt") ;  

    -- Print a string value
    Print("Print 1") ; 

    -- Use textio plus WriteLine
    swrite(buf, "Write 1") ;
    writeline(buf) ; 

    -- Close TranscriptFile
    TranscriptClose ;

    -- Print only when the transcript file is open
    if IsTranscriptOpen then 
      swrite(buf, "Write 1 - transcript open") ;
      writeline(buf) ; 
    end if;

Print works well with VHDL-2008, to_string.

Print("Received value: " & to_string(IntVal) & " at " & to_string(NOW)) ;

TranscriptPkg also supports a mirror mode in which Print and WriteLine write to both TranscriptFile and std.textio.OUTPUT. Enable mirroring using SetTranscriptMirror.

SetTranscriptMirror(TRUE) ;

For more details on TranscriptPkg, see TranscriptPkg_User_Guide.pkg.