#!/usr/bin/env python3 import json import sys import timing_dbs def html_for_cell(cellname, cell, html): def proc_pin(pin): if type(pin) is list: return " ".join(pin) else: return pin iopaths = [] setupholds = [] widths = [] for entry in cell: if entry["type"] == "IOPath": iopaths.append(( proc_pin(entry["from_pin"]), proc_pin(entry["to_pin"]), tuple(entry["rising"]), tuple(entry["rising"]) )) elif entry["type"] == "SetupHold": setupholds.append(( proc_pin(entry["pin"]), proc_pin(entry["clock"]), tuple(entry["setup"]), tuple(entry["hold"]) )) elif entry["type"] == "Width": widths.append(( proc_pin(entry["clock"]), tuple(entry["width"]) )) else: assert False iopaths.sort() setupholds.sort() widths.sort() print("".format(cellname), file=html) print("

{}

".format(cellname), file=html) if len(iopaths) > 0: print("

Propagation Delays

", file=html) print("", file=html) print("", file=html) print("", file=html) print("", file=html) print("", file=html) trstyle = "" for path in iopaths: from_pin, to_pin, rising, falling = path trstyle = " bgcolor=\"#dddddd\"" if trstyle == "" else "" print("".format(trstyle), file=html) print("".format(from_pin, to_pin), file=html) print("".format(rising[0], rising[1], rising[2]), file=html) print("".format(falling[0], falling[1], falling[2]), file=html) print("", file=html) print("", file=html) print("
From PortTo PortLow-High Transition (ps)High-Low Transition (ps)
MinTypMaxMinTypMax
{}{}{:.0f}{:.0f}{:.0f}{:.0f}{:.0f}{:.0f}
", file=html) if len(setupholds) > 0: print("

Setup/Hold Checks

", file=html) print("", file=html) print("", file=html) print("", file=html) print("", file=html) print("", file=html) trstyle = "" for path in setupholds: from_pin, clock, setup, hold = path trstyle = " bgcolor=\"#dddddd\"" if trstyle == "" else "" print("".format(trstyle), file=html) print("".format(from_pin, clock), file=html) print("".format(setup[0], setup[1], setup[2]), file=html) print("".format(hold[0], hold[1], hold[2]), file=html) print("", file=html) print("", file=html) print("
From PortTo ClockSetup (ps)Hold (ps)
MinTypMaxMinTypMax
{}{}{:.0f}{:.0f}{:.0f}{:.0f}{:.0f}{:.0f}
", file=html) if len(widths) > 0: print("

Width Checks

", file=html) print("", file=html) print("", file=html) print("", file=html) print("", file=html) print("", file=html) trstyle = "" for wc in widths: clock, width = wc trstyle = " bgcolor=\"#dddddd\"" if trstyle == "" else "" print("".format(trstyle), file=html) print("".format(clock), file=html) print("".format(width[0], width[1], width[2]), file=html) print("".format(0.5e6/width[2], 0.5e6/width[1], 0.5e6/width[0]), file=html) print("", file=html) print("", file=html) print("
ClockWidth (ps)Equiv. Freq (MHz)
MinTypMaxMinTypMax
{}{:.0f}{:.0f}{:.0f}{:.0f}{:.0f}{:.0f}
", file=html) print("
", file=html) def make_cell_timing_html(dbfile, family, grade, htmlfile): with open(dbfile, 'r') as f: db = json.load(f) with open(htmlfile, 'w') as html: print("", file=html) print("", file=html) print("{} Speed Grade -{} Cell Timings".format(family, grade), file=html) print("", file=html) print("", file=html) print("

{} Speed Grade -{} Cell Timings

".format(family, grade), file=html) print("

Contents

", file=html) print("
", file=html) print("
", file=html) for cellname in sorted(db.keys()): html_for_cell(cellname, db[cellname], html) print("", file=html) print("", file=html) def main(argv): if len(argv) < 3: print("./cell_html.py grade out.html") make_cell_timing_html(timing_dbs.cells_db_path("ECP5", argv[1]), "ECP5", argv[1], argv[2]) if __name__ == "__main__": sys.exit(main(sys.argv))