Perl で gdsii
実行環境
  Active Perl
     更新するには
ppm
  ppm
  DownLoad
  実行
Help
   perldoc GDS2
Examples
  basic-lines
  simple
  simple-sref
  aref
  circle
  circle-inverted
  sample-arc
  donut
  Inverted-Donuts
  Donuts_Combination
  Hello-World
  CP-array
  text2gds.pm
  rotate.pm
  rotate-rectangle
  arc.pm
  line-and-space-180
  triangle-array-nega
  sq_sleeve.pm
  TriangleGridStep
  triangle-array-nega-CP
  CirclesArray-SQ
  LargeCircles
  MA6-Alignment-mark.pm
  Alignment-Place
  Triangle-Grid
  Triangle-Grid-Wide
  ellipsis-polygons
  inscribe_polygon
  inscribe_polygon.pm
  inscribe_polygon-ellipsis.pm
  sleeving-by-square-sample
  sleeving-by-square.pm

Perl Perl/GDSII page
Download (as "TriangleGridStep.txt")

TriangleGridStep

#!/usr/bin/perl -w
# ---------------------------------------------------------------
#     200nm の円を 150,220,330,470 などで 500um x 500um の大きさに配置する
#     実際には引数で指定する  -p 150,220,330,470  -s 500
#     200nm の円は、 CP (HoleSIPH200nm) を想定している
# ---------------------------------------------------------------
use GDS2;
use strict;
use Math::Trig;		#  三角関数を使う
use Getopt::Std;	#  引数の処理
require ( "./text2gds.pm");

our(%opts);
our(@ARGV);

my $R3 = 1.7320508;			# 大域変数  sqrt(3)

#  simulating circle (8 角形)
sub polygon_8($$$$) {			# use strict した時には、引数の数を合せておく
    #   四つの引数をローカル変数に代入
    my ($r)        = shift;		# 直径
    my ($str)      = shift;		# structure の名前
    my ($layer)    = shift;
    my ($gds2File) = shift;		# File Handle
    
    my ($theta) =    22.5 * 3.141593/180;	# get radian for 15 degree

#       + 
#       |     +  ($b, $a)   67.5 度
#       |       
#       |       
#       |
#       |
#       |              +  ($a, $b)   22.5 度
#       |   p            
#       +---------------
    
    my ($a)  =     $r / 2 * cos($theta/2);	# 15 度 -> x
    my ($b)  = 2 * $r / 2 * sin($theta/2);	# 15 度 -> y

    $gds2File -> printBgnstr(-name => $str);
    $gds2File -> printBoundary( 
        -layer => $layer, 
        -dataType => 0, 				# 指定しなくても 0 になるが
        -xy  => [   $a,  $b, 		   $b,   $a,	# 2 x 8 組の座標を設定
                   -$b,  $a, 		  -$a,   $b,
                   -$a, -$b, 		  -$b,  -$a,
                    $b, -$a, 		   $a,  -$b,
        ]);
    $gds2File -> printEndstr;    
}
sub tri_array ($$$$) {
# 引数を読む
    my $CPname = shift;
    my $pitch  = shift;		# nm
    my $span   = shift;		# um
    my $gds2File = shift;

# 名前を用意する
    my $name     = sprintf ("tri-array-p%d-s%d", $pitch * 1000, $span);
    my $sub_name = sprintf (    "array-p%d-s%d", $pitch * 1000, $span);

#  行列の数を求める
    my $columns = $span / $pitch;
    my $rows    = $span / ($pitch * $R3);

    $gds2File -> printBgnstr(-name => $sub_name);	# structure 定義を開始
    $gds2File -> printAref(
	-name=>  $CPname,
	-columns=> $columns,
	-rows=>    $rows,
        -xy=>[0,   0, 					# 左下
              $span, 0, 				# 右下
              0,   $span ]);				# 左上
    $gds2File -> printEndstr;

# 二つの  $sub_name を少しずらして置く (1)
    $gds2File -> printBgnstr(-name => $name);
    $gds2File -> printSref(
	-name =>  $sub_name,
	-xy   =>   [-$span/2, -$span/2]);

# 二つの  $sub_name を少しずらして置く (2)
    $gds2File -> printSref(
	-name =>  $sub_name,
	-xy   =>   [-$span/2  + $pitch/2, -$span/2 + $pitch * $R3/2]);

# 文字を二種類、大と小で置く
    text2gds::text_flat( -$span/2 +  7,  -$span/2 -  2, 11, 0.1, $name, $gds2File);
    text2gds::text_flat(        0,       -$span/2 - 40, 11,   3, $name, $gds2File);
    $gds2File -> printEndstr();
    return $name;
    }

## --------------------------------------------
##          M A I N  R O U T I N E 
## --------------------------------------------


my ($pitch) = '300,350,385,420,460,510';		# no space between
my ($span)  = 500; 					# set default value

getopts('s:p:', \%opts);
if ( $opts{'p'} ) { $pitch = $opts{'p'}}
if ( $opts{'s'} ) { $span  = $opts{'s'}}

my $filename = $0;                                      # ---  set filename with the same as this script
   $filename =~ s/\.txt$//;                             # ---  Strip '.txt' part
							#      単に dot(.) と書くと、「何でも文字一つ」にー致するので、
							#      「本当に . の文字」の意味で \. としています
                                                        #      $ は行末を意味します
			                                # ---  Add '.gds' to (output) filename

# 名前を用意

my $gds_name = sprintf("%s-p%s-s%d.gds", $filename, $pitch, $span);

print $gds_name;

my $gds2File = new GDS2(-fileName=> '>'. $gds_name);
$gds2File -> printInitLib(-name=>'LibraryName');

my $CPname = 'HoleSIPH200nm';
polygon_8(0.20, $CPname, 0, $gds2File);

my @NAMES;
my @PITCH = split(',', $pitch);
foreach my $pitch (@PITCH) {
    push(@NAMES, tri_array('HoleSIPH200nm', $pitch/1000, $span, $gds2File));
}
# Prepare primitive structure
# --------------------------------------------------
#         直径   名前             Layer
print join "\n", @NAMES; print "\n";

my $s = 0.5;
$gds2File -> printBgnstr(-name => 'corner');
$gds2File -> printSref( -name => $NAMES[0], -xy=> [-500-$s, -500-$s]);
$gds2File -> printSref( -name => $NAMES[1], -xy=> [-500-$s,    0]);
$gds2File -> printSref( -name => $NAMES[2], -xy=> [   0,    0]);
$gds2File -> printSref( -name => $NAMES[3], -xy=> [   0, -500 -$s]);
$gds2File -> printEndstr();    

$gds2File -> printBgnstr(-name => 'top');
foreach my $i (0..$#NAMES) {
    $gds2File -> printSref(
	-name => $NAMES[$i],
	-xy   => [ 0, $i * 1000]);
}
    $gds2File -> printEndstr();    

$gds2File -> printEndlib();
__END__

Last Update: Mon, 21 Feb 2022 10:13:01 GMT 1.66 2008/03/08