2 # -*- coding: utf-8 -*-
3 from __future__
import print_function
8 from Hurricane
import Box
9 from Hurricane
import Transformation
10 from Hurricane
import Breakpoint
11 from Hurricane
import Instance
12 from coriolis2
.settings
import af
13 from utils
import Module
, SessionManager
, Config
15 import symbolic
.cmos
# do not remove
18 widths
= {32: 600.0, 16: 490}
21 with
Config(Cfg
.Parameter
.Priority
.UserFile
) as cfg
:
22 cfg
.misc_catchCore
= False
24 cfg
.misc_paranoid
= False
26 cfg
.misc_logMode
= True
27 cfg
.misc_verboseLevel1
= True
28 cfg
.misc_verboseLevel2
= True
29 cfg
.etesian_effort
= 2
30 cfg
.etesian_spaceMargin
= "10.0%"
31 cfg
.etesian_aspectRatio
= "100.0%"
32 cfg
.etesian_uniformDensity
= True
33 cfg
.anabatic_edgeLenght
= 24
34 cfg
.anabatic_edgeWidth
= 8
35 cfg
.anabatic_topRoutingLayer
= 'METAL5'
36 cfg
.katana_searchHalo
= 30
37 cfg
.katana_eventsLimit
= 1000000
38 cfg
.katana_hTracksReservedLocal
= 7
39 cfg
.katana_vTracksReservedLocal
= 6
41 env
= af
.getEnvironment()
42 env
.setCLOCK('^clk$|m_clock')
52 with
SessionManager():
57 self
.editor
.setCell(self
.cell
)
59 result
= self
.place_and_route()
61 with
SessionManager():
70 def place_datapath(self
, datapath_insts
, x_orig
, y_orig
, fold
):
71 channel_sff1
= self
.to_dbu(0)
72 with
SessionManager():
73 slice_height
= self
.to_dbu(50.0)
74 for i
in range(len(datapath_insts
)):
76 x
= self
.to_dbu(x_orig
)
79 y
= self
.to_dbu(y_orig
) + slice_height
*(slice+1)
80 orient
= Transformation
.Orientation
.MY
82 y
= self
.to_dbu(y_orig
) + slice_height
*slice
83 orient
= Transformation
.Orientation
.ID
85 for (opname
, inst
) in datapath_insts
[i
]:
88 inst
.setTransformation(Transformation(x
, y
, orient
))
89 inst
.setPlacementStatus(Instance
.PlacementStatus
.PLACED
)
90 x
+= inst
.getAbutmentBox().getWidth()
93 """ALU16.place(), manual placement overload."""
95 for i
in range(BIT_WIDTH
):
96 datapath_insts
.append([['nmx2', None],
100 for inst
in self
.cell
.getInstances():
101 if (Module
.match_instance(datapath_insts
, 'nmx2', 'i0', inst
) or
102 Module
.match_instance(datapath_insts
, 'no2', 'nq', inst
) or
103 Module
.match_instance(datapath_insts
, 'sff1', 'i', inst
)):
106 # place to right of add
107 add
, sub
= self
.submodules
108 add_wid
= self
.from_dbu(add
.ab
.getWidth())
109 self
.place_datapath(datapath_insts
, add_wid
, 40.0, 1)
112 self
.name
= self
.name
+ '_r'
113 self
.af
.saveCell(self
.cell
, CRL
.Catalog
.State
.Views
)
114 super(ALU16
, self
).save()
121 if not self
.build_submodules():
124 # at this point we have the (auto-calculated) submodules' dimensions
125 # in their `ab` properties.
127 add
, sub
= self
.submodules
129 with
SessionManager():
132 width
= self
.from_dbu(
133 self
.ab
.getWidth() + add
.ab
.getWidth() + sub
.ab
.getWidth()
135 height
= self
.from_dbu(max([
136 self
.ab
.getHeight(), add
.ab
.getHeight(), sub
.ab
.getHeight()
139 # experiment, over-ride
140 width
= widths
[BIT_WIDTH
]
144 self
.ab
= Box(0, 0, self
.to_dbu(width
), self
.to_dbu(height
))
146 add_wid
= self
.from_dbu(add
.ab
.getWidth())
147 sub_ht
= self
.from_dbu(sub
.ab
.getHeight())
148 sub_wid
= self
.from_dbu(sub
.ab
.getWidth())
150 self
.place_submodule(add
, 0, v_margin
)
151 self
.place_submodule(sub
, width
-sub_wid
, v_margin
)
153 # TODO: replace with some form of lazy evaluation?
154 y_north
= self
.from_dbu(self
.ab
.getYMax())
155 for pin_conf
in self
.north_pins
:
156 pin_conf
['y'] = y_north
161 self
.editor
.setCell(self
.cell
)
163 # place first (in middle, between two)
164 # this puts all the remaining cells (little ones)
165 # into this (small) space so that they do not go
166 # "all over the place" around the add and sub
168 # XXX this doesn't work: box is far too big, covers the entire
169 # area (including "under" the add and sub)
171 # self.to_dbu((width-self.ab_width)/2 - h_margin),
172 # self.to_dbu(v_margin),
173 # self.to_dbu((width+self.ab_width)/2 + h_margin),
174 # self.to_dbu(height - v_margin)
176 #self.ab = Box(self.to_dbu(475), self.to_dbu(10),
177 # self.to_dbu(840), self.to_dbu(360))
178 self
.ab
= Box(0, 0, self
.to_dbu(width
), self
.to_dbu(height
))
179 self
.place() # place only
181 # then route (globally)
182 # this connects up not just in the remaining (little) cells,
183 # it connects *to add and sub and the outside world as well*
184 result
= self
.route()
190 def scriptMain(editor
=None, **kwargs
):
196 {'net': 'a({})', 'y': 15.0, 'delta': 50.0,
197 'repeat': BIT_WIDTH
, 'layer': 'METAL2'},
198 {'net': 'b({})', 'y': 20.0, 'delta': 50.0,
199 'repeat': BIT_WIDTH
, 'layer': 'METAL2'},
200 {'net': 'o({})', 'y': 25.0, 'delta': 50.0,
201 'repeat': BIT_WIDTH
, 'layer': 'METAL2'},
204 'b({})'.format(BIT_WIDTH
-1): (
205 'BLOCKAGE2', 'BLOCKAGE3', 'BLOCKAGE4',
208 orientation
=Transformation
.Orientation
.ID
,
210 add
.set_ab(160.0, 50.0 * BIT_WIDTH
)
214 {'net': 'a({})', 'y': 15.0, 'delta': 50.0,
215 'repeat': BIT_WIDTH
, 'layer': 'METAL2'},
216 {'net': 'b({})', 'y': 20.0, 'delta': 50.0,
217 'repeat': BIT_WIDTH
, 'layer': 'METAL2'},
218 {'net': 'o({})', 'y': 25.0, 'delta': 50.0,
219 'repeat': BIT_WIDTH
, 'layer': 'METAL2'},
222 'b({})'.format(BIT_WIDTH
-1): (
223 'BLOCKAGE2', 'BLOCKAGE3', 'BLOCKAGE4',
226 orientation
=Transformation
.Orientation
.ID
,
228 sub
.set_ab(165.0, 50.0 * BIT_WIDTH
)
232 'alu16', editor
, submodules
=[add
, sub
],
234 {'net': 'o({})', 'x': 245.0+o
, 'delta': 5.0, 'repeat': BIT_WIDTH
},
238 {'net': 'a({})', 'x': 195.0+o
, 'delta': 10.0, 'repeat': BIT_WIDTH
},
239 {'net': 'b({})', 'x': 200.0+o
, 'delta': 10.0, 'repeat': BIT_WIDTH
},
242 {'net': 'rst', 'y': 10.0, 'layer': 'METAL2'},
248 if __name__
== '__main__':
250 success
= scriptMain(**kwargs
)
255 sys
.exit(shellSuccess
)