def main(): parser = argparse.ArgumentParser(description=__doc__, fromfile_prefix_chars='@', prefix_chars='-~') parser.add_argument('--db_root', help="""Project X-Ray database to use.""") parser.add_argument('--part', help="""FPGA part to use.""") parser.add_argument('--site_type', help="""Site type to generate for""") parser.add_argument('--output-pb-type', nargs='?', type=argparse.FileType('w'), default=sys.stdout, help="""File to write the output too.""") parser.add_argument('--output-model', nargs='?', type=argparse.FileType('w'), default=sys.stdout, help="""File to write the output too.""") args = parser.parse_args() db = prjxray.db.Database(args.db_root, args.part) site_type = db.get_site_type(args.site_type.upper()) pb_type_xml = ET.Element( 'pb_type', { 'name': 'DUMMY-{}'.format(args.site_type), }, ) for site_pin_name in site_type.get_site_pins(): site_pin = site_type.get_site_pin(site_pin_name) if site_pin.direction == prjxray.site_type.SitePinDirection.IN: ET.SubElement(pb_type_xml, 'input', { 'name': site_pin.name, }) elif site_pin.direction == prjxray.site_type.SitePinDirection.OUT: ET.SubElement(pb_type_xml, 'output', { 'name': site_pin.name, }) else: assert False, site_pin pb_type_str = ET.tostring(pb_type_xml, pretty_print=True).decode('utf-8') args.output_pb_type.write(pb_type_str) args.output_pb_type.close() model_xml = ET.Element('models') model_str = ET.tostring(model_xml, pretty_print=True).decode('utf-8') args.output_model.write(model_str) args.output_model.close()
def main(): mydir = os.path.dirname(__file__) prjxray_db = os.path.abspath( os.path.join(mydir, "..", "..", "third_party", "prjxray-db")) db_types = prjxray.db.get_available_databases(prjxray_db) parser = argparse.ArgumentParser(description=__doc__, fromfile_prefix_chars='@', prefix_chars='-~') parser.add_argument( '--part', choices=[os.path.basename(db_type) for db_type in db_types], help="""Project X-Ray database to use.""") parser.add_argument('--site_type', help="""Site type to generate for""") parser.add_argument('--output-pb-type', nargs='?', type=argparse.FileType('w'), default=sys.stdout, help="""File to write the output too.""") parser.add_argument('--output-model', nargs='?', type=argparse.FileType('w'), default=sys.stdout, help="""File to write the output too.""") args = parser.parse_args() db = prjxray.db.Database(os.path.join(prjxray_db, args.part)) site_type = db.get_site_type(args.site_type.upper()) pb_type_xml = ET.Element( 'pb_type', { 'name': 'DUMMY-{}'.format(args.site_type), }, ) for site_pin_name in site_type.get_site_pins(): site_pin = site_type.get_site_pin(site_pin_name) if site_pin.direction == prjxray.site_type.SitePinDirection.IN: ET.SubElement(pb_type_xml, 'input', { 'name': site_pin.name, }) elif site_pin.direction == prjxray.site_type.SitePinDirection.OUT: ET.SubElement(pb_type_xml, 'output', { 'name': site_pin.name, }) else: assert False, site_pin pb_type_str = ET.tostring(pb_type_xml, pretty_print=True).decode('utf-8') args.output_pb_type.write(pb_type_str) args.output_pb_type.close() model_xml = ET.Element('models') model_str = ET.tostring(model_xml, pretty_print=True).decode('utf-8') args.output_model.write(model_str) args.output_model.close()
def import_site_as_tile(db, args): """ Create a root-level pb_type with the same pin names as a site type. """ site_type = db.get_site_type(args.tile) # Wires sink to a site within the tile are input wires. input_wires = set() # Wires source from a site within the tile are output wires. output_wires = set() site_type_instances = parse_site_type_instance(args.site_types) assert len(site_type_instances) == 1 assert args.tile in site_type_instances assert len(site_type_instances[args.tile]) == 1 for site_pin in site_type.get_site_pins(): site_type_pin = site_type.get_site_pin(site_pin) if site_type_pin.direction == prjxray.site_type.SitePinDirection.IN: input_wires.add(site_type_pin.name) elif site_type_pin.direction == prjxray.site_type.SitePinDirection.OUT: output_wires.add(site_type_pin.name) else: assert False, site_type_pin.direction ########################################################################## # Generate the model.xml file # ########################################################################## model = ModelXml(f=args.output_model, site_directory=args.site_directory) model.add_model_include(args.tile, site_type_instances[args.tile][0]) model.write_model() ########################################################################## # Generate the pb_type.xml file # ########################################################################## tile_name = args.tile pb_type_xml = start_pb_type(tile_name, args.pin_assignments, input_wires, output_wires) site = args.tile site_instance = site_type_instances[args.tile][0] site_pbtype = args.site_directory + "/{0}/{1}.pb_type.xml" site_type_path = site_pbtype.format(site.lower(), site_instance.lower()) ET.SubElement(pb_type_xml, XI_INCLUDE, { 'href': site_type_path, }) cell_pb_type = ET.ElementTree() root_element = cell_pb_type.parse(site_type_path) site_name = root_element.attrib['name'] interconnect_xml = ET.Element('interconnect') interconnect_xml.append(ET.Comment(" Tile->Site ")) for site_pin in sorted(site_type.get_site_pins()): site_type_pin = site_type.get_site_pin(site_pin) if site_type_pin.direction == prjxray.site_type.SitePinDirection.IN: add_direct(interconnect_xml, input=object_ref(add_vpr_tile_prefix(tile_name), site_pin), output=object_ref(site_name, site_pin)) elif site_type_pin.direction == prjxray.site_type.SitePinDirection.OUT: pass else: assert False, site_type_pin.direction interconnect_xml.append(ET.Comment(" Site->Tile ")) for site_pin in sorted(site_type.get_site_pins()): site_type_pin = site_type.get_site_pin(site_pin) if site_type_pin.direction == prjxray.site_type.SitePinDirection.IN: pass elif site_type_pin.direction == prjxray.site_type.SitePinDirection.OUT: add_direct( interconnect_xml, input=object_ref(site_name, site_pin), output=object_ref(add_vpr_tile_prefix(tile_name), site_pin), ) else: assert False, site_type_pin.direction pb_type_xml.append(interconnect_xml) write_xml(args.output_pb_type, pb_type_xml)