-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathBalun_XX_Example.py
More file actions
111 lines (87 loc) · 3.61 KB
/
Copy pathBalun_XX_Example.py
File metadata and controls
111 lines (87 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'''
This script is to call the appropriate functions to generate baluns with the
'XX' structure. Also, this script assumes that the cells generated by the
individual functions remain in memory so 'Balun_XX_Build' function can reference
to them and use them to construct the balun. Apparently this is how 'gdspy' works.
For baluns that are not reducible to a 1:1, the turns on the primary and the
secondary must be even.
'''
import gdspy
import Balun_Scripts.Balun_Parts as BP
import Balun_Scripts.Valid_Check as VC
from Balun_Scripts.Balun_XX_Build import Balun_XX_Build
#define global library
lib = gdspy.GdsLibrary()
#########################
# Variables. Change me. #
#########################
# GDS cell name for the balun
Cell_Name = 'Balun_XX'
# via row and columns
viaM = 4
# Square via width
viaW = 1
# via spacing
viaS = 1
# Length of the balun
balunLength = 300
# Width of each track
trackWidth = 9
# Spacing between tracks
trackSpacing = 3
# Turns in the primary
primaryTurns = 3
# Turns in the secondary
secondaryTurns = 3
##########################################
# Generate GDS cells of some balun parts #
##########################################
# Order is important as certain functions depend on previously generated GDS cells.
# Generate GDS cell for a square
BP.SQ(lib, trackWidth)
# Generate GDS cell for the via array
BP.VIA(lib, int(viaM), viaW, viaS)
# Generate the 'XX' crossover
BP.XX(lib, trackWidth, trackSpacing)
# Generate the 'X' crossover
BP.X(lib, trackWidth, trackSpacing)
#############################################################
# With the given balun parameters, will the balun be valid? #
#############################################################
# Total number of tracks is primary turns plus secondary turns
max_tracks = VC.max_tracks(lib, balunLength, trackWidth, trackSpacing, 'XX')
# Total tracks should be even for 'XX' baluns
if max_tracks%2:
max_tracks = max_tracks - 1
# If not 1:1, the turns on either the side must be even and not equal to zero
ratio_valid = VC.Ratio_XX(int(primaryTurns), int(secondaryTurns))
if max_tracks >= (int(primaryTurns) + int(secondaryTurns)) and ratio_valid:
###############################################
# Generate GDS cells of remaining balun parts #
###############################################
# Generate the all the tracks
BP.TR(lib, balunLength, trackWidth, trackSpacing, int(primaryTurns), int(secondaryTurns))
# Generate ports
BP.P(lib)
#################################
# Construct the 'XX' type balun #
#################################
Balun_XX_Build(lib, balunLength, trackWidth, trackSpacing, int(primaryTurns), int(secondaryTurns), C_Name = Cell_Name)
#####################################################
# Only write the balun cell into the GDS file in um #
#####################################################
cell_list = []
cell_list.append(Cell_Name)
gdspy.write_gds(Cell_Name + '.gds', cells = cell_list, unit = 1.0e-6, precision = 1.0e-9)
################################################
# Display all the GDS cells in current library #
################################################
gdspy.LayoutViewer(lib)
else:
##############################
# Display issues with inputs #
##############################
if max_tracks < (int(primaryTurns) + int(secondaryTurns)):
print('Maximum number of tracks is: '+str(max_tracks))
if ratio_valid == False:
print('Turn ratio not valid!')