Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Best way to Compare two files having mix of chars & digit in Questa Sim

Status
Not open for further replies.

GSB

Newbie level 3
Newbie level 3
Joined
Oct 7, 2014
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
16
Hi,

Is there way in system Verilog to compare line by line two files(its not know whether file will have strings or digit so no %s, %d )
Can I call $system in SV to do diff in Questa Sim or Is there any best way to do it like tcl command etc ?

Thanks,
GSB
 

You can use $fgets to read each file a line at a time into two strings, and then compare them. Do this in a loop until you hit the end of one of the files.

You can use the $system command to execute diff on Linux or FC on Windows, but getting a result back from windows to know if the compare succeeded will take some scripting.

Do you really need to do this while the simulation is running? You can execute these commands from the Tcl prompt.
 
  • Like
Reactions: GSB

    GSB

    Points: 2
    Helpful Answer Positive Rating
Re: Best way to Compare two files having mix of chars & digit in Questa Sim

Hi Dave_59,

Thanks for reply.
I have written below code with $fgets but I am getting simulation Error.

Code:
	    file_results = $fopen("xyz");
		if(!file_results)
                $display("File open operation failed");
	        else 
                $display("File open operation Sucessful %d",file_results);
               //	while(!$feof(file_results)) begin
                rtn =$fgets(line, file_results);
                $display("rtn %d:: %s",rtn, line);

File open operation Sucessful 2
# ** Error: (vsim-PLI-3084) $fgets : Argument 2 is not a valid file descriptor.
# rtn 0::

Could you tell me whats wrong with this.

Another Query : Could you please give some example to compare using system command while running simulation on windows and how we can get back results during simulation.

Thanks,
GSB

- - - Updated - - -

Please ignore the simulation error query,Actually I am able to resolve it by opening file in read mode.

Please answer my 2nd query regarding $system command
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top