2022年12月16日 星期五

自動修復 Hold Time Violation 的程式

以下程式會自動讀取 timing report 中的 hold time violation,跟據 clock pin name 找到 flip-flop,並且在 flip-flop output pin 的 net 上自動加入 delay cell。反覆執行以上動作直到所有的 hold time violation 都被修復為止。

In Tcl File:

proc fix_hold_time_violations {} {
    report_timing -delay_type min > top_hold.rpt
    set target_pin [exec python get_hold_time_violation.py top_hold.rpt]
    while {$target_pin != {}} {
        set target_net [get_nets -of_objects $target_pin]
        insert_buffer [get_nets $target_net] DELAY_CELL_NAME
        legalize_placement -cells [get_cells -hierarchical {eco_cell*}]
        route_zrt_eco -reroute modified_nets_only
        report_timing -delay_type min > top_hold.rpt
        set target_pin [exec python get_hold_time_violation.py top_hold.rpt]
    }
    derive_pg_connection -power_net VDD -ground_net VSS -power_pin VDD -ground_pin VSS
}

In Python File:

import sys
clock_pin_name1 = "CP"
clock_pin_name2 = "CLK"
if len(sys.argv) == 2:
    fname = sys.argv[1]
    with open(fname, "r") as f:
        lines = f.readlines()
        need_fix = 0
        for i in range(len(lines)):
            line = lines[i]
            if "slack" in line:
                if "VIOLATED" in line:
                    need_fix = 1
                break
        if need_fix:
            start = 0
            for i in range(len(lines)):
                line = lines[i]
                if "clock network delay" in line:
                    start = i
                    break
            if start:
                target_cell = ""
                for i in range(start, len(lines)):
                    line = lines[i]
                    if "/" + clock_pin_name1 in line or "/" + clock_pin_name2 in line:
                        start = i + 1
                        target_cell = line.split()[1][1:-1]
                        break
                if target_cell != "":
                    for i in range(start, len(lines)):
                        line = lines[i]
                        if target_cell in line:
                            start = i + 1
                            target_pin = line.split()[0]
                            print(target_pin)
                            break

2022年12月14日 星期三

自動修復 Short Error 的程式

以下程式利用 IC Compiler 的 verify_lvs 指令回報發生 short error 的 nets,用 python 將 short nets 擷取出來,將其刪除並重新繞線。反覆執行此流程直到所有 short errors 都被修復為止。

In Tcl File:

proc fix_short_nets {} {
    verify_lvs > lvs_result.txt
    set short_nets [exec python get_short_nets.py lvs_result.txt]
    while {$short_nets != {}} {
        remove_net_routing $short_nets
        route_zrt_eco -nets $short_nets -reroute modified_nets_only
        verify_lvs > lvs_result.txt
        set short_nets [exec python3 get_short_nets.py lvs_result.txt]
    }
}

In Python File:

import sys
short_net_list = []
if len(sys.argv) == 2:
    fname = sys.argv[1]
    with open(fname, "r") as f:
        lines = f.readlines()
        record = 0
        for line in lines:
            if "ERROR :" in line and "nets short together." in line:
                record = 1
            elif line == "\n":
                record = 0
            if record and not "ERROR :" in line:
                net = line.split()[0]
                if net != "VDD" and net != "VSS":
                    short_net_list.append(net)
for net in short_net_list:
    print(net, end = ' ')