Forgot to witre about block rotation.
[soclayout.git] / experiments7 / doAlu16Flat.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 from __future__ import print_function
4 import sys
5 import re
6
7 import CRL
8 import Cfg
9 from Hurricane import Box
10 from Hurricane import Transformation
11 from Hurricane import Breakpoint
12 from Hurricane import Instance
13 from coriolis2.settings import af
14 from utils import Module, SessionManager, Config
15
16 import symbolic.cmos # do not remove
17
18 BIT_WIDTH = 16
19
20
21 def coriolis_setup():
22 with Config(Cfg.Parameter.Priority.UserFile) as cfg:
23 cfg.misc_catchCore = False
24 cfg.misc_info = False
25 cfg.misc_paranoid = False
26 cfg.misc_bug = False
27 cfg.misc_logMode = True
28 cfg.misc_verboseLevel1 = True
29 cfg.misc_verboseLevel2 = True
30 cfg.etesian_effort = 2
31 cfg.etesian_spaceMargin = "5.0%"
32 cfg.etesian_aspectRatio = "100.0%"
33 cfg.etesian_uniformDensity = True
34 cfg.anabatic_edgeLenght = 24
35 cfg.anabatic_edgeWidth = 8
36 cfg.anabatic_topRoutingLayer = 'METAL5'
37 cfg.katana_searchHalo = 30
38 cfg.katana_eventsLimit = 1000000
39 cfg.katana_hTracksReservedLocal = 7
40 cfg.katana_vTracksReservedLocal = 6
41
42 env = af.getEnvironment()
43 env.setCLOCK('^clk$|m_clock')
44 env.setPOWER('vdd')
45 env.setGROUND('vss')
46
47
48 class AddSub(Module):
49
50 def build(self):
51 """ Main routine. """
52
53 return True
54
55
56 class ALU16(Module):
57
58 def save(self):
59 self.name = self.name + '_r'
60 self.af.saveCell(self.cell, CRL.Catalog.State.Views)
61 super(ALU16, self).save()
62
63 def build(self):
64
65 h_margin = 0.0
66 v_margin = 50.0
67
68 if not self.build_submodules():
69 return False
70
71 # at this point we have the (auto-calculated) submodules' dimensions
72 # in their `ab` properties.
73
74 add, sub = self.submodules
75
76 with SessionManager():
77 # TODO: replace with some form of lazy evaluation?
78 y_north = self.from_dbu(self.ab.getYMax())
79 for pin_conf in self.north_pins:
80 pin_conf['y'] = y_north
81
82 self.create_pins()
83
84 if self.editor:
85 self.editor.setCell(self.cell)
86
87 self.place() # place only
88 Breakpoint.stop(1, 'After ALU16 placement.')
89 result = self.route()
90
91 self.save()
92 return result
93
94
95 def scriptMain(editor=None, **kwargs):
96 coriolis_setup()
97
98 add = AddSub(
99 'add', editor,
100 pads={
101 'b({})'.format(BIT_WIDTH-1): (
102 'BLOCKAGE2', 'BLOCKAGE3', 'BLOCKAGE4',
103 ),
104 },
105 orientation=Transformation.Orientation.ID,
106 )
107 sub = AddSub(
108 'sub', editor,
109 pads={
110 'b({})'.format(BIT_WIDTH-1): (
111 'BLOCKAGE2', 'BLOCKAGE3', 'BLOCKAGE4',
112 ),
113 },
114 orientation=Transformation.Orientation.ID,
115 )
116
117 alu16 = ALU16(
118 'alu16', editor, submodules=[add, sub],
119 north_pins=[
120 {'net': 'o({})', 'x': 365.0, 'delta': -5.0, 'repeat': BIT_WIDTH},
121 {'net': 'op'},
122 ],
123 south_pins=[
124 {'net': 'a({})', 'x': 205.0, 'delta': 5.0, 'repeat': BIT_WIDTH},
125 {'net': 'b({})', 'x': 295.0, 'delta': 5.0, 'repeat': BIT_WIDTH},
126 ],
127 west_pins=[
128 {'net': 'rst', 'y': 10.0, 'layer': 'METAL2'},
129 ],
130 )
131 alu16.set_ab( 600, 650 )
132 return alu16.build()
133
134
135 if __name__ == '__main__':
136 kwargs = {}
137 success = scriptMain(**kwargs)
138 shellSuccess = 0
139 if not success:
140 shellSuccess = 1
141
142 sys.exit(shellSuccess)