OpenRAM/compiler/modules/rom_dummy_cell.py

141 lines
5.5 KiB
Python
Raw Normal View History

# See LICENSE for licensing information.
#
# Copyright (c) 2016-2021 Regents of the University of California and The Board
# of Regents for the Oklahoma Agricultural and Mechanical College
# (acting for and on behalf of Oklahoma State University)
# All rights reserved.
#
from openram.base import design
from openram.base import vector
from openram import OPTS
from openram.sram_factory import factory
from openram.tech import drc
class rom_dummy_cell(design):
2022-09-02 05:06:48 +02:00
def __init__(self, name="", cell_name=None, add_source_contact=False, add_drain_contact=False, route_layer="m1"):
super().__init__(name, cell_name)
2022-09-02 05:06:48 +02:00
self.route_layer = route_layer
self.add_source_contact=add_source_contact
self.add_drain_contact=add_drain_contact
self.create_netlist()
self.create_layout()
def create_netlist(self):
#creates nmos for layout dimensions
self.add_nmos()
#set height and width such that the cell will tile perfectly by only ofsetting in the array by its width and height
2022-10-07 23:40:28 +02:00
def create_layout(self):
self.setup_drc_offsets()
self.add_boundary()
self.add_poly()
self.add_metal()
2022-12-09 23:25:11 +01:00
#self.add_label("0,0", self.route_layer)
2022-09-02 05:06:48 +02:00
2022-10-07 23:40:28 +02:00
# Calculates offsets of cell width and height so that tiling of cells does not violate any drc rules
def setup_drc_offsets(self):
#nmos contact to gate distance
self.contact_to_gate = 0.5 * (self.nmos.width - 2 * self.nmos.contact_width - self.nmos.poly_width - 2 * self.active_enclose_contact)
#height offset to account for active-to-active spacing between adjacent bitlines
self.poly_extend_active_spacing = abs( 2 * self.nmos.poly_extend_active - drc("active_to_active") )
#contact to contact distance, minimum cell width before drc offsets
self.base_width = self.nmos.width - 2 * self.active_enclose_contact - self.nmos.contact_width
#width offset to account for active-to-active spacing between cells on the same bitline
#this is calculated as a negative value
self.cell_diffusion_offset = ((self.base_width - 2 * self.active_enclose_contact - self.nmos.contact_width) - drc("active_to_active")) * 0.5
# width offset to account for poly-active spacing between base and dummy cells on the same bitline
self.poly_active_offset = 0.5 * (self.base_width - 2 * self.cell_diffusion_offset - (self.poly_width + 2 * self.active_enclose_contact + self.nmos.contact_width)) - self.poly_to_active
2022-09-02 05:06:48 +02:00
#so that the poly taps are far enough apart
self.poly_tap_offset = (self.base_width - self.cell_diffusion_offset - self.poly_contact.width - self.poly_active_offset) - drc("poly_to_poly")
def add_boundary(self):
2022-09-02 05:06:48 +02:00
#cell width with offsets applied, height becomes width when the cells are rotated
2022-12-09 23:25:11 +01:00
# self.width = self.nmos.height + self.poly_extend_active_spacing + 2 * self.nmos.poly_extend_active
2022-09-02 05:06:48 +02:00
self.width = self.nmos.height + self.poly_extend_active_spacing + 2 * self.nmos.poly_extend_active
# cell height with offsets applied, width becomes height when the cells are rotated, if the offsets are positive (greater than 0) they are not applied
self.height = self.base_width - min(self.cell_diffusion_offset, 0) - min(self.poly_active_offset, 0) - min(self.poly_tap_offset, 0)
super().add_boundary()
def add_poly(self):
2022-12-09 23:25:11 +01:00
poly_x = 0.5 * (self.nmos.poly_height + self.poly_extend_active_spacing)
# 0.5 * self.nmos.contact_width + self.contact_to_gate
2022-12-09 23:25:11 +01:00
self.poly = self.add_rect_center("poly", vector(poly_x, self.base_width * 0.5), 2 * poly_x, self.poly_width)
def add_metal(self):
2022-12-09 23:25:11 +01:00
if self.route_layer == "li":
via = "mcon"
else:
via = "via{}".format(self.route_layer[len(self.route_layer) - 1])
wire_y = self.height + drc["minwidth_{}".format(via)] * 0.5
wire_x = 0.5 * (self.width - self.poly_extend_active_spacing)
2022-12-09 23:25:11 +01:00
wire_start = vector( wire_x, 0)
wire_end = vector(wire_x, wire_y)
2022-09-02 05:06:48 +02:00
# if self.route_layer == 'm1':
2022-09-02 05:06:48 +02:00
# if self.drain_contact:
# self.add_via_center(self.li_stack, [wire_x, wire_y])
# if self.source_contact:
# self.add_via_center(self.li_stack, [self.width, wire_y])
self.add_path(self.route_layer, [wire_start, wire_end])
2022-12-09 23:25:11 +01:00
# drain_x = 0
# drain_y = 0.5 * (self.width)
source_x = 0.5 * (self.width - self.poly_extend_active_spacing)
source_y = 0
source_pos = vector(source_x, source_y)
self.add_layout_pin_rect_center("S", self.route_layer, source_pos)
drain_pos = vector(source_x, self.height)
self.add_layout_pin_rect_center("D", self.route_layer, drain_pos)
def add_nmos(self):
#used only for layout constants
2022-09-02 05:06:48 +02:00
# if not self.source_contact:
# add_source = False
# else:
# add_source = self.route_layer
# if not self.drain_contact:
# add_drain = False
# else:
# add_drain = self.route_layer
self.nmos = factory.create(module_type="ptx",
2022-10-07 23:40:28 +02:00
module_name="nmos_rom_mod",
2022-09-02 05:06:48 +02:00
tx_type="nmos",
add_source_contact=self.add_source_contact,
add_drain_contact=self.add_drain_contact
)