Download (as "Donuts_Combination.txt") Donuts_Combination
#!/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'; # 左のメニューから、これも Download して下さい
# 円弧座標(の組)を計算して返す
require './arc.pm'; # 左のメニューから、これも Download して下さい
# ---------------------------------
# arc::arc(中心 x, 中心 y, 開始角, 終了角, 半径, 頂点の数,
# 'not-used', 時計回り(-1) or 反時計回り(1) )
# ---------------------------------
our @ARGS;
our %opts;
my($VERSION);
$VERSION = "2019-07-11 09:34" ; # written by emacs time-stamp
# global variable, ここで宣言すると、 sub の中からも見える
my $pi = 3.141592;
my $polygon = 90;
my $frame = 10000;
my $ww = 100; # frame width
my $index = $frame + $ww * 2; # step to locate structure
my $W = $ww;
# 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 inverted_circle ($$$$$){
my $radius = shift;
my $width = shift;
my $F = shift; # 外側枠の大きさ
my $polygon = shift; # 多角形の頂点の数
my $gds2File = shift;
# ------------------------------------------------------
# structure 開始, policy は切捨、四捨五入の切替
# ------------------------------------------------------
my $structure = sprintf("inverted_circle-R%04d-W%03d", $radius, $width);
$gds2File -> printBgnstr( -name=> $structure);
# ------------------------------------------------------
# 外側に枠を付けて円 (反転 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;
}
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);
# ------------------------------------------------------
# donut
# ------------------------------------------------------
$gds2File -> printBoundary( -xy =>
[
arc::arc(0, 0, 0, 360, $radius + $width/2, $polygon, 'not_used', -1),
arc::arc(0, 0, 0, 360, $radius - $width/2, $polygon, 'not_used', 1)
]);
$gds2File -> printBoundary( -xy =>
[
-$F/2, -$F/2, -$F/2, $F/2, $F/2, $F/2, $F/2, -$F/2,
-$F/2 + $W, -$F/2,
-$F/2 + $W, -$F/2 + $W,
$F/2 - $W, -$F/2 + $W,
$F/2 - $W, $F/2 - $W,
-$F/2 + $W, $F/2 - $W,
-$F/2 + $W, -$F/2
]);
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
# ----------------------------------------------------------------
# -------------------------------
# Left Upper, Right Upper
# -------------------------------
my @LU; # --- To collect structure names
foreach my $diameter ( 100, 200, 400, 600, 800, 1000, 1200, 1400,1600 ) {
my $width = 200;
push (@LU, inverted_circle($diameter, $width, $frame, $polygon, $gds2File));
}
# -------------------------------
# Left Down
# -------------------------------
my @LD; # --- To collect structure names
foreach my $diameter ( 150, 200, 400, 600, 800, 1000, 1200, 1400, 1600 ) {
my $width = 200;
push (@LD, donut($diameter, $width, $frame + $W * 2, $polygon, $gds2File));
}
# -------------------------------
# Right, Down
# -------------------------------
my @RD;
foreach my $jj ( 9..17) {
my $width = 200;
my $diameter = $jj * 200; # equivalent to 1800,2000,.. 3400
push (@RD, donut($diameter, $width, $frame + $W * 2, $polygon, $gds2File));
}
# ------------------------------------------------------------------------
# place (make Strucure Reference of) above collected structure
# ------------------------------------------------------------------------
# -------------------------------
# 1. LD
# -------------------------------
$gds2File -> printBgnstr( -name=> 'LD');
my $i = 0;
foreach my $y (-1..1) {
foreach my $x (-1..1) {
$gds2File -> printSref( -name=> $LD[$i++], -xy => [ $x * $index , $y * $index]); }}
$gds2File -> printEndstr;
# -------------------------------
# 2. LU
# -------------------------------
$gds2File -> printBgnstr( -name=> 'LU');
$i = 0;
foreach my $y (-1..1) {
foreach my $x (-1..1) {
$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=> $LU[$i++], -xy => [ $x * $index , $y * $index]); }}
# $gds2File -> printEndstr;
# # -------------------------------
# 4. RD
# -------------------------------
$gds2File -> printBgnstr( -name=> 'RD');
$i = 0;
foreach my $y (-1..1) {
foreach my $x (-1..1) {
$gds2File -> printSref( -name=> $RD[$i++], -xy => [ $x * $index , $y * $index]); }}
$gds2File -> printEndstr;
# -------------------------------
# master structure
# -------------------------------
my $layout = 16000;
$gds2File -> printBgnstr( -name=> 'master');
$gds2File -> printSref( -name=> 'LD', -xy => [-$layout, -$layout]);
$gds2File -> printSref( -name=> 'LU', -xy => [-$layout, $layout]);
$gds2File -> printSref( -name=> 'LU', -xy => [ $layout, $layout]);
$gds2File -> printSref( -name=> 'RD', -xy => [ $layout, -$layout]);
# -----------------------------------------
# center mark (cross hair)
# -----------------------------------------
my $Cw = 10; # cross hair width
$gds2File -> printBoundary (
-xy=> [-$Cw, -$layout * 2,
$Cw, -$layout * 2,
$Cw, $layout * 2,
-$Cw, $layout * 2, ],
-layer=> 20,
);
$gds2File -> printBoundary (
-xy=> [-$layout * 2, -$Cw,
$layout * 2, -$Cw,
$layout * 2, $Cw,
-$layout * 2, $Cw],
-layer=> 20);
$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 30) ; ; default is 8
|