forked from JakobRat/RALF
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain_routing.py
91 lines (73 loc) · 3.15 KB
/
main_routing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# ========================================================================
#
# Script to route a already placed circuit.
#
# SPDX-FileCopyrightText: 2023 Jakob Ratschenberger
# Johannes Kepler University, Institute for Integrated Circuits
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-License-Identifier: Apache-2.0
# ========================================================================
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from SchematicCapture.Circuit import Circuit
from Magic.MagicDie import MagicDie
import faulthandler
faulthandler.enable()
import pickle
from Routing_v2.Obstacles import DieObstacles
from Routing_v2.utils import route
import time
import matplotlib.pyplot as plt
from PDK.PDK import global_pdk
#########################################################################
CIRCUIT_NAME = "DiffAmp" #Name of the circuit
PLAN_WIRES = True #If True, before detail-routing, wire-planning (global-routing) will be performed
N_PLANNING_ITERATIONS = 15 #Number of wire-planning iterations
GCELL_LENGTH = 150 #Length of a wire-planning cell (in units of lambda)
LAYERS = ['m1','m2','m3','m4'] #Layers which will be used for wire-planning
SHOW_STATS = True #If True, statistics of the routing will be printed
DESTINATION_PATH = 'Magic/Routing/' #Destination path of the routing file
PLOT_RESULT = False #If True, the result will be plotted
LOG_WIREPLAN = False #If True, the stats of the wire-planning iterations will be logged to a csv file
#########################################################################
#load the placed circuit
file = open(f"PlacementCircuits/{CIRCUIT_NAME}_placement.pkl", 'rb')
die : MagicDie
die = pickle.load(file)
file.close()
#setup obstacles from the die
die_obstacles = DieObstacles(die)
#get the placed circuit
circuit = die.circuit
#setup a axis for plotting
if PLOT_RESULT:
fig, ax = plt.subplots(1)
ax.set_aspect('equal')
ax.plot()
cm = plt.get_cmap('Set1')
for layer in global_pdk.metal_layers.values():
color = cm(hash(layer)%9)
ax.plot([], color=color, label=str(layer), linewidth=10, alpha=0.5)
fig.legend(loc='right')
else:
ax = None
start = time.time()
#route the circuit
route(circuit=circuit, routing_name=CIRCUIT_NAME, plan_wires=PLAN_WIRES,
planning_iterations=N_PLANNING_ITERATIONS, gcell_length=GCELL_LENGTH, use_layers=LAYERS,
destination_path=DESTINATION_PATH, show_stats=SHOW_STATS, ax=ax, log_wireplan=LOG_WIREPLAN)
print(f"Took {round((time.time()-start)*1e3,2)}ms")
if PLOT_RESULT:
plt.show()