+ Post New Thread
Results 1 to 10 of 10
  1. #1
    Full Member level 4
    Points: 1,951, Level: 10

    Join Date
    Jul 2014
    Posts
    223
    Helped
    14 / 14
    Points
    1,951
    Level
    10

    compare two text files using verilog..........

    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

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 52,361, Level: 55

    Join Date
    Apr 2011
    Location
    Minneapolis, Minnesota, USA
    Posts
    12,835
    Helped
    2557 / 2557
    Points
    52,361
    Level
    55

    Re: compare two text files using verilog..........

    Did you rule out ordinary file-comparison utilities?

    Example, for Macintosh I use Text Wrangler.



  3. #3
    Super Moderator
    Points: 31,177, Level: 43
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    7,189
    Helped
    1706 / 1706
    Points
    31,177
    Level
    43

    Re: compare two text files using verilog..........

    Quote Originally Posted by dipin View Post
    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
    http://www.sutherland-hdl.com/online..._ref_guide.pdf
    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/1...ine-in-verilog


    1 members found this post helpful.

  4. #4
    Advanced Member level 5
    Points: 14,946, Level: 29
    mrflibble's Avatar
    Join Date
    Apr 2010
    Posts
    2,724
    Helped
    687 / 683
    Points
    14,946
    Level
    29

    Re: compare two text files using verilog..........

    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.



    •   AltAdvertisement

        
       

  5. #5
    Newbie level 6
    Points: 75, Level: 1

    Join Date
    Oct 2014
    Posts
    12
    Helped
    2 / 2
    Points
    75
    Level
    1

    Re: compare two text files using verilog..........

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



  6. #6
    Advanced Member level 5
    Points: 14,946, Level: 29
    mrflibble's Avatar
    Join Date
    Apr 2010
    Posts
    2,724
    Helped
    687 / 683
    Points
    14,946
    Level
    29

    Re: compare two text files using verilog..........

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



  7. #7
    Full Member level 4
    Points: 1,951, Level: 10

    Join Date
    Jul 2014
    Posts
    223
    Helped
    14 / 14
    Points
    1,951
    Level
    10

    Re: compare two text files using verilog..........

    Hi
    Quote Originally Posted by mrflibble View Post
    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


    1 members found this post helpful.

  8. #8
    Advanced Member level 5
    Points: 14,946, Level: 29
    mrflibble's Avatar
    Join Date
    Apr 2010
    Posts
    2,724
    Helped
    687 / 683
    Points
    14,946
    Level
    29

    Re: compare two text files using verilog..........

    Always interesting to hear what creative ways people use to do certain jobs. Thanks. :)


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  9. #9
    Full Member level 2
    Points: 1,323, Level: 8
    verylsi's Avatar
    Join Date
    Mar 2012
    Posts
    123
    Helped
    16 / 16
    Points
    1,323
    Level
    8

    Re: compare two text files using verilog..........

    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



  10. #10
    Full Member level 4
    Points: 1,951, Level: 10

    Join Date
    Jul 2014
    Posts
    223
    Helped
    14 / 14
    Points
    1,951
    Level
    10

    Re: compare two text files using verilog..........

    hi verylsi,
    Quote Originally Posted by verylsi View Post
    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


    1 members found this post helpful.

--[[ ]]--