我必须读取一个字符串并从stim.txt文件中显示它。我可以读取所有其他字段但不能读取f_string。如果您可以建议我如何成功显示f_string。我真的很感激
stim.txt File extract
0 000aaa 0b0b0b0b " I am here "
我正在使用
initial
begin
string f_string;
fd = $fopen("stim.txt", "r");
p=$fgets(line,fd);
n_items = $sscanf(line, "%h %h %h %s", cmd, addr, data, f_string);
$display("%h %h %h %s", cmd, addr, data,f_string);
非常感谢
答案 0 :(得分:0)
您的问题是您需要从文件中读取引号以及字符串。您需要明确地阅读这些内容,例如:
n_items = $sscanf(line, "%h %h %h %c %s", cmd, addr, data, DUMMY, f_string);
其中%c
读取单个字符,DUMMY是8位向量。