sonar/api.py
def ip(args):
        """
        Create a new sonar IP in the current working directory.

        Args:
            args (object): Should have "name" attribute
        """
        curr_dir = Path(os.getcwd())

        ip_dir = curr_dir.joinpath(args.name)
        ip_dir.mkdir()

        ip_dir.joinpath("build/bin").mkdir(parents=True)
        ip_dir.joinpath("include").mkdir()
        ip_dir.joinpath("src").mkdir()
        ip_dir.joinpath("testbench/build/bin").mkdir(parents=True)
        ip_dir.joinpath("cad").mkdir()
        ip_dir.joinpath("hls").mkdir()

        with open(ip_dir.joinpath(Constants.SONAR_IP_MAKEFILE), "w") as f:
            ip_makefile = MakeFile()
            # ip_makefile.add_ip_variables(str(ip_dir))
            f.write(str(ip_makefile.ip(str(ip_dir))))

        with open(ip_dir.joinpath("Makefile"), "w") as f:
            f.write("include sonar.mk")

        src_dir = os.path.join(
            os.path.dirname(__file__), "files_to_copy/repo/ip"
        )
        shutil.copy(
            os.path.join(src_dir, "generate_cad.tcl"), ip_dir.joinpath("cad")
        )
        shutil.copy(
            os.path.join(src_dir, "generate_cad.sh"), ip_dir.joinpath("cad")
        )
        shutil.copy(
            os.path.join(src_dir, "generate_hls.tcl"), ip_dir.joinpath("hls")
        )
        shutil.copy(
            os.path.join(src_dir, "generate_hls.sh"), ip_dir.joinpath("hls")
        )
        shutil.copy(os.path.join(src_dir, "run.sh"), ip_dir)

        base_ip_path_sh = str(ip_dir).replace(
            os.getenv("SONAR_REPO"), "$SONAR_REPO"
        )
        base_ip_path_tcl = str(ip_dir).replace(
            os.getenv("SONAR_REPO"), "${::env(SONAR_REPO)}"
        )

        sonar.include.replace_in_file(
            str(ip_dir.joinpath("cad").joinpath("generate_cad.tcl")),
            "BASE_PATH",
            base_ip_path_tcl,
        )
        sonar.include.replace_in_file(
            str(ip_dir.joinpath("cad").joinpath("generate_cad.sh")),
            "BASE_PATH",
            base_ip_path_sh,
        )
        sonar.include.replace_in_file(
            str(ip_dir.joinpath("hls").joinpath("generate_hls.tcl")),
            "BASE_PATH",
            base_ip_path_tcl,
        )
        sonar.include.replace_in_file(
            str(ip_dir.joinpath("hls").joinpath("generate_hls.sh")),
            "BASE_PATH",
            base_ip_path_sh,
        )
        sonar.include.replace_in_file(
            str(ip_dir.joinpath("run.sh")),
            "BASE_PATH",
            base_ip_path_sh,
        )

        # active_repo = sonar.database.Repo.get_active()
        sonar.database.IP.add_new(args.name, ip_dir)
        # repos = sonar.database.Repo.get()
        # path = repos[active_repo]["path"]
        # init_toml = os.path.join(path, Constants.SONAR_CONFIG_FILE)
        # init = toml.load(init_toml)
        # init["project"]["ips"] = [args.name]
        # print(init)
        # with open(init_toml, "w") as f:
        #     toml.dump(init, f)

        Create a new sonar IP in the current working directory.

        Args:
            args (object): Should have "name" attribute
        
Create a new sonar IP in the current working directory.
Create a new sonar IP in the current working directory .
def ip(args):
        curr_dir = Path(os.getcwd())
        ip_dir = curr_dir.joinpath(args.name)
        ip_dir.mkdir()
        ip_dir.joinpath("build/bin").mkdir(parents=True)
        ip_dir.joinpath("include").mkdir()
        ip_dir.joinpath("src").mkdir()
        ip_dir.joinpath("testbench/build/bin").mkdir(parents=True)
        ip_dir.joinpath("cad").mkdir()
        ip_dir.joinpath("hls").mkdir()
        with open(ip_dir.joinpath(Constants.SONAR_IP_MAKEFILE), "w") as f:
            ip_makefile = MakeFile()
            f.write(str(ip_makefile.ip(str(ip_dir))))
        with open(ip_dir.joinpath("Makefile"), "w") as f:
            f.write("include sonar.mk")
        src_dir = os.path.join(
            os.path.dirname(__file__), "files_to_copy/repo/ip"
        )
        shutil.copy(
            os.path.join(src_dir, "generate_cad.tcl"), ip_dir.joinpath("cad")
        )
        shutil.copy(
            os.path.join(src_dir, "generate_cad.sh"), ip_dir.joinpath("cad")
        )
        shutil.copy(
            os.path.join(src_dir, "generate_hls.tcl"), ip_dir.joinpath("hls")
        )
        shutil.copy(
            os.path.join(src_dir, "generate_hls.sh"), ip_dir.joinpath("hls")
        )
        shutil.copy(os.path.join(src_dir, "run.sh"), ip_dir)
        base_ip_path_sh = str(ip_dir).replace(
            os.getenv("SONAR_REPO"), "$SONAR_REPO"
        )
        base_ip_path_tcl = str(ip_dir).replace(
            os.getenv("SONAR_REPO"), "${::env(SONAR_REPO)}"
        )
        sonar.include.replace_in_file(
            str(ip_dir.joinpath("cad").joinpath("generate_cad.tcl")),
            "BASE_PATH",
            base_ip_path_tcl,
        )
        sonar.include.replace_in_file(
            str(ip_dir.joinpath("cad").joinpath("generate_cad.sh")),
            "BASE_PATH",
            base_ip_path_sh,
        )
        sonar.include.replace_in_file(
            str(ip_dir.joinpath("hls").joinpath("generate_hls.tcl")),
            "BASE_PATH",
            base_ip_path_tcl,
        )
        sonar.include.replace_in_file(
            str(ip_dir.joinpath("hls").joinpath("generate_hls.sh")),
            "BASE_PATH",
            base_ip_path_sh,
        )
        sonar.include.replace_in_file(
            str(ip_dir.joinpath("run.sh")),
            "BASE_PATH",
            base_ip_path_sh,
        )
        sonar.database.IP.add_new(args.name, ip_dir)
def ip ( args ) : curr_dir = Path ( os . getcwd ( ) ) ip_dir = curr_dir . joinpath ( args . name ) ip_dir . mkdir ( ) ip_dir . joinpath ( "build/bin" ) . mkdir ( parents = True ) ip_dir . joinpath ( "include" ) . mkdir ( ) ip_dir . joinpath ( "src" ) . mkdir ( ) ip_dir . joinpath ( "testbench/build/bin" ) . mkdir ( parents = True ) ip_dir . joinpath ( "cad" ) . mkdir ( ) ip_dir . joinpath ( "hls" ) . mkdir ( ) with open ( ip_dir . joinpath ( Constants . SONAR_IP_MAKEFILE ) , "w" ) as f : ip_makefile = MakeFile ( ) f . write ( str ( ip_makefile . ip ( str ( ip_dir ) ) ) ) with open ( ip_dir . joinpath ( "Makefile" ) , "w" ) as f : f . write ( "include sonar.mk" ) src_dir = os . path . join ( os . path . dirname ( __file__ ) , "files_to_copy/repo/ip" ) shutil . copy ( os . path . join ( src_dir , "generate_cad.tcl" ) , ip_dir . joinpath ( "cad" ) ) shutil . copy ( os . path . join ( src_dir , "generate_cad.sh" ) , ip_dir . joinpath ( "cad" ) ) shutil . copy ( os . path . join ( src_dir , "generate_hls.tcl" ) , ip_dir . joinpath ( "hls" ) ) shutil . copy ( os . path . join ( src_dir , "generate_hls.sh" ) , ip_dir . joinpath ( "hls" ) ) shutil . copy ( os . path . join ( src_dir , "run.sh" ) , ip_dir ) base_ip_path_sh = str ( ip_dir ) . replace ( os . getenv ( "SONAR_REPO" ) , "$SONAR_REPO" ) base_ip_path_tcl = str ( ip_dir ) . replace ( os . getenv ( "SONAR_REPO" ) , "${::env(SONAR_REPO)}" ) sonar . include . replace_in_file ( str ( ip_dir . joinpath ( "cad" ) . joinpath ( "generate_cad.tcl" ) ) , "BASE_PATH" , base_ip_path_tcl , ) sonar . include . replace_in_file ( str ( ip_dir . joinpath ( "cad" ) . joinpath ( "generate_cad.sh" ) ) , "BASE_PATH" , base_ip_path_sh , ) sonar . include . replace_in_file ( str ( ip_dir . joinpath ( "hls" ) . joinpath ( "generate_hls.tcl" ) ) , "BASE_PATH" , base_ip_path_tcl , ) sonar . include . replace_in_file ( str ( ip_dir . joinpath ( "hls" ) . joinpath ( "generate_hls.sh" ) ) , "BASE_PATH" , base_ip_path_sh , ) sonar . include . replace_in_file ( str ( ip_dir . joinpath ( "run.sh" ) ) , "BASE_PATH" , base_ip_path_sh , ) sonar . database . IP . add_new ( args . name , ip_dir )
Create a new sonar IP in the current working directory.
Create a new sonar IP in the current working directory .
"""
        Create a new sonar IP in the current working directory.

        Args:
            args (object): Should have "name" attribute
        """ # ip_makefile.add_ip_variables(str(ip_dir)) # active_repo = sonar.database.Repo.get_active() # repos = sonar.database.Repo.get() # path = repos[active_repo]["path"] # init_toml = os.path.join(path, Constants.SONAR_CONFIG_FILE) # init = toml.load(init_toml) # init["project"]["ips"] = [args.name] # print(init) # with open(init_toml, "w") as f: #     toml.dump(init, f)
args
Should have "name" attribute
Should have " name " attribute