Electronics > FPGA

VCD to CSV Conversion

(1/1)

ali_asadzadeh:
Hi,
I have written some test benches that would read csv files and apply signals to DUT, Now I have a VCD file, I want to know is there a tool or utility to convert it to a csv file?

My sample file is attached for reference.

BrianHG:
It's a simple ASCII file.  You can write your own VCD file reader directly in your verilog testbench.

ali_asadzadeh:
It's way more complicated than a csv file, I have written something like this for my csv file



--- Code: ---
reg r_i_clk  [0:65536];
reg r_G_MISO [0:65536];
reg r_G_SCK  [0:65536];
reg r_G_MOSI [0:65536];
reg r_G_SS   [0:65536];

integer file;
string line;
integer lineNumber = 0,timeunitCsv,rePlayLineNumber = 0;
//file operation
initial
    begin
////////////// Read the input file and fill the input array
file=$fopen("STM32SlaveSPI/SPIwrite25_core0_window0.csv","r");
if(file)
$display("File opened succesfuly %d",file);
else
$display("Can not open the file %d",file);

//if we have valid file read it for me!
if(file) begin
//Read the top 3 lines of the file, becuase they are string info and we do not need them
$fgets(line,file);
$display("%s",line);

$fgets(line,file);
$display("%s",line);

$fgets(line,file);
$display("%s",line);

//now read the content of the whole file
while(!$feof(file)) begin
$fgets(line,file);
$sscanf(line,"%d, %b, %b, %b, %b, %b",timeunitCsv,r_i_clk[lineNumber],r_G_MISO[lineNumber],r_G_SCK[lineNumber],r_G_MOSI[lineNumber],r_G_SS[lineNumber]);

/*$display("linenumber %d",lineNumber);
$display("time unit: %d us",timeunitCsv);
$display("ick %b",r_i_clk[lineNumber]);
$display("miso %d",r_G_MISO[lineNumber]);
$display("sck %d",r_G_SCK[lineNumber]);
$display("mosi %d",r_G_MOSI[lineNumber]);
$display("ss %d",r_G_SS[lineNumber]);*/

lineNumber++;
end

$fclose(file);
end


end

--- End code ---

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version