UVM之sformat


Useful SystemVerilog System Tasks

Useful SystemVerilog System Tasks
Task Name Description
$sscanf(str,format,args);

$sscanf 將字符串按照某個模板格式進行掃描,其字符串格式和C語言中的printf()函數類似

$sformat(str,format,args);

$sformat是$sscanf的反函數。將字符串按照給定的格式填入相應的參數args中

$display(format,args);

$display就是Verilog的printf語句,在stdout上顯示格式化的字符串

$sformatf(format,args);

$sformatf任務和$sformat相似,除了其返回字符串結果。字符串作為$sformatf的返回值,而不是像$sformt一樣放在第一個參數上。

 

$sformat() update the string with value which you have passed to it.

1 string a;
2 $sformat(a," Hello world");

 

So here, "Hello world" will be stored in the string a. 
It is as good as a = "Hello world";

eg:  

1 $sformat(name,"slaves[%0d]",i);

 

 

SV的輸出格式: 

%d 以及 %D 以十進制格式輸出
%b 以及 %B 以二進制格式輸出
%o 以及 %O 以八進制格式輸出
%h 以及 %H 以十六進制格式輸出

%e 以及 %E 以指數表示方式輸出實數(real型)

%f 以及 %F 以十進制數表示方式輸出實數(real型)

%g 以及 %G 以十進制數或者以指數表示方式輸出實數

 

%s 以及 %S 以字符串格式輸出

%c 以及 %C 以ASCII碼格式輸出

 

%m 以及 %M 輸出層次名

%v 以及 %V 輸出線網類型變量的強度

%t 以及 %T 以當前時間格式輸出

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM