gentex: made bitvalues clearer
authorMartin Perner <martin@perner.cc>
Tue, 26 Oct 2010 17:25:02 +0000 (19:25 +0200)
committerMartin Perner <martin@perner.cc>
Tue, 26 Oct 2010 21:10:35 +0000 (23:10 +0200)
don't write a bunch of X's for don't care bitvalues. instead we group
the X's like the names of the fields are grouped.

was a wish of markus

2_isa/gentex.pl

index b2751c84d51c257fce8d3cbca1f31273d93a8e35..373d576f0ff7aa64d1ab57352956a9d0bef831a2 100755 (executable)
@@ -48,29 +48,22 @@ sub ins {
 
                if($fieldn =~ m/^[^\(.]*\(\s*([0-1]+)\s*\).*$/) {
                        if(length($1) == $fields[$count]) {
-                               push(@bitlist,$1);
+                               push(@bitlist,'S'.$1);
                                $fieldn =~  s/\s?\(\s*[0-1]+\s*\)//;
                                $pvline = 1;
                        }
                        else {
-                               $x = '';
-                               for($i = 1; $i <= $fields[$count]; $i++) {
-                                       $x .= 'X';
-                               }
-                       push(@bitlist,$x);
+                               $x = 'LX';
+                               push(@bitlist,$x);
                        }
                }
                else {
-                       $x = '';
-                       for($i = 1; $i <= $fields[$count]; $i++) {
-                               $x .= 'X';
-                       }
+                       $x = 'LX';
                        push(@bitlist,$x);
                }
                #$tabular .= $fieldn.": ". $bits." \\\\";
                $count++;
        }
-       my $bitlist = join("",@bitlist);
 
        #$tabular .= "\\textbf{names:} @fieldnames \n";
        #$tabular .= "\\textbf{bitlist:} $bitlist \n";
@@ -93,30 +86,36 @@ sub ins {
                        $bline .= "\\\\ \\hline \n";
                }
 
-               #build bitvalue
-               $vline .= substr($bitlist,($bits-1)-$i,1);
-               if($i != 0) {
-                       $vline .= " & ";
-               }
-               else {
-                       $vline .= "\\\\ \\hline \n";
-               }
-
-               #build nameline
+               #build nameline and bitvalue
                #because of multicolumn we need to limit execution
                if($i == $count) {
                        $nline .= "\\multicolumn{@fields[0]}{>{\\columncolor{names}}c|}{@fieldnames[0]}";
 
+                       if(substr(@bitlist[0],0,1) eq "L") {
+                               $vline .= "\\multicolumn{@fields[0]}{>{\\columncolor{bitval}}c|}{".substr(@bitlist[0],1)."}";
+                       }
+                       else {
+                               for(my $j = 1; $j <= @fields[0]; $j++) {
+                                       $vline .= substr(@bitlist[0],$j,1);
+                                       if($j != @fields[0]) {
+                                               $vline .= " & ";
+                                       }
+                               }
+                       }
+
                        #update count
                        $count -= @fields[0];
 
                        if($count < 0) {
                                $nline .= "\\\\ \\hline \n";
+                               $vline .= "\\\\ \\hline \n";
                        }
                        else {
                                $nline .= " & ";
+                               $vline .= " & ";
                        }
 
+                       shift(@bitlist);
                        shift(@fieldnames);
                        shift(@fields);
                }