我尝试使用perl首次使用xlsx。即使单元格包含1'b1或1'b0,else条件也会始终执行。请帮帮我。
#!/usr/bin/perl -w
use Spreadsheet::ParseXLSX;
use Spreadsheet::WriteExcel;
use Switch;
# Creates object (parser) of ParseXLSX
my $parser = Spreadsheet::ParseXLSX->new();
# call parse method thro parser object for parsing and parse it to excel variable
$excel = $parser->parse('PinMux_Spec.xlsx');
#$test_cond = "TEST.mbist_mode == 1'b0 && DIG_PINMUX.FC_pti_en == 1'b1";
$file_func = "pinmux_func.csv";
open (FH_F,">$file_func") || die "cannot open $file_func\n";
# looping thro all the sheets in .xlsx sheet
foreach $sheet (@{$excel -> {Worksheet}})
{
if(index ($sheet ->{Name},"FUNCTIONAL_MODE") !=-1 ) {
$sheetname = $sheet -> {Name};
# max row depth
$sheet -> {MaxRow} ||= $sheet -> {MinRow};
$i=0;
# Row iteration outer loop ex cell[0][0], cell[1][0]..
foreach $row ($sheet -> {MinRow} .. $sheet -> {MaxRow})
{
# max column depth
$sheet -> {MaxCol} ||= $sheet -> {MinCol};
$j=0;
# Column iteration inner loop ex. cell[0][0], cell[0][1]..
foreach $col ($sheet -> {MinCol} .. $sheet -> {MaxCol})
{
# read content of cells in each row and column
$cell = $sheet -> {Cells} [$row] [$col];
$column[$j] = $cell-> {Val};
$j++;
}
####### MAJOR CODE ########
$OEN_SIGNAL = chomp($column[1]);
print FH_F "$column[1]-$OEN_SIGNAL-";
if($column[1] eq "1'b1") { print FH_F "A"; }
elsif($column[1] eq "1'b0") { print FH_F "B"; }
else { print FH_F "C"; }
}
}
}
实际输出
$ column [1]-$ OEN_SIGNAL-operation
1'b1-0-C
1'b0-0-C
sda_oen-0-C
预期输出:
1'b1-1'b1-A
1'b0-1'b0-B
sda_oen-sda_oen-C
抱歉,这是一个小错误。将1b'1校正为1'b1之后,预期输出现在是正确的。我将更正代码。