class NonminimalEliminator:
    def __init__(self, db_config, table):
        self.db_ = ArkDBMySQL(db_config_file=db_config)
        self.table_ = table
        self.db_.set_table(self.table_)
        self.hypo_checker_ = StructuralHypoChecker()
        self.hypo_checker_.set_strategy(NonminimalityStrategy())

    def eliminate_nonminimal_cells(self,
                                   start,
                                   cnt,
                                   is_checking_bsf_weak=True):
        query = f'SELECT idCELL, CELL_NETLIST FROM {self.table_} LIMIT {start},{cnt}'
        nonminimal_cell_ids = list()
        runner_idx = start // cnt
        for row in tqdm(self.db_.run_query_get_all_row(query),
                        desc=f'Eliminating nonminimal[{runner_idx:02}]:'):
            self.hypo_checker_.set_netlist(row['CELL_NETLIST'])
            self.hypo_checker_.check()

            if is_checking_bsf_weak:
                is_non_minimal = not self.hypo_checker_.is_all_bsf_weak_diff()
            else:
                is_non_minimal = not self.hypo_checker_.is_all_bsf_diff()

            if is_non_minimal:
                self.db_.delete_nocommit(row['idCELL'], 'idCELL')
                nonminimal_cell_ids.append(row['idCELL'])
        self.db_.commit()
Beispiel #2
0
def remove_non_shared_multi_cells(db_config, table):
    db = ArkDBMySQL(db_config_file=db_config)
    db.set_table(table)
    id_list = [
        row['idCELL'] for row in
        db.run_query_get_all_row(f"SELECT idCELL FROM {db.get_table()} WHERE CELL_FAMILY like '%MultiCellIsoInput%'")
    ]
    for id_cell in id_list:
        db.delete(id_cell, 'idCELL')
    if len(id_list) != 0:
        db.commit()
    print(get_cell_cnt(db_config, table))
Beispiel #3
0
def update_bsf_uni_for_table(bsf_col, db_config_file, target_lib, start, cnt, force=False):
    db = ArkDBMySQL(db_config_file=db_config_file)

    if not force:
        unset_entry_cnt = db.get_query_value('CNT', f'SELECT COUNT(*) AS CNT FROM {target_lib} '
                                                    f'WHERE {bsf_col}_UNIFIED is null')
        if unset_entry_cnt == 0:
            print(f'{bsf_col}_UNIFIED column is set for all entries, skipping...')
            return

    # TODO: add fast mode, in which only null entries are selected and updated
    query = f'SELECT * FROM BSF_LIB LIMIT {start},{cnt}'
    uni_bsf_arr = db.run_query_get_all_row(query)

    runner_idx = start // cnt
    for row in tqdm(uni_bsf_arr, desc=f'Update {bsf_col}_UNI[{runner_idx:02}]'):
        db.run_sql_nocommit(f'UPDATE {target_lib} SET {bsf_col}_UNIFIED = %s WHERE {bsf_col} = %s',
                            [row['BSF_UNI'].decode("utf-8"), row['BSF'].decode("utf-8")])
    db.commit()
Beispiel #4
0
def create_bsf_table(input_cnt, db_config_file):
    db = ArkDBMySQL(db_config_file=db_config_file)

    # db.run_sql(f'DROP TABLE IF EXISTS BSF_LIB')
    create_table_sql = 'CREATE TABLE IF NOT EXISTS `CADisCMOS`.`BSF_LIB` (\
        `BSF` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\
        `BSF_UNI` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL NOT NULL,\
        PRIMARY KEY (`BSF`))\
        ENGINE = InnoDB'

    # create the BSF_LIB table if it does not exist
    db.run_sql(create_table_sql)
    db.set_table('BSF_LIB')

    uni_bsf_dict = get_uni_dict(input_cnt, ['0', '1', 'o', 'i', 'Z', 'X', 'R', 'r'])

    for key in tqdm(uni_bsf_dict.keys(), desc='Insert into DB'):
        rec = dict()
        rec['BSF_UNI'] = key
        for bsf in uni_bsf_dict[key]:
            rec['BSF'] = bsf
            db.insert_nocommit(rec)
    db.commit()
        str_size_desc = ''
        area = 0
        for size in size_desc:
            str_size_desc += str(size)
            area += int(size)
        yield str_size_desc, area


if __name__ == '__main__':
    db_config = sys.argv[1]
    db = ArkDBMySQL(db_config_file=db_config)

    create_table_sql = 'CREATE TABLE IF NOT EXISTS `CADisCMOS`.`SIZE_LIB` (\
        `idSIZE_LIB` INT NOT NULL AUTO_INCREMENT,\
        `SIZE_DESC` VARCHAR(45) NOT NULL,\
        `TX_CNT` INT NOT NULL,\
        `SIZE_AREA` INT NULL,\
        PRIMARY KEY (`idSIZE_LIB`))\
        ENGINE = InnoDB'

    # create the SIZE_LIB table if it does not exist
    db.run_sql(create_table_sql)
    db.set_table('SIZE_LIB')

    for i in range(1, 8):
        rec = {'TX_CNT': i}
        for rec['SIZE_DESC'], rec['SIZE_AREA'] in gen_sizes(
                rec['TX_CNT'], [1, 2, 3, 4]):
            db.insert_nocommit(rec)
        db.commit()