Hi, I want to print for every row, from row 2 like this: based on the corresponding values in their rows
PAZ valid commands are => MLL, LOC
MLL valid commands are => MLL, LLP
LOC valid commands are => MLL, LOC
LLP valid commands are => MLL, LOC, LLP
Error:
n = $sscanf(fd,“%[^,],%[^,],%[^,],%[^]”,col[0],col[1],col[2],col[3]);
|
xmsim: *E,SYSFMT (./testbench.sv,38|25): $sscanf – Invalid format specifier ‘%[’.
module tb;
int fd; // Variable for file descriptor handle
string line;
struct {
string name;
logic[2:0] val;
} mode[5];
string col[4];
int i;
int n;
initial begin
fd = $fopen ("trial", "w");
for (int i = 0; i < 5; i++)
if(i==0)
$fdisplay (fd, "PAZ,MLL,LOC,LLP", i);
else if(i==1)
$fdisplay(fd,"PAZ,1,1,0",i);
else if(i==2)
$fdisplay(fd,"MLL,1,0,1",i);
else if(i==3)
$fdisplay(fd,"LOC,1,1,0",i);
else if(i==4)
$fdisplay(fd,"LLP,1,1,1",i);
$fclose(fd);
fd = $fopen ("trial", "r");
while(!$feof(fd)) begin
while($fgets(line,fd)) begin
$display("Data =%s",line);
if(i==0)
n = $fscanf(fd,"%d,%[^,],%[^,],%[^,],%[^]",col[0],col[1],col[2],col[3]);
else
n = $fscanf(fd,"%[^,],%[^,],%[^,],%[^]",mode[i].name,mode[i].val[2],mode[i].val[1],mode[i].val[0]);
i=i+1;
end
end
$fclose(fd);
end
endmodule