vvvvv said:Create array of bytes and write to it char codes
of ones = 31h
zeros = 30h
spaces=20h
echo47 said:Please describe more clearly what type variable you are trying to manipulate. Maybe show us your code example.
gliss said:Actually, it's not very clear what you want to do.
gliss said:I'm trying to understand. You are typing this in a text editor? You are writing a Verilog module and you are entering a literal string?
-or-
You are watching the results of a simulation and see "101010011" get printed to the console or output file, and instead want to see "1 0 1 0 1 0 1 1"?
There are possibilities here. What context is the binary number in?
mona_c said:the later one is correct !!! & i need to write..this form into the text file..taking output from a verilog code
reg [0:3] array;
integer log_pointer;
initial
log_pointer = $fopen("file_name");
$fdisplay (log_pointer,"data = %b\b%b\b%b\b%b", array[0],array[1],
array[2],array[3]);
end
vivek said:mona_c said:the later one is correct !!! & i need to write..this form into the text file..taking output from a verilog code
Hi
If u want to write this info into a file use $fdisplay. You should open a file for this like :
This will write your data to a file of the name you specify. log_pointer shall be the file pointer for the file you opened. It will increment automatically by one line for every $fdisplay.Code:reg [0:3] array; integer log_pointer; initial log_pointer = $fopen("file_name"); $fdisplay (log_pointer,"data = %b\b%b\b%b\b%b", array[0],array[1], array[2],array[3]); end
If you need more such info about verilog HDL you can refer the book "Verilog HDL: A Guide to Digital Design and Synthesis" by Samir Palnitkar. The ebook is available in this forum. Pretty good for beginning with verilog.
Hope this helps
Vivek
data = xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b
data = xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b
data = xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b
data = xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b
data = xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b
data = xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b
data = xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b
data = xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b xbxbxbx b
integer log_pointer, n;
initial begin
log_pointer = $fopen("file_name");
for (n=0; n<16; n=n+1)
$fdisplay (log_pointer,"data = %b %b %b %b", n[3], n[2], n[1], n[0]);
$fclose(log_pointer);
end
data = 0 0 0 0
data = 0 0 0 1
data = 0 0 1 0
data = 0 0 1 1
data = 0 1 0 0
data = 0 1 0 1
data = 0 1 1 0
data = 0 1 1 1
data = 1 0 0 0
data = 1 0 0 1
data = 1 0 1 0
data = 1 0 1 1
data = 1 1 0 0
data = 1 1 0 1
data = 1 1 1 0
data = 1 1 1 1
echo47 said:If that's approximately what you want, then how about changing the $fdisplay statement slightly?
integer log_pointer, n;
initial begin
log_pointer = $fopen("file_name");
for (n=0; n<16; n=n+1)
$fdisplay (log_pointer,"data = %b %b %b %b", n[3], n[2], n[1], n[0]);
$fclose(log_pointer);
end[/code]
Code:data = 0 0 0 0 data = 0 0 0 1 data = 0 0 1 0 data = 0 0 1 1 data = 0 1 0 0 data = 0 1 0 1 data = 0 1 1 0 data = 0 1 1 1 data = 1 0 0 0 data = 1 0 0 1 data = 1 0 1 0 data = 1 0 1 1 data = 1 1 0 0 data = 1 1 0 1 data = 1 1 1 0 data = 1 1 1 1
integer log_pointer;
wire [31:0] out;
initial begin
log_pointer = $fopen("format.txt");
$monitor($realtime,,"ps %d %h %h %h %d ",in,clk,oe,reset,out);
$fdisplay (log_pointer,"%b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b", out[31], out[30], out[29], out[28], out[27], out[26], out[25], out[24], out[23], out[22], out[21], out[20], out[19], out[18], out[17], out[16], out[15], out[14], out[13], out[12], out[11], out[10], out[9], out[8], out[7], out[6], out[5], out[4], out[3], out[2], out[1], out[0]);
$fclose(log_pointer);
$finish;
end
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?