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.

fwrite in verilog....

Status
Not open for further replies.

lakshminarayanan

Newbie level 5
Joined
Sep 11, 2006
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,339
verilog fwrite

while using the fwrite in verilog....... as mentioned below....
$fwrite(file,"a=%d @=%d",a,addr);
if the value of a is negative i am getting the data in the file as.........for eg....-1 as 65535 but i need to print it as -1 in the file do any one know other format of writting the data so i colud write negative values as -1 in my file.....
 

fwrite verilog

lakshminarayanan said:
while using the fwrite in verilog....... as mentioned below....
$fwrite(file,"a=%d @=%d",a,addr);
if the value of a is negative i am getting the data in the file as.........for eg....-1 as 65535 but i need to print it as -1 in the file do any one know other format of writting the data so i colud write negative values as -1 in my file.....

Using %d should print -1, for example the following code works fine in VCS:

Code:
module fwrite();

  initial begin : b1
    integer file;
    file = $fopen ("a.txt", "w");
    $fwrite (file, "MIN_1 is %d PLUS_1 is %d ", -1, 1);
   $finish;
  end

endmodule

Output is:

Code:
  MIN_1 is          -1 PLUS_1 is           1

HTH
Ajeetha, CVC
www.noveldv.com[/code]
 
$fwrite verilog

Checkout this!

Code:
module test;
   integer file;
   reg signed [15:0] a, addr;
   
initial begin
   a = -1;
   addr = 100;
   file = $fopen("test");
   $fwrite(file,"a=%d @=%d",a,addr); 
end
endmodule // test
 
verilog $fwrite

i think if you have declared the variable 'a' as register data type, there is a possibility that it might not show the negative value since it might be unsigned by default. Plz check the fwrite statement with 'a' declared as an integer and see if the same problem occurs.

Also, please provide a feedback on this.
 

fwrite in verilog

The problem is fixed by the suggestion given by nand_gates........i am using the modelsim simulator in win xp ................
 

When I try the code above and simulate using Isim, the output has only one character, instead of "MIN_1 is -1 PLUS_1 is 1", the output is just M. Anyone could tell me how to solve it? Is it because I did the wrong simulation?
Thanks
 

What's the difference between $fwrite and $fdisplay?
 

What's the difference between $fwrite and $fdisplay?

just copy paste it from "verilog golden reference guide"

"The only difference between $display and $write, is that $display writes out a
newline character at the end of the text, whereas $write does not."
 

Thanks! Short and clear :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top