21 if (gate_library ==
nullptr)
23 log_critical(
"netlist",
"nullptr given as gate library.");
27 return std::make_unique<Netlist>(gate_library);
30 std::unique_ptr<Netlist>
load_netlist_from_string(
const std::string& netlist_string,
const std::filesystem::path& gate_library_file)
34 if (!gate_library_file.empty())
39 log_critical(
"netlist",
"could not parse gate library '{}', will not read netlist.", gate_library_file.string());
47 std::unique_ptr<Netlist>
load_netlist(
const std::filesystem::path& netlist_file,
const std::filesystem::path& gate_library_file)
49 if (access(netlist_file.c_str(), F_OK | R_OK) == -1)
51 log_critical(
"netlist",
"could not access file '{}'.", netlist_file.string());
57 if (!gate_library_file.empty())
62 log_critical(
"netlist",
"could not parse gate library '{}', will not load netlist.", gate_library_file.string());
67 if (netlist_file.extension() ==
".hal")
75 log_critical(
"netlist",
"could not load netlist '{}' without gate library.", netlist_file.string());
84 if (access(netlist_file.c_str(), F_OK | R_OK) == -1)
86 log_critical(
"netlist",
"could not access file '{}'.", netlist_file.string());
92 log_critical(
"netlist",
"gate library is a nullptr, will not load netlist.");
96 if (netlist_file.extension() ==
".hal")
108 if (!std::filesystem::is_directory(project_dir))
110 log_critical(
"netlist",
"could not access hal project '{}'.", project_dir.string());
117 log_critical(
"netlist",
"could not open hal project '{}'.", project_dir.string());
121 std::unique_ptr<Netlist> retval = std::move(pm->
get_netlist());
127 std::filesystem::path netlist_file =
args.is_option_set(
"--import-netlist") ? std::filesystem::path(
args.get_parameter(
"--import-netlist")) : pdir.
get_default_filename();
129 if (access(netlist_file.c_str(), F_OK | R_OK) == -1)
131 log_critical(
"netlist",
"cannot access file '{}'.", netlist_file.string());
135 auto extension = netlist_file.extension();
137 if (extension ==
".hal")
145 std::vector<std::unique_ptr<Netlist>>
load_netlists(
const std::filesystem::path& netlist_file)
147 if (access(netlist_file.c_str(), F_OK | R_OK) == -1)
149 log_critical(
"netlist",
"could not access file '{}'.", netlist_file.string());
std::filesystem::path get_default_filename(const std::string &extension=std::string()) const
static ProjectManager * instance()
std::unique_ptr< Netlist > & get_netlist()
bool open_project(const std::string &path="")
#define log_critical(channel,...)
GateLibrary * load(std::filesystem::path file_path, bool reload)
std::unique_ptr< Netlist > create_netlist(const GateLibrary *gate_library)
Create a new empty netlist using the specified gate library.
std::unique_ptr< Netlist > load_hal_project(const std::filesystem::path &project_dir)
Create a netlist from the given hal project.
std::unique_ptr< Netlist > load_netlist_from_string(const std::string &netlist_string, const std::filesystem::path &gate_library_file)
Create a netlist from the given string.
std::unique_ptr< Netlist > load_netlist(const std::filesystem::path &netlist_file, const std::filesystem::path &gate_library_file)
Create a netlist from the given file.
std::vector< std::unique_ptr< Netlist > > load_netlists(const std::filesystem::path &netlist_file)
Create a netlist from a given file for each matching pre-loaded gate library.
std::unique_ptr< Netlist > parse(const std::filesystem::path &file_name, const ProgramArguments &args)
std::vector< std::unique_ptr< Netlist > > parse_all(const std::filesystem::path &file_name)
std::unique_ptr< Netlist > deserialize_from_string(const std::string &hal_string, GateLibrary *gatelib)
std::unique_ptr< Netlist > deserialize_from_file(const std::filesystem::path &hal_file, GateLibrary *gatelib)
This file contains various functions to create and load netlists.