systemverilog使用$fwrite系統函數打印信息到屏幕

       使用systemverilog(以下簡稱sv),除了使用$display系統函數,打印信息到屏幕上,還可以使用$fwrite系統函數,進行打印。

       $fwrite的函數的第一個參數,是文件描述符。後續參數與$display系統函數參數一致。

       在sv的標準中,有如下說明:

The file descriptor fd is a 32-bit packed array value. The MSB (bit 31) of a fd is reserved and shall always be set; this allows implementations of the file input and output functions to determine how the file was opened. The remaining bits hold a small number indicating what file is opened. Three file descriptors are pre-opened; they are STDIN, STDOUT, and STDERR, which have the values 32'h8000_0000, 32'h8000_0001, and 32'h8000_0002, respectively. STDIN is pre-opened for reading, and STDOUT and STDERR are pre-opened for append.

       從該說明中,可以得到

文件描述符

說明

0x8000_0000

STDIN:標準輸入

0x8000_0001

STDOUT:標準輸出

0x8000_0002

STDERR:標準錯誤輸出

       因此,只需要執行

$fwrite(0x80000002, “hello world”);

       就可以向屏幕打印hello world。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章