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
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
 

ads-ee

Super Moderator
Staff member
Advanced Member level 7
Joined
Sep 10, 2013
Messages
7,941
Helped
1,822
Reputation
3,654
Reaction score
1,807
Trophy points
1,393
Location
USA
Activity points
60,176
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

mrflibble

Advanced Member level 5
Advanced Member level 5
Joined
Apr 19, 2010
Messages
2,720
Helped
679
Reputation
1,360
Reaction score
652
Trophy points
1,393
Activity points
19,551
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.
 

rancho_trojan

Newbie level 6
Newbie level 6
Joined
Oct 9, 2014
Messages
12
Helped
2
Reputation
4
Reaction score
2
Trophy points
3
Activity points
80
Is there a reason you are trying to compare it in verilog? Why not tkdiff or any other utility commands?
 

mrflibble

Advanced Member level 5
Advanced Member level 5
Joined
Apr 19, 2010
Messages
2,720
Helped
679
Reputation
1,360
Reaction score
652
Trophy points
1,393
Activity points
19,551
Since you marked this as solved ... what solution did you end up using? Always useful to know for future people with the same problem.
 

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
Activity points
1,731
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
 

mrflibble

Advanced Member level 5
Advanced Member level 5
Joined
Apr 19, 2010
Messages
2,720
Helped
679
Reputation
1,360
Reaction score
652
Trophy points
1,393
Activity points
19,551
Always interesting to hear what creative ways people use to do certain jobs. Thanks. :)
 
  • Like
Reactions: dipin

    dipin

    Points: 2
    Helpful Answer Positive Rating

verylsi

Full Member level 2
Full Member level 2
Joined
Mar 12, 2012
Messages
123
Helped
16
Reputation
32
Reaction score
16
Trophy points
1,308
Activity points
2,130
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
 

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
Activity points
1,731
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

Top