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.

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
Newbie level 3
Joined
May 23, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
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"
 
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top