From 905f6f8b4325ff573a71b54445413c84b77a7a7a Mon Sep 17 00:00:00 2001 From: Jesse Cirimelli-Low Date: Tue, 30 Oct 2018 21:37:30 -0700 Subject: [PATCH] added docstring and renamed some functions --- .../datasheet/characterization_corners.py | 6 +++ compiler/datasheet/datasheet.py | 8 +++- compiler/datasheet/datasheet_gen.py | 46 +++++++++++++------ compiler/datasheet/deliverables.py | 6 +++ compiler/datasheet/in_out.py | 6 +++ compiler/datasheet/operating_conditions.py | 6 +++ compiler/datasheet/timing_and_current_data.py | 6 +++ 7 files changed, 68 insertions(+), 16 deletions(-) diff --git a/compiler/datasheet/characterization_corners.py b/compiler/datasheet/characterization_corners.py index 54f75c3f..494b491f 100644 --- a/compiler/datasheet/characterization_corners.py +++ b/compiler/datasheet/characterization_corners.py @@ -1,6 +1,9 @@ from flask_table import * class characterization_corners(Table): + """ + Set up characterization corners table columns and title information + """ corner_name = Col('Corner Name') process = Col('Process') power_supply = Col('Power Supply') @@ -8,6 +11,9 @@ class characterization_corners(Table): library_name_suffix = Col('Library Name Suffix') class characterization_corners_item(object): + """ + Defines the contents of a charcaterization corner table row + """ def __init__(self, corner_name, process, power_supply, temperature, library_name_suffix): self.corner_name = corner_name self.process = process diff --git a/compiler/datasheet/datasheet.py b/compiler/datasheet/datasheet.py index f9edb5da..4a3b3b69 100644 --- a/compiler/datasheet/datasheet.py +++ b/compiler/datasheet/datasheet.py @@ -8,7 +8,9 @@ import os from globals import OPTS class datasheet(): - + """ + Defines the layout,but not the data, of the html datasheet + """ def __init__(self,identifier): self.io = [] self.corners = [] @@ -20,7 +22,11 @@ class datasheet(): def generate_html(self): + """ + Generates html tables using flask-table + """ with open(os.path.abspath(os.environ.get("OPENRAM_HOME")) + '/datasheet/assets/datasheet.css', 'r') as datasheet_css: + #css styling is kept in a seperate file self.html += datasheet_css.read() self.html +='

'+ self.name + '.html' + '

' diff --git a/compiler/datasheet/datasheet_gen.py b/compiler/datasheet/datasheet_gen.py index a16959f0..a0826cf8 100644 --- a/compiler/datasheet/datasheet_gen.py +++ b/compiler/datasheet/datasheet_gen.py @@ -1,13 +1,16 @@ #!/usr/bin/env python3 """ -Datasheet Generator - -TODO: -locate all port elements in .lib -Locate all timing elements in .lib -Diagram generation -Improve css +This is a script to load data from the characterization and layout processes into +a web friendly html datasheet. This script requres the python-flask and flask-table +packages to be installed. """ +#TODO: +#locate all port elements in .lib +#Locate all timing elements in .lib +#Calculate area from .gds file +#Diagram generation +#Improve css + import debug from globals import OPTS @@ -24,10 +27,13 @@ if OPTS.datasheet_gen: from in_out import * else: debug.warning("Python library flask_table not found. Skipping html datasheet generation. This can be installed with pip install flask-table.") - + #make sure appropriate python libraries are installed def process_name(corner): + """ + Expands the names of the characterization corner types into something human friendly + """ if corner == "TT": return "Typical - Typical" if corner == "SS": @@ -37,12 +43,18 @@ def process_name(corner): else: return "custom" -def parse_file(f,pages): +def parse_characterizer_csv(f,pages): + """ + Parses output data of the Liberty file generator in order to construct the timing and + current table + """ with open(f) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') line_count = 0 for row in csv_reader: found = 0 + + #defines layout of csv file NAME = row[0] NUM_WORDS = row[1] NUM_BANKS = row[2] @@ -65,6 +77,7 @@ def parse_file(f,pages): #if the .lib information is for an existing datasheet compare timing data for item in sheet.operating: + #check if the new corner dataa is worse than the previous worse corner data if item.parameter == 'Operating Temperature': if float(TEMP) > float(item.max): @@ -87,14 +100,17 @@ def parse_file(f,pages): if float(math.floor(1000/float(MIN_PERIOD)) < float(item.max)): item.max = str(math.floor(1000/float(MIN_PERIOD))) except Exception: + #pass if MIN_PERIOD is zero (not supported by analyitcal model) pass - + #regardless of if there is already a corner for the current sram, append the new corner to the datasheet new_sheet.corners.append(characterization_corners_item(PROC,process_name(PROC),VOLT,TEMP,LIB_NAME.replace(OUT_DIR,'').replace(NAME,''))) new_sheet.dlv.append(deliverables_item('.lib','Synthesis models','{1}'.format(LIB_NAME,LIB_NAME.replace(OUT_DIR,'')))) if found == 0: + + #if this is the first corner for this sram, run first time configuration and set up tables new_sheet = datasheet(NAME) pages.append(new_sheet) @@ -106,7 +122,8 @@ def parse_file(f,pages): new_sheet.operating.append(operating_conditions_item('Operating Frequency (F)*','','',str(math.floor(1000/float(MIN_PERIOD))),'MHz')) except Exception: new_sheet.operating.append(operating_conditions_item('Operating Frequency (F)*','','',"unknown",'MHz')) #analytical model fails to provide MIN_PERIOD - + + #place holder timing and current data new_sheet.timing.append(timing_and_current_data_item('Cycle time','2','3','4')) new_sheet.timing.append(timing_and_current_data_item('Access time','2','3','4')) new_sheet.timing.append(timing_and_current_data_item('Positive clk setup','2','3','4')) @@ -118,6 +135,7 @@ def parse_file(f,pages): new_sheet.timing.append(timing_and_current_data_item('Area','2','3','4')) if not OPTS.netlist_only: + #physical layout files should not be generated in netlist only mode new_sheet.dlv.append(deliverables_item('.gds','GDSII layout views','{1}.{2}'.format(OUT_DIR,NAME,'gds'))) new_sheet.dlv.append(deliverables_item('.lef','LEF files','{1}.{2}'.format(OUT_DIR,NAME,'lef'))) @@ -128,7 +146,7 @@ def parse_file(f,pages): new_sheet.dlv.append(deliverables_item('.lib','Synthesis models','{1}'.format(LIB_NAME,LIB_NAME.replace(OUT_DIR,'')))) - + #debug table for multiport information new_sheet.io.append(in_out_item('WORD_SIZE',WORD_SIZE)) new_sheet.io.append(in_out_item('NUM_WORDS',NUM_WORDS)) new_sheet.io.append(in_out_item('NUM_BANKS',NUM_BANKS)) @@ -149,11 +167,9 @@ class datasheet_gen(): if not (os.path.isdir(in_dir)): os.mkdir(in_dir) - #if not (os.path.isdir(out_dir)): - # os.mkdir(out_dir) datasheets = [] - parse_file(in_dir + "/datasheet.info", datasheets) + parse_characterizer_csv(in_dir + "/datasheet.info", datasheets) for sheets in datasheets: diff --git a/compiler/datasheet/deliverables.py b/compiler/datasheet/deliverables.py index d5287c3a..9ba3c0e6 100644 --- a/compiler/datasheet/deliverables.py +++ b/compiler/datasheet/deliverables.py @@ -1,12 +1,18 @@ from flask_table import * class deliverables(Table): + """ + Set up delivarables table columns and title information + """ typ = Col('Type') description = Col('Description') link = Col('Link') class deliverables_item(object): + """ + Define deliverables table row elemenent information + """ def __init__(self, typ, description,link): self.typ = typ self.description = description diff --git a/compiler/datasheet/in_out.py b/compiler/datasheet/in_out.py index f656dba6..98ba9fe5 100644 --- a/compiler/datasheet/in_out.py +++ b/compiler/datasheet/in_out.py @@ -1,11 +1,17 @@ from flask_table import * class in_out(Table): + """ + Set up I/O table columns and title information for multiport debugging + """ typ = Col('Type') description = Col('Description') class in_out_item(object): + """ + Define table row element for I/O table + """ def __init__(self, typ, description): self.typ = typ self.description = description diff --git a/compiler/datasheet/operating_conditions.py b/compiler/datasheet/operating_conditions.py index e08adc61..69648174 100644 --- a/compiler/datasheet/operating_conditions.py +++ b/compiler/datasheet/operating_conditions.py @@ -1,6 +1,9 @@ from flask_table import * class operating_conditions(Table): + """ + Set up operating conditions columns and title information + """ parameter = Col('Parameter') min = Col('Min') typ = Col('Typ') @@ -8,6 +11,9 @@ class operating_conditions(Table): units = Col('Units') class operating_conditions_item(object): + """ + Define operating conditions table row element + """ def __init__(self, parameter, min, typ, max, units): self.parameter = parameter self.min = min diff --git a/compiler/datasheet/timing_and_current_data.py b/compiler/datasheet/timing_and_current_data.py index ebf489e8..ff95df49 100644 --- a/compiler/datasheet/timing_and_current_data.py +++ b/compiler/datasheet/timing_and_current_data.py @@ -1,12 +1,18 @@ from flask_table import * class timing_and_current_data(Table): + """ + Set up timing and current table columns and title information + """ parameter = Col('Parameter') min = Col('Min') max = Col('Max') units = Col('Units') class timing_and_current_data_item(object): + """ + Define timing and current data row element + """ def __init__(self, parameter, min, max, units): self.parameter = parameter self.min = min