Handling write and read file verilog

Functions used for writing and reading from file in verilog.

  • fopen
  • fclose
  • fscanf  – read from file as per format
  • fwrite – write to file as per format
  • fdisplay -write to file

Above Function are similar to C programming file handling. Difference of fwrite and fdisplay is that fwrite does not insert newline after each statement display while fdisplay does insert newline.

To write and read memory , new system functions are provided are

  • writememh
  • readmemh

These functions used to load/dump memory directly. Below is example.

reg [99:0] memory [0:1000]

writememh (“file_name”,memory);

File should have number of lines equals to depth of memory and each line should have bits equal to depth of memory.

Please provide comments to improve blog.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s