how to read a text file in verilog, in which the text has signed floating values?

Status
Not open for further replies.

bhalke.santosh

Newbie level 3
Joined
May 23, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,305
I've written a matlab code to generate sinewave to that I added noise and then that signal then I converted into text file.
This textfile has decimal floating values. I want to read this file in verilog testbench and get input from that file. and again backto write in another text file the output.
can anybody help me in this?
 

Assuming the file in like :

.1
.12
.15
.2
.26
.3

and so on

write code like this

integer in,i,out;
real data;

initial begin
in = $fopen("input.txt,"rb");
out = $fopen("output","w");

if(!in) $display("File Open Error!");
if(!out) $display("File Open Error!");

i = $fscanf(in,"%f",data);
i = $fwritef(in,"%f",data);
$fclose(in);
$fclose(out);
end

----------------------------------------
check this page
http://www.asic.co.in/Index_files/verilog_files/File_IO.htm
Paragraph "READ FORMATTED TEXT"
 

thanks for ur reply its helpfull...
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…