how the file handling is being used in verilog ?

Status
Not open for further replies.

Muthuraja.M

Advanced Member level 4
Joined
Jul 20, 2013
Messages
101
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Visit site
Activity points
634
Hi friends,

How to use file handling in verilog ?

I want to read the text file which contains my image values by using verilog.

Pls give me suggestions. reply me with an example...

Thanks in advance....
 

Use google "verilog file io" will give you lots of results and examples
 

i want to and 2 variables and the result is stored in one txt file this s my code.

I cant get the output in my output txt file.

pls correct my code..

module main(c);
output [7:0]c;
an a1(c);
file f1(c);
endmodule



module file(a);
inout [7:0]a;
integer fd;
initial
begin
fd=$fopen("outfile1.txt");
$fdisplay(fd,"Result is : %b",a);
$fclose(fd);
end
endmodule



module an(d);
parameter a=8'b00011100;
parameter b=8'b00011100;
output [7:0]d;
assign d=a&b;
endmodule
 

Did you simulate the code or just compiled?
It worked for me. If it is simulator specific issue, add timing delay before $fdisplay. Like "#10 $fdisplay..."

Difficult to understand the purpose of the code.
Prefer to do file I/O in the top module.
 

i simulate that code but in the txt file it stored as xxxxxxxx. so only i am asking wat is the problem in
my code ...

And i want to know how the array of values are stored in text file...

pls explain me ....
 

no Fvm it should be still xxxxxxxx

- - - Updated - - -

i find fvm i use initial so it has the value in the starting of the simulation i use delay as vardan said or i use always instead of using initial block....


Thanks to both fvm and vardan.....
 

hi anyone i need to know how the program is dumped in spartan 3e kit...

i am using xc3s500e device and package is PQ208..

pls send me how to dump the code using xilinx ... i finished upto project creation and check the syntax after that i dont know how to proceed pls help me i am in a hurry....
 

i want to and 2 variables and the result is stored in one txt file this s my code.

module file(a);
inout [7:0]a;
integer fd;
initial
begin
fd=$fopen("outfile1.txt");
$fdisplay(fd,"Result is : %b",a);
$fclose(fd);
end
endmodule

You have the $fopen and the $fdisplay in the initial block. The initial block will run at time 0 so you'll only have X's assigned to a. The $fdisplay (and the $fclose) shouldn't be in the initial block unless you add something to trigger the $fdisplay like some wait statement that looks for something to decide when to do the file write.
 

yeah rite thank u i understand and i rectify my error in my code.

i have another doubt is primitives are used inside always or initial block ?

pls give me suggestions....
 

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