use --recursive on git submodule not --remote - one does a "latest update"
[soclayout.git] / experiments9 / LibreSOCMem.py
1
2 import CRL
3 import Hurricane
4 import Viewer
5 import Cfg
6 from Hurricane import Technology, DataBase, DbU, Library, \
7 Layer, BasicLayer, Cell, Net, Vertical, \
8 Rectilinear, Box, Point, Instance, \
9 Transformation, NetExternalComponents, \
10 Horizontal, Pad
11 from common.colors import toRGB
12 from common.patterns import toHexa
13 from helpers import u, l
14 from helpers.technology import setEnclosures
15 from helpers.overlay import CfgCache, UpdateSession
16
17
18 __all__ = ["setup"]
19
20
21 def _load():
22 print( ' o LibreSOCMem.py: create dummy abstract of "spblock_512w64b8w".' )
23
24 af = CRL.AllianceFramework.get()
25 rg = af.getRoutingGauge()
26 cg = af.getCellGauge()
27 db = DataBase.getDB()
28 tech = db.getTechnology()
29 rootlib = db.getRootLibrary()
30 sliceHeight = cg.getSliceHeight()
31 METAL2 = tech.getLayer( 'METAL2' )
32 METAL3 = tech.getLayer( 'METAL3' )
33 BLOCKAGE1 = tech.getLayer( 'BLOCKAGE1' )
34 BLOCKAGE2 = tech.getLayer( 'BLOCKAGE2' )
35 BLOCKAGE3 = tech.getLayer( 'BLOCKAGE3' )
36
37 with UpdateSession():
38 lib = Library.create( rootlib, 'LibreSOCMem' )
39 cell = Cell.create( lib, 'spblock_512w64b8w' )
40
41 cell.setAbutmentBox( Box( 0, 0, (55+2)*sliceHeight, (45+2)*sliceHeight ) )
42 nets = { 'clk' : Net.create( cell, 'clk' )
43 , 'vdd' : Net.create( cell, 'vdd' )
44 , 'vss' : Net.create( cell, 'vss' )
45 , 'blockageNet': Net.create( cell, 'blockageNet' )
46 }
47 nets['clk'].setType( Net.Type.CLOCK )
48 nets['clk'].setExternal( True )
49 nets['clk'].setDirection( Net.Direction.IN )
50 nets['vdd'].setType( Net.Type.POWER )
51 nets['vdd'].setExternal( True )
52 nets['vdd'].setDirection( Net.Direction.IN )
53 nets['vss'].setType( Net.Type.GROUND )
54 nets['vss'].setExternal( True )
55 nets['vss'].setDirection( Net.Direction.IN )
56 blockageArea = Box( cell.getAbutmentBox() )
57 blockageArea.inflate( -sliceHeight )
58 for layer in (BLOCKAGE1, BLOCKAGE2, BLOCKAGE3):
59 Pad.create( nets['blockageNet'], layer, blockageArea )
60 for name, width in ( ('a', 9), ('d', 64), ('q', 64), ('we', 8) ):
61 for bit in range(width):
62 bitName = '{}({})'.format( name, bit )
63 nets[ bitName ] = Net.create( cell, bitName )
64 nets[ bitName ].setExternal( True )
65 direction = Net.Direction.IN
66 if name == 'q':
67 direction = Net.Direction.OUT
68 nets[ bitName ].setDirection( direction )
69 METAL2pitch = rg.getLayerGauge( METAL2 ).getPitch()
70 METAL3pitch = rg.getLayerGauge( METAL3 ).getPitch()
71 METAL2width = rg.getLayerGauge( METAL2 ).getWireWidth()
72 METAL3width = rg.getLayerGauge( METAL3 ).getWireWidth()
73 southSideStep = 16
74 yref = cell.getAbutmentBox().getYMin() + sliceHeight - METAL2pitch
75 for bitpair in range(32):
76 xref = cell.getAbutmentBox().getXMax() \
77 - sliceHeight - ( (bitpair+1)*southSideStep + 2 )*METAL3pitch
78
79 pinSpecs = [ ('q', (63-bitpair*2) , 0)
80 , ('d', (63-bitpair*2) , 10)
81 , ('d', (63-bitpair*2)-1, 12)
82 , ('q', (63-bitpair*2)-1, 14)
83 ]
84 if bitpair%4 == 3:
85 pinSpecs.append( ('we', 7-bitpair//4, 8) )
86 for name, bit, deltaPitch in pinSpecs:
87 net = nets[ '{}({})'.format(name,bit) ]
88 xaxis = xref - METAL3pitch*deltaPitch
89 segment = Vertical.create( net
90 , METAL3
91 , xaxis
92 , METAL3width
93 , yref
94 , yref+8*METAL2pitch )
95 segment = Vertical.create( net
96 , METAL3
97 , xaxis
98 , METAL3width
99 , yref
100 , yref+METAL2pitch )
101 NetExternalComponents.setExternal( segment )
102 segment = Vertical.create( nets['clk']
103 , METAL3
104 , cell.getAbutmentBox().getXMin()
105 + sliceHeight + 5*METAL3pitch
106 , METAL3width
107 , yref
108 , yref+8*METAL2pitch )
109 segment = Vertical.create( nets['clk']
110 , METAL3
111 , cell.getAbutmentBox().getXMin()
112 + sliceHeight + 5*METAL3pitch
113 , METAL3width
114 , yref
115 , yref+METAL2pitch )
116 NetExternalComponents.setExternal( segment )
117
118 xref = cell.getAbutmentBox().getXMin() + sliceHeight - METAL3pitch
119 yref = cell.getAbutmentBox().getYMax() - sliceHeight
120 for bit in range(9):
121 net = nets[ '{}({})'.format('a',8-bit) ]
122 yaxis = yref - 2*sliceHeight*bit - METAL3pitch*5
123 if bit > 4:
124 yaxis -= 20*sliceHeight
125 segment = Horizontal.create( net
126 , METAL2
127 , yaxis
128 , METAL2width
129 , xref
130 , xref+8*METAL3pitch )
131 segment = Horizontal.create( net
132 , METAL2
133 , yaxis
134 , METAL2width
135 , xref
136 , xref+METAL3pitch )
137 NetExternalComponents.setExternal( segment )
138
139 xmin = cell.getAbutmentBox().getXMin() + 2*sliceHeight
140 xmax = cell.getAbutmentBox().getXMax() - 2*sliceHeight
141 yref = cell.getAbutmentBox().getYMin() + 2*sliceHeight
142 for i in range(44):
143 net = nets['vdd']
144 if i % 2:
145 net = nets['vss']
146 segment = Horizontal.create( net
147 , METAL3
148 , yref + sliceHeight*i
149 , l(24.0)
150 , xmin
151 , xmax )
152 NetExternalComponents.setExternal( segment )
153
154 af.wrapLibrary( lib, 0 )
155
156 return lib
157
158 def setup():
159 lib = _load()
160 return lib