-2

I need to write a 32 bit "reg" of a ".v" program in Modelsim in to a txt-type file. The variable is changing every CLK cycle and I need to store each value of it in decimal format. The program needs to write the each value just in one line.

M.Hallajian
  • 5
  • 1
  • 3
  • 2
    If I understand the question correctly you need to write values to a text file from a verilog test? Could you show what you have tried so far, thanks. – Morgan Mar 11 '15 at 11:44

1 Answers1

1

If the variable is named var and the name of your text file is "file.txt", You can use the following code to write on the file on each clock rising edge (the parameter "w" means that the file is opened for writing) :

integer fileH; // file handler

initial begin
    fileH = $fopen ("file.txt", "w");
end

always @(posedge clock)
    $fwrite (fileH, "value : %d \n", var);
Amir
  • 507
  • 3
  • 12