systemverilog中科学记数法转换为实数

Conversion of scientific notation into real in systemverilog

我有一个具有以下形式的字符串

str = "1e-06"

字符串的内容是一个数字,用科学计数法表示。我想以实际格式获取字符串的内容,以便在我的 systemverilog 代码的下一个块中使用。谁能帮我找到解决办法?

示例:

string str = "1e-06";
real number;
number = str.atoreal();
$display("%f", number);

在这段代码的输出中,我期待 1e-06 但我得到了 1

使用 %e 而不是 %f。这就是展示完整示例非常重要的原因。

这里有一个完整的例子

module top;
string str = "1e-06";
real number;
initial begin 
  number = str.atoreal();
  $display("%e", number); // %f displays a fixed point number, you want %e or %g
  end
endmodule