def get_site_pin_timing(site_pin_info): """ Convert site_pin_info JSON into InPinTiming or OutPinTiming object. Returns ------- If timing information is not present for this site pin, returns None. If this is an output pin, returns OutPinTiming. If this is an input pin, returns InPinTiming. """ if isinstance(site_pin_info, str): return site_pin_info, None wire = site_pin_info['wire'] if 'delay' not in site_pin_info: return None delays = fast_slow_tuple_to_corners(site_pin_info['delay']) if 'cap' in site_pin_info: assert 'res' not in site_pin_info return wire, InPinTiming( delays=delays, capacitance=float(site_pin_info['cap']) / CAPACITANCE_FACTOR, ) else: assert 'res' in site_pin_info return wire, OutPinTiming( delays=delays, drive_resistance=float(site_pin_info['res']) / RESISTANCE_FACTOR, )
def get_pip_timing(pip_timing_json): """ Convert pip_timing_json JSON into PipTiming object. Returns ------- If timing information is not present for this pip, returns None. If timing information is present, returns PipTiming. Some fields may be None if the pip type lacks that field. """ if pip_timing_json is None: return None delays = None if pip_timing_json.get('delay') is not None: delays = fast_slow_tuple_to_corners(pip_timing_json.get('delay')) in_cap = pip_timing_json.get('in_cap') if in_cap is not None: in_cap = float(in_cap) / CAPACITANCE_FACTOR else: in_cap = 0 res = pip_timing_json.get('res') if res is not None: res = float(res) / RESISTANCE_FACTOR else: res = 0 return PipTiming( delays=delays, drive_resistance=res, internal_capacitance=in_cap, )