forked from huangqiangsheng/Ruby_mask
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCpw_class.rb
More file actions
114 lines (102 loc) · 3.56 KB
/
Cpw_class.rb
File metadata and controls
114 lines (102 loc) · 3.56 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
112
113
114
load "waveguide.rb"
# Enter your Ruby code here
class Cpw_straight
include MyBasic
include RBA
attr_accessor :cpw_gap, :cpw_swidth, :cpw_width,
:taperL, :probe_w,:probe_L,
:lay_cpw,:lay_gcpw,:dbu,:wg_length
def initialize(cpw_gap = 18.0,
cpw_swidth = 10.0,
cpw_width = 350.0,
taperL = 30.0,
probe_w = 90.0,
probe_L = 90.0,
lay_cpw = CellView::active.layout.layer(1, 0),
lay_gcpw = CellView::active.layout.layer(1, 1),
dbu = CellView::active.layout.dbu,
wg_length = 100.0)
@dbu = dbu
@cpw_gap = cpw_gap/@dbu
@cpw_swidth = cpw_swidth/@dbu
@cpw_width = cpw_width/@dbu
@wg_length = wg_length/@dbu
@taperL = taperL/@dbu
@probe_w = probe_w/@dbu
@probe_L = probe_L/@dbu
@lay_cpw = lay_cpw
@lay_gcpw = lay_gcpw
@ports = []
end
def shapes(cell)
@ports = []
@ports.push(Ports::new(width = @cpw_swidth,
direction = Math::PI,
face_angle = direction+Math::PI/2.0,
point = DPoint::new(0.0,0.0)))
shape = cell.shapes(@lay_cpw)
gshape = cell.shapes(@lay_gcpw)
poly1 = []
poly2 = []
t1 = Trans::new(DTrans::M90) #mirroy along y axis
t2 = Trans::new(@wg_length,0.0)
pts = [DPoint::new(0.0,0.0),
DPoint::new(@wg_length,0.0)]
wg = Waveguide::new(pts,@cpw_swidth)
poly1.push(wg.poly)
wg = Waveguide::new(pts,@cpw_swidth+2.0*@cpw_gap)
poly2.push(wg.poly)
pts = [DPoint::new(-@taperL,0.0),
DPoint::new(0.0,0.0)]
taper = Taper::new(pts,@probe_w,@cpw_swidth)
poly1.push(taper.poly)
poly1.push(poly1[-1].transformed(t1).transformed(t2))
taper = Taper::new(pts,@probe_w+@cpw_gap*2.0,@cpw_swidth+@cpw_gap*2.0)
poly2.push(taper.poly)
poly2.push(poly2[-1].transformed(t1).transformed(t2))
pts = [DPoint::new(-@taperL-@probe_L,0.0),
DPoint::new(-@taperL,0.0)]
wg = Waveguide::new(pts,@probe_w)
poly1.push(wg.poly)
poly1.push(poly1[-1].transformed(t1).transformed(t2))
wg = Waveguide::new(pts,@probe_w+@cpw_gap*2.0)
poly2.push(wg.poly)
poly2.push(poly2[-1].transformed(t1).transformed(t2))
pts = [DPoint::new(-@taperL-@probe_L,0.0),
DPoint::new(@wg_length+@taperL+@probe_L,0.0)]
wg = Waveguide::new(pts,@cpw_width)
poly = wg.poly
rpoly = poly.round_corners(0.0/@dbu,5.0/@dbu,128)
shape.insert(rpoly)
ep = RBA::EdgeProcessor::new()
out = ep.boolean_p2p(poly1,poly2,RBA::EdgeProcessor::ModeBNotA,false, false)
out.each {|p| gshape.insert(p)}
end
def ports
return @ports
end
end
if __FILE__ == $0
include MyBasic
include RBA
# create a new view (mode 1) with an empty layout
main_window =Application::instance.main_window
layout = main_window.create_layout(1).layout
layout_view = main_window.current_view
# set the database unit (shown as an example, the default is 0.001)
dbu = 0.001
layout.dbu = dbu
# create a cell
top = layout.create_cell("Top")
cpw = Cpw_straight.new()
vlength = [900.0, 1100.0, 1300.0]
vlength.each_with_index do |len,ind|
cell = layout.create_cell("CPW #{len}")
cpw.wg_length = len/dbu
cpw.shapes(cell)
top.insert(CellInstArray::new(cell.cell_index,Trans::new(0,ind*250/dbu)))
end
layout_view.select_cell(cell.cell_index, 0)
layout_view.add_missing_layers
layout_view.zoom_fit
end