verilog-problem write text file

Status
Not open for further replies.

jalal.baba

Junior Member level 1
Joined
Feb 5, 2018
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
118
Hi
I have three member out_x ,out_y,out_z and I want to write them in text file as shown below:
Code:
out_x[0]    out_y[0]       out_z[0]
out_x[1]    out_y[1]       out_z[1]
out_x[2]    out_y[2]       out_z[2]
.                  .                   .
.                  .                   .
.                  .                   .
.                  .                   .
out_x[n]     out_y[n]       out_z[n]
I wrote code:
Code:
`define Lenght_v 22
integer file,stat,i,j,m,n,k,out;
integer file_v,stat_v;
real out_x[0:`Lenght_v-1];
real out_y[0:`Lenght_v-1];
real out_z[0:`Lenght_v-1];
output reg clk;
always@(posedge clk)
	begin 
		out=$fopen("out.txt","w");
		for(k=0;k<`Lenght_v;k=k+1)
			begin
				$fwrite (out,"a=%f\n b=%f\n c=%f\n",out_x[k],out_y[k],out_z[k]); 
				
			end 
			$fflush(out);
	end

and my result is:
Code:
out_x[0]
out_y[0]
out_z[0]
out_x[1]
out_y[1]
out_z[1]
.
.
.
How can I achieve the desired results?
thanks
 
Last edited by a moderator:

Code:
$fwrite (out,"a=%f     b=%f     c=%f\n",out_x[k],out_y[k],out_z[k]);
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…