我有以下字符串:
str= "w, 0, A0002000, 00000000, \n"
我使用(模式声明为位,len表示为int' ax_trx表示为位[31:0]):
$sscanf(str, "%c", mode);
$sscanf(str, "%d", len);
$sscanf(str,"%h", ax_trx.addr)
由于某些原因,我得到的结果是: 模式是' 1' (我希望它是' w')。 len是00000000(我不确定它是否正常)。 ax_trx.addr是00000000(我预计它是A0002000)。
答案 0 :(得分:2)
你不能指望将信号声明为具有值的位' w',bit只能有0或1个值。
根据System Verilog规范(第21.3.4.3章):
If an argument is too small to hold the converted input, then, in general, the LSBs are transferred
答案 1 :(得分:0)
以下是一个示例:(单个字符为%c,字符串为%s,十进制为%d,十六进制为%h,请参阅格式here)
CREATE UNIQUE CLUSTERED INDEX IDX_vwGetVisit_VisitID
ON [vwGetVisit] (VisitID);
CREATE UNIQUE CLUSTERED INDEX IDX_vwLatestVisit_VisitID
ON [vwLastestVisitMovement] (VisitID);
产生:
module test;
initial begin
string str = "w, 10, A0002000, deadbeef, \n";
string mode = "";
int len = 0;
bit [31:0] address = 0;
int data = 0;
$display("mode (%s) len (%d) address (%h) data (%h)", mode, len, address, data);
$sscanf(str, "%c, %d, %h, %h,", mode, len, address, data);
$display("mode (%s) len (%d) address (%h) data (%h)", mode, len, address, data);
end
endmodule