def tGen( self, plusOneIfMirrored=False): for x in range(self.r.nx): for y in range(self.r.ny): o = 1 if plusOneIfMirrored else 0 pairs = [( self.anchor, Transformation( x, y, 1, 1)), ( self.anchorMY, Transformation( x+o, y, -1, 1)), ( self.anchorMX, Transformation( x, y+o, 1, -1)), ( self.anchorMXY, Transformation( x+o, y+o, -1, -1))] for ( bv, tr) in pairs: yield ( x, y, bv, tr)
def encode_T( tech, obj): globalTrans = Transformation( 0, 0, tech.pitchPoly*tech.halfXADTGrid*2, tech.pitchDG*tech.halfYADTGrid*2) if isinstance(obj, Rect): return globalTrans.hitRect( obj).toList() elif isinstance(obj, Terminal): if obj.layer == 'metal1': r = globalTrans.hitRect( obj.r) r.llx -= 200 r.urx += 200 r.lly += 360 r.ury -= 360 return { "netName" : obj.nm, "layer" : obj.layer, "rect" : r.toList()} else: raise TypeError(repr(obj) + (" is not JSON serializable. Unknown terminal layer %s" % obj.layer)) else: raise TypeError(repr(obj) + " is not JSON serializable.")
def write_globalrouting_json( self, fp, tech, placer_results=None): grs = [] terminals = [] hack = 1 # gridFactor == 4 if placer_results is not None: globalScale = Transformation( 0, 0, hack*tech.halfXADTGrid*tech.pitchPoly, hack*tech.halfYADTGrid*tech.pitchDG) b = globalScale.hitRect( Rect( *placer_results['bbox'])).canonical() terminals.append( { "netName" : placer_results['nm'], "layer" : "diearea", "rect" : b.toList()}) print( "placer_results bbox:", b.toList()) leaves_map = { leaf['template_name'] : leaf for leaf in placer_results['leaves']} for inst in placer_results['instances']: leaf = leaves_map[inst['template_name']] tr = inst['transformation'] trans = Transformation( tr['oX'], tr['oY'], tr['sX'], tr['sY']) r = globalScale.hitRect( trans.hitRect( Rect( *leaf['bbox'])).canonical()) nm = placer_results['nm'] + '/' + inst['instance_name'] + ':' + inst['template_name'] print( nm, r) terminals.append( { "netName" : nm, "layer" : "cellarea", "rect" : r.toList()}) for term in placer_results['terminals']: nm = term['net_name'] + ':' + term['hier_name'] b = globalScale.hitRect( Rect( *term['rect'])).canonical() b.llx -= 200 b.urx += 200 b.lly += 360 b.ury -= 360 terminals.append( { "netName" : nm, "layer" : term['layer'], "rect" : b.toList()}) for (k,v) in self.wires.items(): for (ly, vv) in v.items(): for gr in vv: terminals.append(gr) # halfXGRGrid should be 2 # hack = 1 works if gridFactor is 2 # what should hack be if gridFactor is 4 hack = self.gridFactor // 2 grGrid = [] globalScale = Transformation( 0, 0, hack*tech.halfXGRGrid*tech.pitchPoly, hack*tech.halfYGRGrid*tech.pitchDG) self.bbox = globalScale.hitRect( Rect( 0, 0, self.nx, self.ny)) for x in range( self.nx): for y in range( self.ny): r = globalScale.hitRect( Rect( x, y, x+1, y+1)) print( "global route:", x, y, r) grGrid.append( r.toList()) data = { "bbox" : [self.bbox.llx, self.bbox.lly, self.bbox.urx, self.bbox.ury], "globalRoutes" : grs, "globalRouteGrid" : grGrid, "terminals" : terminals} print( 'Grid bbox:', data['bbox']) fp.write( json.dumps( data, indent=2, default=lambda x: encode_GR(tech,x)) + "\n")
def test_transformation_hit1(): t = Transformation(0, 10, 1, -1) assert (0, 0) == t.hit((0, 10))
def test_transformation_postMult0(): a = Transformation(0, 10, 0, 0) b = Transformation(0, 0, 1, -1) assert (0, -10) == (b.postMult(a)).hit((0, 0))
def test_transformation_preMult0(): a = Transformation(0, 10, 0, 0) b = Transformation(0, 0, 1, -1) assert (0, -10) == (a.preMult(b)).hit((0, 0))
def test_transformation_Mult0(): a = Transformation(0, 10, 0, 0) b = Transformation(0, 0, 1, -1) assert (0, -10) == (Transformation.mult(b, a)).hit((0, 0))