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.

[SOLVED] compare two text files using verilog..........

Status
Not open for further replies.

dipin

Full Member level 4
Full Member level 4
Joined
Jul 16, 2014
Messages
223
Helped
14
Reputation
28
Reaction score
14
Trophy points
18
Visit site
Activity points
1,731
hi

is there any way two compare two text files using verilog???

actually i need to compare expected output stored in a text file with the output of my program.is there any way to do this directly like c program.

did anyone have some documents or sample code..please help.
(this is for simulation purpose only)

thanks and regards
 

is there any way two compare two text files using verilog???
actually i need to compare expected output stored in a text file with the output of my program.is there any way to do this directly like c program.
Use fileIO system tasks to read the "golden" file and compare word for word data from the UUT. This type of self checking testbench code is pretty easy to write and there are a lot of examples of using the fileIO system tasks to read in files on various websites.

The first four google hits:
http://www.asic-world.com/verilog/verilog2k3.html

This one is a comparison of pre-2001 fileio package with Verilog 2001. http://www.chris.spear.net/pli/fileio.htm
http://stackoverflow.com/questions/16630319/how-to-read-a-text-file-line-by-line-in-verilog
 
  • Like
Reactions: dipin

    dipin

    Points: 2
    Helpful Answer Positive Rating
man diff

I'd use some external script to do the comparison. No need to reinvent the wheel in a poorly implemented fashion in verilog.
 

Is there a reason you are trying to compare it in verilog? Why not tkdiff or any other utility commands?
 

Since you marked this as solved ... what solution did you end up using? Always useful to know for future people with the same problem.
 

Hi
Since you marked this as solved ... what solution did you end up using? Always useful to know for future people with the same problem.

i have used $readmemb("input.txt",mem); to read the text file into a register and done the same to the other text file. then i compared the both registers . and finally used $fwrite to print the result into a another text file .
thanks for the help..
regards
 
Always interesting to hear what creative ways people use to do certain jobs. Thanks. :)
 
  • Like
Reactions: dipin

    dipin

    Points: 2
    Helpful Answer Positive Rating
Hi Dipin,

You did it in verilog for specific reason or you just wanted to explore it?
I always do the same in sw like Beyond compare, did you face any problem with that?

just asking for my future reference.
Thanks
 

hi verylsi,
Hi Dipin,

You did it in verilog for specific reason or you just wanted to explore it?
I always do the same in sw like Beyond compare, did you face any problem with that?

just asking for my future reference.
Thanks

actually i need to verify the output of a verilog program in which output writting into a text file. so i did this as a part of the testbench.
this comparison is a part of my program . so i done it in verilog itself

thanks and regards
 
  • Like
Reactions: verylsi

    verylsi

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top