AnsweredAssumed Answered

reading cadance layers into ads layout

Question asked by ILANB on May 26, 2008
Latest reply on Jun 2, 2008 by ILANB
I have created a small perl file that can take a cadence .map layer definition file and convert it to ads .lay format.

to use it run layerpp -i cadence_.map > newlayer.lay

code updated to ver 0.1 may 27, 2008

[code]
#! /usr/bin/perl


$ver= '$Id: layerpp.pl ver 0.1 IB $ ';
# changed current layer to first layer

=begin comment

   Copyright 2008 Ilan Barak, Raysat israel ltd.
   This program is free software: you can redistribute it and or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation version 3

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   a copy of the GNU General Public License is available at <http://www.gnu.org/licenses/>.

=end comment

=cut



require "getopts.pl";
&Getopts("hi");
(defined($opt_i)) ? ($interactive=1) : ($interactive=0) ;
if (defined($opt_h)) {
  print "$0 $ver\n";
  print "  -i interactive\n";
 
  print "  convert cadence .map file to agilent ads .lay file \n";
  die;
}

$counter=0;
# $other_layer_counter=0;
while (<>) {
   unless (/^\W*(;&#124;#&#124;$)/) {
     $line_save= $_;
     chop;
     $counter = $counter + 1 ;
     split /\s+/;
     $layer_name = @_[0];
     $layer_name =~ s/\+/plus/; # change the "+" and "-" signes to charecters
     $layer_name =~ s/\-/minus/;
     $line= $layer_name. "  number = " . @_[2] . " gds_num = " . @_[2] . " stream = -1  color = " . $counter . " fill = 18 line = 0, 2 0 1, \"\", type = 1, dxf = \"" . $layer_name . "\" trans = 0";
     $gds_type=$_[3] + 0;      # make this variable integer
     if ($gds_type == 0) {      # if layer tpe is 0 then put it in @deck
           push @deck,$line;
        }else{
            push @next_deck,$line_save; # otherwise, layer type <>0 save raw data in @next_deck
        }
}
}

# now process the layers that

for ($i=0;$i<@next_deck;$i++) {
     $_=$next_deck[$i];
     $counter = $counter + 1 ;
     split;
     $layer_name = @_[0]."_".substr @_[1],0,3;
     $layer_name =~ s/\+/plus/;
     $layer_name =~ s/\-/minus/;
     $line= $layer_name. "  number = " . $counter . " gds_num = " . @_[2] . " stream = -1  color = " . $counter . " fill = 18 line = 0, 2 0 1, \"\", type = 1, dxf = \"" . $layer_name . "\" trans = 0";
     push @deck,$line;
}

# now add layer 0 definition for ads
unshift ( @deck , "default number = 0 gds_num=255 iges = 1 color = 59 fill = 0 line = 0, 0 0 1, \"*\", type = 1, dxf =\"default\" trans = 0");
#now add cuurent layer definition
unshift ( @deck , "CurrentLayer number = 1 " );
&printdeck;


sub printdeck {
 for (@deck) {
#    print &wrapline(70,"","+","\n"," ",split(" ",$_));
     print $_ . "\n";
 }
}

######################### wrapline ###############

# wrapline( linelen, header, header2, trailer,
#           separator, list )
# where
#  linelen max number of chars per line   eg 70
#  header   is a string stuck on to the beginning
#  header2  is a string to add to the second and all subsequent lines,
#           {if they exist]
#  trailer is a string to tack on to the end of the structure
#  separator is put between multiple elements in the list (NOT last)
#  list    
# returns string

sub wrapline {
   local($maxlen, $header, $header2, $trailer,
         $separator, $linelen, @list, $output, $term, $last_term);

   ($maxlen, $header, $header2, $trailer, $separator, @list)=@_;
    $output=$header;
    $linelen=length($output);
    $last_term=pop(@list);
    foreach $term (@list) {
        if ((length($term)+$linelen+length($separator))>$maxlen) {
            $output .= "\n$header2" ;
            $linelen = length($header2);
        }
        $output .= "$term$separator";
        $linelen += length($term)+ length($separator);
    }
        if ((length($last_term)+$linelen+length($trailer))>$maxlen) {
            $output .= "\n$header2" ;
        }
        $output .= "$last_term$trailer";
return $output;
}

#

&#91;code&#93;

&#91;/code&#93;

enjoy  

Outcomes