UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
1,202 Views
Registered: ‎08-24-2015

Regarding File reading and writing in vivado simulation through Verilog RTL code

Jump to solution

Hi,

 

I'm reading a text (.txt) file hex data from directory using below command,

                a1=$fopen("test1.txt","r");

                a2=$fscanf(a1,"%h",reg1);

I'm writing a text (.txt) file to directory using below command,

                a1=$fopen("test1.txt","w");

                      $fdisplay(a1,"%h",reg2);

 

Here my question is how to read and write  RAW (.raw) files ...?

 

It's not working for 

                a1=$fopen("test1.raw","r");

                a2=$fscanf(a1,"%h",reg1);

 

So,  how to read and write  RAW (.raw) files ...? give me any suggestions.

0 Kudos
1 Solution

Accepted Solutions
Scholar richardhead
Scholar
1,608 Views
Registered: ‎08-01-2012

Re: Regarding File reading and writing in vivado simulation through Verilog RTL code

Jump to solution

you can open any file as binary instead of text. You need to open in binary mode:

 

a1 = $fopen("some_file", "rb"); //read mode, binary

 

$fread(some_variable, a1);

0 Kudos
3 Replies
Scholar richardhead
Scholar
1,609 Views
Registered: ‎08-01-2012

Re: Regarding File reading and writing in vivado simulation through Verilog RTL code

Jump to solution

you can open any file as binary instead of text. You need to open in binary mode:

 

a1 = $fopen("some_file", "rb"); //read mode, binary

 

$fread(some_variable, a1);

0 Kudos
1,157 Views
Registered: ‎08-24-2015

Re: Regarding File reading and writing in vivado simulation through Verilog RTL code

Jump to solution

Hi,

 

 

 

0 Kudos
Highlighted
1,118 Views
Registered: ‎08-24-2015

Re: Regarding File reading and writing in vivado simulation through Verilog RTL code

Jump to solution

Hi,

 

same i used for writing

reg [16:0]reg_data;

a1 = $fopen("some_file.raw", "wb"); //write mode, binary

 

$fwrite(reg_data, a1);

 

it's not working.

 

Please give your suggestion...

0 Kudos