forked from huangqiangsheng/Ruby_mask
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrenchwaveguide_class.rb
More file actions
92 lines (89 loc) · 2.87 KB
/
Trenchwaveguide_class.rb
File metadata and controls
92 lines (89 loc) · 2.87 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
load "waveguide.rb"
class Trenchwaveguide
include MyBasic
include RBA
attr_accessor :wg_width, :trench_width,
:end_face_angle,:start_face_angle,
:start_angle, :end_angle,
:lay_wg,:lay_trwg, :self_poly_flag
def initialize(pts,
wg_width = 2.0,
trench_width = 3.0,
start_face_angle = nil,
end_face_angle = nil,
start_angle = nil,
end_angle = nil,
lay_wg = CellView::active.layout.layer(1, 0),
lay_trwg = CellView::active.layout.layer(1, 1),
self_poly_flag = 0,
dbu = CellView::active.layout.dbu)
@dbu = dbu
@pts = pts.collect{|p| p*(1/@dbu)}
@wg_width = wg_width/@dbu
@trench_width = trench_width/@dbu
@start_face_angle = start_face_angle
@end_face_angle = end_face_angle
@self_poly_flag = self_poly_flag
@start_angle = start_angle
@end_angle = end_angle
@lay_wg = lay_wg
@lay_trwg = lay_trwg
@ports = []
end
def pts=(pt)
@pts = pt.collect{|p| p*(1/@dbu)}
end
def pts
@pts
end
def dbu=(unit)
@dbu = unit
@pts = pts.collect{|p| p*(1/@dbu)}
@wg_width = wg_width/@dbu
@trench_width = trench_width/@dbu
end
def dbu
@dbu
end
def shapes(cell)
wg = Waveguide.new(@pts, @wg_width, @start_face_angle, @end_face_angle,@start_angle,@end_angle,@self_poly_flag)
@ports = []
@ports.push(Ports::new(width = @wg_width,
direction = wg.start_angle+Math::PI,
face_angle = @start_face_angle,
point = pts[0]))
@ports.push(Ports::new(width = @wg_width,
direction = wg.end_angle,
face_angle = @start_face_angle,
point = pts[0]))
wgshape = cell.shapes(@lay_wg)
trshape = cell.shapes(@lay_trwg)
wgshape.insert(wg.poly)
wg.width = @trench_width
trshape.insert(wg.poly)
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
cell = layout.create_cell("Top")
pts = [DPoint.new(0.0,0.0), DPoint.new(10.0,0.0),DPoint.new(10.0,10.0),DPoint.new(20.0,30.0),DPoint.new(10.0,60.0)]
pts = round_corners(pts,5.0)
tr = Trenchwaveguide.new(pts,2.0,4.0)
tr.trench_width = 6.0/dbu
tr.shapes(cell)
layout_view.select_cell(cell.cell_index, 0)
layout_view.add_missing_layers
layout_view.zoom_fit
end