def parse_altera_cyclone_iii(filepath: Path, config: Dict) -> List[Pin]: """Parse Altera Cyclone III pinout to a Pin list. Args: fname: filename as a string config: dictionary from loaded configuration TOML file Returns: Pin list of parsed data """ part_root = filepath.stem.upper().split('-')[0] year = config['year'] node = config['node'] manufacturer = config['manufacturer'] family = config['family'] pins = [] with open(filepath, 'r', encoding='cp1252') as f: reader = csv.reader(f, delimiter='\t') _, _, _, headers, *data = reader # removes junk rows parts = [] for idx, val in enumerate(headers): if val and val[0] in ['E', 'F', 'M', 'T', 'Q', 'U']: if '/' in val: try: [int(v[1:]) for v in val.split('/')] [parts.append((idx, v)) for v in val.split('/')] except ValueError: continue else: try: int(val[1:]) parts.append((idx, val)) except ValueError: continue for part in parts: pin_id_idx, part_tail = part part_name = part_root + part_tail for row in data: try: pin_name = row[2] pin_id = row[pin_id_idx] except IndexError: continue if pin_name == '' or pin_id == '': continue pin_type = _pin_type_cleanup(pin_name) new_pin = Pin(year, node, manufacturer, family, part_name, pin_name, pin_id, pin_type) pins.append(new_pin) return pins
def parse_altera_cyclone_ten(filepath: Path, config: Dict) -> List[Pin]: """Parse Altera Cyclone-10 pinout to a Pin list. Args: fname: filename as a string config: dictionary from loaded configuration TOML file Returns: Pin list of parsed data """ part_root = filepath.stem.upper().split('-')[0] year = config['year'] node = config['node'] manufacturer = config['manufacturer'] family = config['family'] pins = [] with open(filepath, 'r', encoding='cp1252') as f: reader = csv.reader(f, delimiter='\t') header, *data = reader # removes junk rows for idx, val in enumerate(header): if val and val[0] in ['E', 'F', 'M', 'U']: try: val = val.split(' ')[0] int(val[1:]) pin_id_idx = idx part_tail = val except ValueError: continue if val and (val.startswith('Pin Name') or val.startswith('PinName')): pin_name_idx = idx part_name = part_root + part_tail for row in data: try: pin_name = row[pin_name_idx] pin_id = row[pin_id_idx] except IndexError: continue if pin_name == '' or pin_id == '': continue pin_type = _pin_type_cleanup(pin_name) new_pin = Pin(year, node, manufacturer, family, part_name, pin_name, pin_id, pin_type) pins.append(new_pin) return pins
def parse_altera_arria_gx(filepath: Path, config: Dict) -> List[Pin]: """Parse Altera Arrian GX pinout to a Pin list. Args: fname: filename as a string config: dictionary from loaded configuration TOML file Returns: Pin list of parsed data """ year = config['year'] node = config['node'] manufacturer = config['manufacturer'] family = config['family'] pins = [] with open(filepath, 'r', encoding='cp1252') as f: reader = csv.reader(f, delimiter='\t') _, _, _, headers, _, *data = reader # removes junk rows parts = [] for idx, val in enumerate(headers): if val.startswith('EP'): parts.append((idx, val)) for part in parts: pin_id_idx, part_name = part for row in data: if len(row) < 2: continue try: pin_name = row[2] pin_id = row[pin_id_idx] except IndexError: continue if pin_name == '' or pin_id == '': continue pin_type = _pin_type_cleanup(pin_name) new_pin = Pin(year, node, manufacturer, family, part_name, pin_name, pin_id, pin_type) pins.append(new_pin) return pins
def parse_xilinx_virtex_six(filepath: Path, config: Dict) -> List[Pin]: """Parse a Xilinx Virtex-6 pinout to a Pin list. Args: fname: filename as a string config: dictionary from loaded configuration TOML file Returns: Pin list of parsed data """ part_name = filepath.stem[:-3].upper() year = config['year'] node = config['node'] manufacturer = config['manufacturer'] family = config['family'] pins = [] with open(filepath, 'r') as f: reader = csv.reader(f, delimiter='\t') _, _, _, _, *data, _, _ = reader # removes junk rows for row in data: if len(row) == 0 or row[0] == '': continue pin_id = row[0] if len(row) == 2: pin_name = row[1] else: pin_name = row[2] pin_type = _pin_type_cleanup(pin_name) new_pin = Pin( year, node, manufacturer, family, part_name, pin_name, pin_id, pin_type, ) pins.append(new_pin) return pins
def parse_kintex_ultrascale_plus(filepath: Path, config: Dict) -> List[Pin]: """Parse a Xilinx Kintex Ultrascale Plus pinout to a Pin list. Args: fname: filename as a string config: dictionary from loaded configuration TOML file Returns: Pin list of parsed data """ part_name = filepath.stem[:-3].upper() year = config['year'] node = config['node'] manufacturer = config['manufacturer'] family = config['family'] pins = [] with open(filepath, 'r') as f: reader = csv.reader(f) *data, _, _ = reader # removes junk rows for row in data: if len(row) == 1 or row[0] is '': continue try: pin_type = _pin_type_cleanup(row[1]) new_pin = Pin( year, node, manufacturer, family, part_name, row[1], row[0], pin_type, ) pins.append(new_pin) except ValueError: print(row) input() return pins