From fac9ff9be632ccd9118d771b825aa89a114ef0d3 Mon Sep 17 00:00:00 2001 From: Jesse Cirimelli-Low Date: Wed, 6 Mar 2019 20:59:52 -0800 Subject: [PATCH] changed add_db.py to uncommenting method --- compiler/datasheet/add_db.py | 47 ++++++++++++++++++++--------- compiler/datasheet/datasheet.py | 15 +++++---- compiler/datasheet/datasheet_gen.py | 5 +++ compiler/datasheet/table_gen.py | 25 ++++++++++----- 4 files changed, 63 insertions(+), 29 deletions(-) diff --git a/compiler/datasheet/add_db.py b/compiler/datasheet/add_db.py index 1df3cf7b..f0f69fc7 100644 --- a/compiler/datasheet/add_db.py +++ b/compiler/datasheet/add_db.py @@ -12,23 +12,40 @@ def get_file_tree(path): return list(Path(path).rglob("*.html")) -def parse_html(file, db): - start_tag = 'Deliverables

' - with open(file, 'r+') as f: +def parse_html(file, comment): + start_tag = '' + with open(file, 'r+') as f: file_string = f.read() - start_byte = file_string.find(start_tag) + len(start_tag) - row = '' - file_string = "%s%s%s" % ( - file_string[:start_byte], row, file_string[start_byte:]) - f.seek(0) - f.write(file_string) + start_byte = file_string.find(start_tag) + while(start_byte != -1): + f.seek(0) + file_string = f.read() + start_byte = file_string.find(start_tag) + end_byte = file_string.find(end_tag) + start_byte + len(end_tag) + + f.seek(start_byte) + found = f.read(end_byte - start_byte) + + file_string = "%s%s%s" % ( + file_string[:start_byte], found[len(start_tag):len(found)-len(end_tag)] , file_string[end_byte:]) + + f.seek(0) + f.write(file_string) + start_byte = file_string.find(start_tag) + end_byte = file_string.find(end_tag) + start_byte + len(end_tag) + +def uncomment(comments): + for datasheet in datasheet_list: + for comment in comments: + if glob.glob(os.path.dirname(datasheet)+'/*' + comment): + comment_files = list(Path(os.path.dirname(datasheet)).rglob('*'+comment)) + for comment_file in comment_files: + parse_html(datasheet, comment) datasheet_list = get_file_tree(path_to_files) -for datasheet in datasheet_list: - if glob.glob(os.path.dirname(datasheet)+'/*.db'): - db_files = list(Path(os.path.dirname(datasheet)).rglob("*.db")) - for db_file in db_files: - parse_html(datasheet, db_file) +comments = ['.db'] +uncomment(comments) + diff --git a/compiler/datasheet/datasheet.py b/compiler/datasheet/datasheet.py index a7700349..a21d3dae 100644 --- a/compiler/datasheet/datasheet.py +++ b/compiler/datasheet/datasheet.py @@ -38,6 +38,9 @@ class datasheet(): with open(os.path.abspath(os.environ.get("OPENRAM_HOME")) + '/datasheet/assets/OpenRAM_logo.png', "rb") as image_file: openram_logo = base64.b64encode(image_file.read()) + #comment table rows which we may want to enable after compile time + comments = ['.db'] + self.html += 'VLSIDAOpenRAM'.format(str(vlsi_logo)[2:-1], str(openram_logo)[2:-1]) self.html += '

' + \ @@ -51,11 +54,11 @@ class datasheet(): 'Git commit id: ' + str(self.git_id) + '

' # print port table self.html += '

Ports and Configuration

' - self.html += self.io_table.to_html() + self.html += self.io_table.to_html(comments) # print operating condidition information self.html += '

Operating Conditions

' - self.html += self.operating_table.to_html() + self.html += self.operating_table.to_html(comments) # check if analytical model is being used self.html += '

Timing Data

' @@ -66,13 +69,13 @@ class datasheet(): model = "spice characterizer" # display timing data self.html += '

Using '+model+'

' - self.html += self.timing_table.to_html() + self.html += self.timing_table.to_html(comments) # display power data self.html += '

Power Data

' - self.html += self.power_table.to_html() + self.html += self.power_table.to_html(comments) # display corner information self.html += '

Characterization Corners

' - self.html += self.corners_table.to_html() + self.html += self.corners_table.to_html(comments) # display deliverables table self.html += '

Deliverables

' - self.html += self.dlv_table.to_html() + self.html += self.dlv_table.to_html(comments) diff --git a/compiler/datasheet/datasheet_gen.py b/compiler/datasheet/datasheet_gen.py index 3b4fe2ac..e6c728f0 100644 --- a/compiler/datasheet/datasheet_gen.py +++ b/compiler/datasheet/datasheet_gen.py @@ -386,6 +386,9 @@ def parse_characterizer_csv(f, pages): [PROC, VOLT, TEMP, LIB_NAME.replace(OUT_DIR, '').replace(NAME, '')]) new_sheet.dlv_table.add_row( ['.lib', 'Synthesis models', '{1}'.format(LIB_NAME, LIB_NAME.replace(OUT_DIR, ''))]) + new_sheet.dlv_table.add_row( + ['.db', 'Compiled .lib', '{1}'.format(LIB_NAME[:-3] + 'db', LIB_NAME.replace(OUT_DIR, '')[:-3] + 'db')]) + if found == 0: @@ -603,6 +606,8 @@ def parse_characterizer_csv(f, pages): ['.html', 'This datasheet', '{0}.{1}'.format(OPTS.output_name, 'html')]) new_sheet.dlv_table.add_row( ['.lib', 'Synthesis models', '{1}'.format(LIB_NAME, LIB_NAME.replace(OUT_DIR, ''))]) + new_sheet.dlv_table.add_row( + ['.db', 'Compiled .lib', '{1}'.format(LIB_NAME[:-3] + 'db', LIB_NAME.replace(OUT_DIR, '')[:-3] + 'db')]) new_sheet.dlv_table.add_row( ['.py', 'OpenRAM configuration file', '{0}.{1}'.format(OPTS.output_name, 'py')]) new_sheet.dlv_table.add_row( diff --git a/compiler/datasheet/table_gen.py b/compiler/datasheet/table_gen.py index 8f94e896..a03fea8c 100644 --- a/compiler/datasheet/table_gen.py +++ b/compiler/datasheet/table_gen.py @@ -22,27 +22,36 @@ class table_gen: html += '' return html - def gen_table_body(self): + def gen_table_body(self,comments): """generate html body (used after gen_table_head)""" html = '' html += '' html += '' for row in self.rows[1:]: - html += '' - for col in row: - html += '' - html += '' + + if row[0] not in comments: + html += '' + for col in row: + html += '' + html += '' + + else: + html += '' + html += '' html += '' return html - def to_html(self): + def to_html(self,comments): """writes table_gen object to inline html""" html = '' html += '
TypeDescriptionLink
.dbCompiled .lib file'+str(os.path.basename(db))+'
' + str(col) + '
' + str(col) + '
' html += self.gen_table_head() - html += self.gen_table_body() - html += '
' + html += self.gen_table_body(comments) + html += '\n' return html