K
Kenneth Brun Nielsen
Guest
Hi all,
I have two questions related to the $sscanf function.
First, I read input stimuli (among others) from a file. If 5 bit
values are read, I should do one thing, and if only 4 bit values are
read, something else should be done. E.g.
while (!$feof(fd))
begin
r = $fgets(textline,fd);
if ($sscanf(textline, "%1b %1b %1b %1b %1b
\n",SSread,SCKread,MOSIread,DIread,DINread) > 0)
begin
$display("FULL VECTOR READ");
end
else if ($sscanf(textline, "%1b %1b %1b %1b
\n",SSread,SCKread,MOSIread,DI1read) > 0)
begin
$display("HALF VECTOR READ");
end
else if ($sscanf(textline, "%s\n",subtext) > 0)
begin
$display("LINE NOT RECOGNIZED");
end
end
The problem is, that both input lines consisting of four and five bit
values seems to satisfy the first 'if' conditional. The same thing
happends, if I switch them around.
Any suggestions to how I can differentiate between four and five input
values?
Best regards,
Kenneth
I have two questions related to the $sscanf function.
First, I read input stimuli (among others) from a file. If 5 bit
values are read, I should do one thing, and if only 4 bit values are
read, something else should be done. E.g.
while (!$feof(fd))
begin
r = $fgets(textline,fd);
if ($sscanf(textline, "%1b %1b %1b %1b %1b
\n",SSread,SCKread,MOSIread,DIread,DINread) > 0)
begin
$display("FULL VECTOR READ");
end
else if ($sscanf(textline, "%1b %1b %1b %1b
\n",SSread,SCKread,MOSIread,DI1read) > 0)
begin
$display("HALF VECTOR READ");
end
else if ($sscanf(textline, "%s\n",subtext) > 0)
begin
$display("LINE NOT RECOGNIZED");
end
end
The problem is, that both input lines consisting of four and five bit
values seems to satisfy the first 'if' conditional. The same thing
happends, if I switch them around.
Any suggestions to how I can differentiate between four and five input
values?
Best regards,
Kenneth