diff --git a/compiler/router/grid.py b/compiler/router/grid.py index ad7636e5..51ae278b 100644 --- a/compiler/router/grid.py +++ b/compiler/router/grid.py @@ -17,20 +17,16 @@ class grid: """ - def __init__(self, width, height): + def __init__(self): """ Create a routing map of width x height cells and 2 in the z-axis. """ - self.width=width - self.height=height + self.NONPREFERRED_COST = 5 + self.VIA_COST = 3 self.source = [] self.target = [] self.blocked = [] - self.map={} - # let's leave this sparse, create cells on demand - # for x in range(width): - # for y in range(height): - # for z in range(2): - # self.map[vector3d(x,y,z)]=cell() + # let's leave the map sparse, cells are created on demand + self.map={} # priority queue for the maze routing self.q = Q.PriorityQueue() @@ -73,11 +69,6 @@ class grid: # img.save(filename) def set_property(self,ll,ur,z,name,value=True): - assert(ur[1] >= ll[1] and ur[0] >= ll[0]) - assert(ll[0]=0) - assert(ll[1]=0) - assert(ur[0]=0) - assert(ur[1]=0) for x in range(int(ll[0]),int(ur[0])+1): for y in range(int(ll[1]),int(ur[1])+1): n = vector3d(x,y,z) @@ -252,21 +243,14 @@ class grid: cost = 0 for p0,p1 in plist: if p0.z != p1.z: # via - cost += 2 + cost += self.VIA_COST elif p0.x != p1.x: # horizontal - cost += 2 if (p0.z == 1) else 1 + cost += self.NONPREFERRED_COST if (p0.z == 1) else 1 elif p0.y != p1.y: # vertical - cost += 2 if (p0.z == 0) else 1 + cost += self.NONPREFERRED_COST if (p0.z == 0) else 1 else: debug.error("Non-changing direction!") - # for p in path: - # if p.z != prev_p.z: - # via_cost += 2 # we count a via as 2x a wire track - # prev_layer = p.z - # prev_p = p - # - #return len(path)+via_cost return cost def get_inertia(self,p0,p1): diff --git a/compiler/router/router.py b/compiler/router/router.py index b3bf1209..0eae2d5d 100644 --- a/compiler/router/router.py +++ b/compiler/router/router.py @@ -84,14 +84,7 @@ class router: size = self.ur - self.ll debug.info(1,"Size: {0} x {1}".format(size.x,size.y)) - # The routing grid starts at the self.ll and goes up/right - # The +1 is because the source/dest object may get expanded outside the region - self.height_in_tracks = int(math.ceil(self.ur.x/self.track_width))+2 - self.width_in_tracks = int(math.ceil(self.ur.y/self.track_width))+2 - - debug.info(1,"Size (in tracks, from ll): {0} x {1}".format(self.width_in_tracks, self.height_in_tracks)) - - self.rg = grid.grid(self.height_in_tracks,self.width_in_tracks) + self.rg = grid.grid() def find_pin(self,pin): @@ -370,7 +363,7 @@ class router: ur = snap_to_grid(ur) # to scale coordinates to tracks - debug.info(1,"Converting [ {0} , {1} ]".format(ll,ur)) + #debug.info(1,"Converting [ {0} , {1} ]".format(ll,ur)) ll=ll.scale(self.track_factor) ur=ur.scale(self.track_factor) ll = ll.floor() if round_bigger else ll.round() diff --git a/compiler/router/tests/01_no_blockages_test.py b/compiler/router/tests/01_no_blockages_test.py index 4847aeea..b4524c48 100644 --- a/compiler/router/tests/01_no_blockages_test.py +++ b/compiler/router/tests/01_no_blockages_test.py @@ -51,7 +51,6 @@ class no_blockages_test(unittest.TestCase): layer_stack =("metal1","via1","metal2") r.route(layer_stack,src="A",dest="B") r.add_route(self) - self.gds_write("mytemp.gds") r = routing("test1", "01_no_blockages_test") diff --git a/compiler/router/tests/02_blockages_test.py b/compiler/router/tests/02_blockages_test.py index 9bd689ba..e4e5f6cf 100644 --- a/compiler/router/tests/02_blockages_test.py +++ b/compiler/router/tests/02_blockages_test.py @@ -49,21 +49,10 @@ class no_blockages_test(unittest.TestCase): self.gdsname = "{0}/{1}.gds".format(os.path.dirname(os.path.realpath(__file__)),gdsname) r=router.router(self.gdsname) layer_stack =("metal1","via1","metal2") - (src_rect,path,dest_rect)=r.route(layer_stack,src="A",dest="B") - r.rg.view() - self.add_rect(layer=layer_stack[0], - offset=src_rect[0], - width=src_rect[1].x-src_rect[0].x, - height=src_rect[1].y-src_rect[0].y) - self.add_wire(layer_stack,path) - self.add_rect(layer=layer_stack[0], - offset=dest_rect[0], - width=dest_rect[1].x-dest_rect[0].x, - height=dest_rect[1].y-dest_rect[0].y) + r.route(layer_stack,src="A",dest="B") + r.add_route(self) - - - r = routing("test1", "AB_blockages") + r = routing("test1", "02_blockages_test") self.local_check(r) # fails if there are any DRC errors on any cells diff --git a/compiler/router/tests/03_same_layer_pins_test.py b/compiler/router/tests/03_same_layer_pins_test.py index 76297e47..1dd81f49 100644 --- a/compiler/router/tests/03_same_layer_pins_test.py +++ b/compiler/router/tests/03_same_layer_pins_test.py @@ -49,21 +49,11 @@ class no_blockages_test(unittest.TestCase): self.gdsname = "{0}/{1}.gds".format(os.path.dirname(os.path.realpath(__file__)),gdsname) r=router.router(self.gdsname) layer_stack =("metal1","via1","metal2") - (src_rect,path,dest_rect)=r.route(layer_stack,src="A",dest="B") - #r.rg.view() - self.add_rect(layer=layer_stack[0], - offset=src_rect[0], - width=src_rect[1].x-src_rect[0].x, - height=src_rect[1].y-src_rect[0].y) - self.add_wire(layer_stack,path) - self.add_rect(layer=layer_stack[0], - offset=dest_rect[0], - width=dest_rect[1].x-dest_rect[0].x, - height=dest_rect[1].y-dest_rect[0].y) - + r.route(layer_stack,src="A",dest="B") + r.add_route(self) - r = routing("test1", "AB_same_layer_pins") + r = routing("test1", "03_same_layer_pins_test") self.local_check(r) diff --git a/compiler/router/tests/AB_no_blockages.gds b/compiler/router/tests/AB_no_blockages.gds deleted file mode 100644 index 299444f3..00000000 Binary files a/compiler/router/tests/AB_no_blockages.gds and /dev/null differ diff --git a/compiler/router/tests/temp.gds b/compiler/router/tests/temp.gds deleted file mode 100644 index 4da06d4c..00000000 Binary files a/compiler/router/tests/temp.gds and /dev/null differ