Download (as "Inverted-Donuts.txt") Inverted-Donuts
#!/usr/bin/perl -w
# GDSII generation for 10/5 um circle
use GDS2;
use strict;
use POSIX qw(floor ceil);
use Getopt::Std;
use Math::Trig;
require './text2gds.pm';
require './arc.pm'; # 円弧座標(の組)を計算して返す
# ---------------------------------
# arc::arc(中心 x, 中心 y, 開始角, 終了角, 半径, 頂点の数,
# 'not-used', 時計回り(-1) or 反時計回り(1) )
# ---------------------------------
our @ARGS;
our %opts;
my($VERSION);
$VERSION = "2019-07-07 12:45" ; # written by emacs time-stamp
# global variable, ここで宣言すると、 sub の中からも見える
my $pi = 3.141592;
# perl Inverted-Donuts -h と入力した時の表示 (help)
# ------------------------------------------------
sub usage() {
print <<HELP;
$0:
Generate GDSII, inverted donuts
Usage
perl $0 [-h]
Where
-h show this help
HELP
}
# ------------------------------------------------------
# 引数で与えられた大きさのドーナツ形状を作る、実は反転
# ------------------------------------------------------
sub donut ($$$$$){
my $radius = shift;
my $width = shift;
my $F = shift; # 外側わくの大きさ
my $polygon = shift; # 多角形の頂点の数
my $gds2File = shift;
# ------------------------------------------------------
# structure 開始, policy は切捨、四捨五入の切替
# ------------------------------------------------------
my $structure = sprintf("donut-R%04d-W%03d", $radius, $width);
$gds2File -> printBgnstr( -name=> $structure);
# ------------------------------------------------------
# 内側の小さな円
# ------------------------------------------------------
$gds2File -> printBoundary(
-xy =>
[ arc::arc(0, 0, 0, 360, $radius - $width/2, $polygon, 'not_used', 1)]
);
# ------------------------------------------------------
# 外側に枠を付けて円 (反転 donut)
# ------------------------------------------------------
$gds2File -> printBoundary( -xy =>
[
$F/2, 0,
$F/2, $F/2,
-$F/2, $F/2,
-$F/2, -$F/2,
$F/2, -$F/2, $F/2, 0,
arc::arc(0, 0, 0, 360, $radius + $width/2, $polygon, 'not_used', -1)
]);
text2gds::text_flat( 0, -$F/2 + 500 , 11, 60, $structure, $gds2File);
$gds2File -> printEndstr();
return $structure;
}
## --------------------------------------------
## M A I N R O U T I N E
## --------------------------------------------
my ($gds2File);
my ($X) = 0; # constant (MACRO)
my ($Y) = 1; # ditto
getopts('h', \%opts);
if ($opts{'h'} ) { usage() ; exit;}
my $filename = $0;
$filename =~ s/\.txt$//; # --- Strip '.txt' part
$filename .= '.gds';
print 'output name: '. $filename, "\n";
unlink $filename;
$gds2File = new GDS2(-fileName=> '>'. $filename );
$gds2File -> printInitLib(-name=>'LibraryName');
# -----------------------------------------------------------------
# M A I N P A R T O F M A K I N G D O N U T S
# ----------------------------------------------------------------
my $polygon = 90;
my $frame = 10000;
# -------------------------------
# Left down
# -------------------------------
my @LD; # --- To collect structure names
foreach my $diameter ( 150, 200, 400, 600, 800, 1000, 1400, 1200,1600 ) {
foreach my $width ( 200) { # --- angle step
push (@LD, donut($diameter, $width, $frame, $polygon, $gds2File));
};
}
# -------------------------------
# Left upper
# -------------------------------
my @LU; # --- To collect structure names
foreach my $diameter ( 100, 200, 400, 600, 800, 1000, 1200, 1400, 1600 ) {
foreach my $width (100) { # --- angle step
push (@LU, donut($diameter, $width, $frame, $polygon, $gds2File));
};
}
# -------------------------------
# Right Upper, Down
# -------------------------------
my (@RU, @RD);
foreach my $jj ( 9..17) {
my $diameter = $jj * 200; # equivalent to 1800,2000,.. 3400
push (@RU, donut($diameter, 200, $frame, $polygon, $gds2File));
push (@RD, donut($diameter, 100, $frame, $polygon, $gds2File));
}
my $index = 10000; # step to locate structure
# ------------------------------------------------------------------------
# place (make Strucure Reference of) above collected structure
# ------------------------------------------------------------------------
# -------------------------------
# 1. LD
# -------------------------------
$gds2File -> printBgnstr( -name=> 'LD');
my $i = 0;
foreach my $y (0..2) {
foreach my $x (0..2) {
$gds2File -> printSref( -name=> $LD[$i++], -xy => [ $x * $index , $y * $index]); }}
$gds2File -> printEndstr;
# -------------------------------
# 2. LU
# -------------------------------
$gds2File -> printBgnstr( -name=> 'LU');
$i = 0;
foreach my $y (0..2) {
foreach my $x (0..2) {
$gds2File -> printSref( -name=> $LU[$i++], -xy => [ $x * $index , $y * $index]); }}
$gds2File -> printEndstr;
# -------------------------------
# 3. RU
# -------------------------------
$gds2File -> printBgnstr( -name=> 'RU');
$i = 0;
foreach my $y (0..2) {
foreach my $x (0..2) {
$gds2File -> printSref( -name=> $RU[$i++], -xy => [ $x * $index , $y * $index]); }}
$gds2File -> printEndstr;
# -------------------------------
# 4. RD
# -------------------------------
$gds2File -> printBgnstr( -name=> 'RD');
$i = 0;
foreach my $y (0..2) {
foreach my $x (0..2) {
$gds2File -> printSref( -name=> $RD[$i++], -xy => [ $x * $index , $y * $index]); }}
$gds2File -> printEndstr;
# -------------------------------
# master structure
# -------------------------------
$gds2File -> printBgnstr( -name=> 'master');
$gds2File -> printSref( -name=> 'LD', -xy => [-15000, -15000]);
$gds2File -> printSref( -name=> 'LU', -xy => [-15000, 15000]);
$gds2File -> printSref( -name=> 'RU', -xy => [ 15000, 15000]);
$gds2File -> printSref( -name=> 'RD', -xy => [ 15000, -15000]);
$gds2File -> printEndstr;
$gds2File -> printEndlib();
__END__
(require 'time-stamp)
(add-hook 'write-file-hooks 'time-stamp)
(setq time-stamp-active t)
;; (setq time-stamp-time-zone "UTC")
(setq time-stamp-time-zone nil)
(setq time-stamp-format "%04y-%02m-%02d %02H:%02M");
(setq time-stamp-start "$VERSION = \"") ;
(setq time-stamp-end "\"") ;
(setq time-stamp-line-limit 20) ; ; default is 8
|