mirror of https://github.com/VLSIDA/OpenRAM.git
changed add_db.py to uncommenting method
This commit is contained in:
parent
3802c537e5
commit
fac9ff9be6
|
|
@ -12,23 +12,40 @@ def get_file_tree(path):
|
||||||
return list(Path(path).rglob("*.html"))
|
return list(Path(path).rglob("*.html"))
|
||||||
|
|
||||||
|
|
||||||
def parse_html(file, db):
|
def parse_html(file, comment):
|
||||||
start_tag = 'Deliverables</p><table id= "data"><thead><tr><th>Type</th><th>Description</th><th>Link</th></tr></thead><tbody><tr><tr>'
|
start_tag = '<!--'+comment
|
||||||
with open(file, 'r+') as f:
|
end_tag = '-->'
|
||||||
|
|
||||||
|
with open(file, 'r+') as f:
|
||||||
file_string = f.read()
|
file_string = f.read()
|
||||||
start_byte = file_string.find(start_tag) + len(start_tag)
|
start_byte = file_string.find(start_tag)
|
||||||
row = '<tr><td>.db</td><td>Compiled .lib file</td><td><a href="' + \
|
|
||||||
str(db)+'">'+str(os.path.basename(db))+'</a></td></tr>'
|
|
||||||
file_string = "%s%s%s" % (
|
|
||||||
file_string[:start_byte], row, file_string[start_byte:])
|
|
||||||
f.seek(0)
|
|
||||||
f.write(file_string)
|
|
||||||
|
|
||||||
|
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)
|
datasheet_list = get_file_tree(path_to_files)
|
||||||
for datasheet in datasheet_list:
|
comments = ['.db']
|
||||||
if glob.glob(os.path.dirname(datasheet)+'/*.db'):
|
uncomment(comments)
|
||||||
db_files = list(Path(os.path.dirname(datasheet)).rglob("*.db"))
|
|
||||||
for db_file in db_files:
|
|
||||||
parse_html(datasheet, db_file)
|
|
||||||
|
|
|
||||||
|
|
@ -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:
|
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())
|
openram_logo = base64.b64encode(image_file.read())
|
||||||
|
|
||||||
|
#comment table rows which we may want to enable after compile time
|
||||||
|
comments = ['.db']
|
||||||
|
|
||||||
self.html += '<a href="https://vlsida.soe.ucsc.edu/"><img src="data:image/png;base64,{0}" alt="VLSIDA"></a><a href ="https://github.com/VLSIDA/OpenRAM"><img src ="data:image/png;base64,{1}" alt = "OpenRAM"></a>'.format(str(vlsi_logo)[2:-1], str(openram_logo)[2:-1])
|
self.html += '<a href="https://vlsida.soe.ucsc.edu/"><img src="data:image/png;base64,{0}" alt="VLSIDA"></a><a href ="https://github.com/VLSIDA/OpenRAM"><img src ="data:image/png;base64,{1}" alt = "OpenRAM"></a>'.format(str(vlsi_logo)[2:-1], str(openram_logo)[2:-1])
|
||||||
|
|
||||||
self.html += '<p style="font-size: 18px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">' + \
|
self.html += '<p style="font-size: 18px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">' + \
|
||||||
|
|
@ -51,11 +54,11 @@ class datasheet():
|
||||||
'Git commit id: ' + str(self.git_id) + '</p>'
|
'Git commit id: ' + str(self.git_id) + '</p>'
|
||||||
# print port table
|
# print port table
|
||||||
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Ports and Configuration</p>'
|
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Ports and Configuration</p>'
|
||||||
self.html += self.io_table.to_html()
|
self.html += self.io_table.to_html(comments)
|
||||||
|
|
||||||
# print operating condidition information
|
# print operating condidition information
|
||||||
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Operating Conditions</p>'
|
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Operating Conditions</p>'
|
||||||
self.html += self.operating_table.to_html()
|
self.html += self.operating_table.to_html(comments)
|
||||||
|
|
||||||
# check if analytical model is being used
|
# check if analytical model is being used
|
||||||
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Timing Data</p>'
|
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Timing Data</p>'
|
||||||
|
|
@ -66,13 +69,13 @@ class datasheet():
|
||||||
model = "spice characterizer"
|
model = "spice characterizer"
|
||||||
# display timing data
|
# display timing data
|
||||||
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Using '+model+'</p>'
|
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Using '+model+'</p>'
|
||||||
self.html += self.timing_table.to_html()
|
self.html += self.timing_table.to_html(comments)
|
||||||
# display power data
|
# display power data
|
||||||
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Power Data</p>'
|
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Power Data</p>'
|
||||||
self.html += self.power_table.to_html()
|
self.html += self.power_table.to_html(comments)
|
||||||
# display corner information
|
# display corner information
|
||||||
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Characterization Corners</p>'
|
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Characterization Corners</p>'
|
||||||
self.html += self.corners_table.to_html()
|
self.html += self.corners_table.to_html(comments)
|
||||||
# display deliverables table
|
# display deliverables table
|
||||||
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Deliverables</p>'
|
self.html += '<p style="font-size: 26px;font-family: Trebuchet MS, Arial, Helvetica, sans-serif;">Deliverables</p>'
|
||||||
self.html += self.dlv_table.to_html()
|
self.html += self.dlv_table.to_html(comments)
|
||||||
|
|
|
||||||
|
|
@ -386,6 +386,9 @@ def parse_characterizer_csv(f, pages):
|
||||||
[PROC, VOLT, TEMP, LIB_NAME.replace(OUT_DIR, '').replace(NAME, '')])
|
[PROC, VOLT, TEMP, LIB_NAME.replace(OUT_DIR, '').replace(NAME, '')])
|
||||||
new_sheet.dlv_table.add_row(
|
new_sheet.dlv_table.add_row(
|
||||||
['.lib', 'Synthesis models', '<a href="file://{0}">{1}</a>'.format(LIB_NAME, LIB_NAME.replace(OUT_DIR, ''))])
|
['.lib', 'Synthesis models', '<a href="file://{0}">{1}</a>'.format(LIB_NAME, LIB_NAME.replace(OUT_DIR, ''))])
|
||||||
|
new_sheet.dlv_table.add_row(
|
||||||
|
['.db', 'Compiled .lib', '<a href="{1}">{1}</a>'.format(LIB_NAME[:-3] + 'db', LIB_NAME.replace(OUT_DIR, '')[:-3] + 'db')])
|
||||||
|
|
||||||
|
|
||||||
if found == 0:
|
if found == 0:
|
||||||
|
|
||||||
|
|
@ -603,6 +606,8 @@ def parse_characterizer_csv(f, pages):
|
||||||
['.html', 'This datasheet', '<a href="{0}.{1}">{0}.{1}</a>'.format(OPTS.output_name, 'html')])
|
['.html', 'This datasheet', '<a href="{0}.{1}">{0}.{1}</a>'.format(OPTS.output_name, 'html')])
|
||||||
new_sheet.dlv_table.add_row(
|
new_sheet.dlv_table.add_row(
|
||||||
['.lib', 'Synthesis models', '<a href="{1}">{1}</a>'.format(LIB_NAME, LIB_NAME.replace(OUT_DIR, ''))])
|
['.lib', 'Synthesis models', '<a href="{1}">{1}</a>'.format(LIB_NAME, LIB_NAME.replace(OUT_DIR, ''))])
|
||||||
|
new_sheet.dlv_table.add_row(
|
||||||
|
['.db', 'Compiled .lib', '<a href="{1}">{1}</a>'.format(LIB_NAME[:-3] + 'db', LIB_NAME.replace(OUT_DIR, '')[:-3] + 'db')])
|
||||||
new_sheet.dlv_table.add_row(
|
new_sheet.dlv_table.add_row(
|
||||||
['.py', 'OpenRAM configuration file', '<a href="{0}.{1}">{0}.{1}</a>'.format(OPTS.output_name, 'py')])
|
['.py', 'OpenRAM configuration file', '<a href="{0}.{1}">{0}.{1}</a>'.format(OPTS.output_name, 'py')])
|
||||||
new_sheet.dlv_table.add_row(
|
new_sheet.dlv_table.add_row(
|
||||||
|
|
|
||||||
|
|
@ -22,27 +22,36 @@ class table_gen:
|
||||||
html += '</thead>'
|
html += '</thead>'
|
||||||
return html
|
return html
|
||||||
|
|
||||||
def gen_table_body(self):
|
def gen_table_body(self,comments):
|
||||||
"""generate html body (used after gen_table_head)"""
|
"""generate html body (used after gen_table_head)"""
|
||||||
html = ''
|
html = ''
|
||||||
|
|
||||||
html += '<tbody>'
|
html += '<tbody>'
|
||||||
html += '<tr>'
|
html += '<tr>'
|
||||||
for row in self.rows[1:]:
|
for row in self.rows[1:]:
|
||||||
html += '<tr>'
|
|
||||||
for col in row:
|
if row[0] not in comments:
|
||||||
html += '<td>' + str(col) + '</td>'
|
html += '<tr>'
|
||||||
html += '</tr>'
|
for col in row:
|
||||||
|
html += '<td>' + str(col) + '</td>'
|
||||||
|
html += '</tr>'
|
||||||
|
|
||||||
|
else:
|
||||||
|
html += '<!--'+row[0]+'<tr>'
|
||||||
|
for col in row:
|
||||||
|
html += '<td>' + str(col) + '</td>'
|
||||||
|
html += '</tr>-->'
|
||||||
|
|
||||||
html += '</tr>'
|
html += '</tr>'
|
||||||
html += '</tbody>'
|
html += '</tbody>'
|
||||||
return html
|
return html
|
||||||
|
|
||||||
def to_html(self):
|
def to_html(self,comments):
|
||||||
"""writes table_gen object to inline html"""
|
"""writes table_gen object to inline html"""
|
||||||
html = ''
|
html = ''
|
||||||
html += '<table id= \"'+self.table_id+'\">'
|
html += '<table id= \"'+self.table_id+'\">'
|
||||||
html += self.gen_table_head()
|
html += self.gen_table_head()
|
||||||
html += self.gen_table_body()
|
html += self.gen_table_body(comments)
|
||||||
html += '</table>'
|
html += '</table>\n'
|
||||||
|
|
||||||
return html
|
return html
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue