OpenRAM/compiler/router/grid_cell.py

53 lines
1.2 KiB
Python
Raw Normal View History

# See LICENSE for licensing information.
#
2023-01-29 07:56:27 +01:00
# Copyright (c) 2016-2023 Regents of the University of California and The Board
2019-06-14 17:43:41 +02:00
# of Regents for the Oklahoma Agricultural and Mechanical College
# (acting for and on behalf of Oklahoma State University)
# All rights reserved.
#
2022-11-27 22:01:20 +01:00
class grid_cell:
"""
A single cell that can be occupied in a given layer, blocked,
visited, etc.
"""
def __init__(self):
2016-11-17 01:47:31 +01:00
self.path = False
self.blocked = False
2016-11-17 01:47:31 +01:00
self.source = False
self.target = False
# -1 means it isn't visited yet
2020-11-03 15:29:17 +01:00
self.min_cost = -1
def reset(self):
2020-11-03 15:29:17 +01:00
"""
2022-07-22 18:52:38 +02:00
Reset the dynamic info about routing.
"""
self.min_cost=-1
self.min_path=None
self.blocked=False
self.source=False
self.target=False
2018-11-02 22:57:40 +01:00
def get_cost(self):
# We can display the cost of the frontier
if self.min_cost > 0:
return self.min_cost
2020-11-03 15:29:17 +01:00
def get_type(self):
2019-05-31 17:43:37 +02:00
type_string = ""
2020-11-03 15:29:17 +01:00
if self.blocked:
2019-05-31 17:43:37 +02:00
type_string += "X"
if self.source:
2019-05-31 17:43:37 +02:00
type_string += "S"
if self.target:
2019-05-31 17:43:37 +02:00
type_string += "T"
2016-11-17 01:47:31 +01:00
if self.path:
2019-05-31 17:43:37 +02:00
type_string += "P"
return type_string