sandy
sandy

Reputation: 191

Reading a cell from xlsx and comparing

I am trying to work with xlsx for the first time using perl. Even though the cell contains 1'b1 or 1'b0, the else condition is executed always. Please help me out.

#!/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             = $column[1];
print FH_F "$OEN_SIGNAL";
if($OEN_SIGNAL eq "1'b1")    {          print FH_F "A"; }
elsif($OEN_SIGNAL eq "1'b0") {          print FH_F "B"; }
else                         {          print FH_F "C"; }
}
}
}

Actual output

$OEN_SIGNAL-operation

1'b1-A

1'b0-B

sda_oen-C

Upvotes: 1

Views: 72

Answers (1)

sandy
sandy

Reputation: 191

Sorry, It was a small mistake. After correcting 1b'1 to 1'b1 the actual output is correct now. I have corrected the code and the output. My issue was solved. I don't whether to mark the question as fixed. So leaving as it is.

Upvotes: 1

Related Questions