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.

Read the data from a text file in Verilog HDL

Status
Not open for further replies.

velu.plg

Member level 5
Member level 5
Joined
Jul 30, 2013
Messages
93
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
chennai
Visit site
Activity points
1,974
i am new to verilogHDL.
now i want to read the data from a text file.
here text file contain data in integer format.
how can i read that integer data...
 

sir,this is my code...

module readwrite1;
reg [0:3]reg1[7:0];
integer fp,status;

initial
begin
fp = $fopen ("img.txt","r");
status = $fread (reg1,fp);
end

endmodule


here, file "img.txt" contain integer
1
4
3
5

but our output is(reg1)

reg1(0) 0001
(1) 1010
(2) 0100
(3) 1010
(4) 0011
(5) 1010
(6) 0101
(7) xxxx

what is the reason for getting 1010 at reg1(1,3,5..) ???
how can i read that data in correct format ??
 

Because you print it as binary in the code that you don't show obviously.
 

thanks for your reply.
sir, then what change can i do for getting correct output in integer form??
 

thanks for your replay....
i post my doubt after searching net source because i did not clear with it ...
can u give syntax or simple program code regards my doubt...
 

thanks for your replay....
i post my doubt after searching net source because i did not clear with it ...
can u give syntax or simple program code regards my doubt...
See the last link I gave you. There are some $display examples that you can just about copy verbatim into your code. Some initiative of your own required.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top