Hi.
I have the following as a reference input line:
“HEADER | DESC_part1 DESC_part2 … DESC_partN | WORD 10”
And I want to extract two elements:
- a concatenated version of the DESC to a single string e.g. desc_STR = “DESC_part1 DESC_part2 … DESC_partN”
- The decimal value after “WORD”
As long as the DESC does not include whitesapces, the following code does the work:
initial begin
integer status;
string status_STR;
string desc;
integer val;
string val_STR;
status = $sscanf(inputSTR,"HEADER | %s | WORD %d",desc,val);
val_STR.itoa(addr);
if (status == 2) begin
$display("SUCCESS");
$display({"desc is : ", desc});
$display({"addr is : ", addr_STR});
end
else begin
$display("FAILURE");
end
end
When the DESC consists of multiple whitespace separated strings:
status = 1
desc = DESC_part1
val = ?
When I try to exclude characters in the format specifier i.e. “[^|]”, I get the following error:
**
An invalid input format specifier ‘%{’ is passed as part of the second argument
**
What am I missing? Is character excluding forbidden in verilog?
Thanks.
Itay.