mirror of https://github.com/YosysHQ/yosys.git
Added "make mklibyosys", some minor API changes
This commit is contained in:
parent
3fe2441185
commit
1df81f92ce
|
@ -22,5 +22,6 @@
|
||||||
/yosys-filterlib.html
|
/yosys-filterlib.html
|
||||||
/kernel/version_*.cc
|
/kernel/version_*.cc
|
||||||
/share
|
/share
|
||||||
|
/libyosys
|
||||||
/yosys-win32-mxebin-*
|
/yosys-win32-mxebin-*
|
||||||
/yosys-win32-vcxsrc-*
|
/yosys-win32-vcxsrc-*
|
||||||
|
|
14
Makefile
14
Makefile
|
@ -335,6 +335,20 @@ qtcreator:
|
||||||
{ echo .; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \) -printf '%h\n' | sort -u; } > qtcreator.includes
|
{ echo .; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \) -printf '%h\n' | sort -u; } > qtcreator.includes
|
||||||
touch qtcreator.config qtcreator.creator
|
touch qtcreator.config qtcreator.creator
|
||||||
|
|
||||||
|
mklibyosys: $(OBJS) $(GENFILES) $(EXTRA_TARGETS)
|
||||||
|
rm -rf libyosys
|
||||||
|
mkdir -p libyosys/include libyosys/objs
|
||||||
|
set -e; for f in $(wildcard $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2>/dev/null); do \
|
||||||
|
echo "Analyse: $$f" >&2; cpp -std=gnu++0x -MM -I. -D_YOSYS_ $$f; done | sed 's,.*:,,; s,//*,/,g; s,/[^/]*/\.\./,/,g; y, \\,\n\n,;' | \
|
||||||
|
grep '^[^/]' | sort -u | grep -v kernel/version_ | grep '\.\(h\|hh\)$$' | xargs cp -t libyosys/include/
|
||||||
|
sed -i 's/^\(# *include *"\)[^"]*\//\1/' libyosys/include/*
|
||||||
|
{ echo "#ifndef YOSYS_CONFIG_H"; echo "#define YOSYS_CONFIG_H"; for opt in $(CXXFLAGS); do [[ "$$opt" == -D* ]] || continue; V="$${opt#-D}"; N="$${V%=*}"; \
|
||||||
|
V="$${V#*=}"; [ "$$V" = "$$N" ] && echo "#define $$N" || echo "#define $$N $$V"; done; echo "#endif"; } > libyosys/include/config.h
|
||||||
|
sed -i '/^#define YOSYS_H/ { p; s/.*/#include "config.h"/; };' libyosys/include/yosys.h
|
||||||
|
cp $(filter-out kernel/driver.o,$(OBJS)) libyosys/objs/
|
||||||
|
cp tests/simple/fiedler-cooley.v libyosys/example.v
|
||||||
|
cp misc/example.cc libyosys/example.cc
|
||||||
|
|
||||||
vcxsrc: $(GENFILES) $(EXTRA_TARGETS)
|
vcxsrc: $(GENFILES) $(EXTRA_TARGETS)
|
||||||
rm -rf yosys-win32-vcxsrc-$(YOSYS_VER){,.zip}
|
rm -rf yosys-win32-vcxsrc-$(YOSYS_VER){,.zip}
|
||||||
set -e; for f in $(wildcard $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2>/dev/null); do \
|
set -e; for f in $(wildcard $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2>/dev/null); do \
|
||||||
|
|
|
@ -291,7 +291,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (optind < argc)
|
while (optind < argc)
|
||||||
run_frontend(argv[optind++], frontend_command, yosys_design, output_filename == "-" ? &backend_command : NULL, NULL);
|
run_frontend(argv[optind++], frontend_command, output_filename == "-" ? &backend_command : NULL);
|
||||||
|
|
||||||
if (!scriptfile.empty()) {
|
if (!scriptfile.empty()) {
|
||||||
if (scriptfile_tcl) {
|
if (scriptfile_tcl) {
|
||||||
|
@ -302,14 +302,14 @@ int main(int argc, char **argv)
|
||||||
log_error("Can't exectue TCL script: this version of yosys is not built with TCL support enabled.\n");
|
log_error("Can't exectue TCL script: this version of yosys is not built with TCL support enabled.\n");
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
run_frontend(scriptfile, "script", yosys_design, output_filename == "-" ? &backend_command : NULL, NULL);
|
run_frontend(scriptfile, "script", output_filename == "-" ? &backend_command : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = passes_commands.begin(); it != passes_commands.end(); it++)
|
for (auto it = passes_commands.begin(); it != passes_commands.end(); it++)
|
||||||
run_pass(*it, yosys_design);
|
run_pass(*it);
|
||||||
|
|
||||||
if (!backend_command.empty())
|
if (!backend_command.empty())
|
||||||
run_backend(output_filename, backend_command, yosys_design);
|
run_backend(output_filename, backend_command);
|
||||||
|
|
||||||
if (print_stats)
|
if (print_stats)
|
||||||
{
|
{
|
||||||
|
|
|
@ -679,8 +679,11 @@ static void handle_label(std::string &command, bool &from_to_active, const std::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_frontend(std::string filename, std::string command, RTLIL::Design *design, std::string *backend_command, std::string *from_to_label)
|
void run_frontend(std::string filename, std::string command, std::string *backend_command, std::string *from_to_label, RTLIL::Design *design)
|
||||||
{
|
{
|
||||||
|
if (design == nullptr)
|
||||||
|
design = yosys_design;
|
||||||
|
|
||||||
if (command == "auto") {
|
if (command == "auto") {
|
||||||
if (filename.size() > 2 && filename.substr(filename.size()-2) == ".v")
|
if (filename.size() > 2 && filename.substr(filename.size()-2) == ".v")
|
||||||
command = "verilog";
|
command = "verilog";
|
||||||
|
@ -772,8 +775,16 @@ void run_frontend(std::string filename, std::string command, RTLIL::Design *desi
|
||||||
Frontend::frontend_call(design, NULL, filename, command);
|
Frontend::frontend_call(design, NULL, filename, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void run_frontend(std::string filename, std::string command, RTLIL::Design *design)
|
||||||
|
{
|
||||||
|
run_frontend(filename, command, nullptr, nullptr, design);
|
||||||
|
}
|
||||||
|
|
||||||
void run_pass(std::string command, RTLIL::Design *design)
|
void run_pass(std::string command, RTLIL::Design *design)
|
||||||
{
|
{
|
||||||
|
if (design == nullptr)
|
||||||
|
design = yosys_design;
|
||||||
|
|
||||||
log("\n-- Running command `%s' --\n", command.c_str());
|
log("\n-- Running command `%s' --\n", command.c_str());
|
||||||
|
|
||||||
Pass::call(design, command);
|
Pass::call(design, command);
|
||||||
|
@ -781,6 +792,9 @@ void run_pass(std::string command, RTLIL::Design *design)
|
||||||
|
|
||||||
void run_backend(std::string filename, std::string command, RTLIL::Design *design)
|
void run_backend(std::string filename, std::string command, RTLIL::Design *design)
|
||||||
{
|
{
|
||||||
|
if (design == nullptr)
|
||||||
|
design = yosys_design;
|
||||||
|
|
||||||
if (command == "auto") {
|
if (command == "auto") {
|
||||||
if (filename.size() > 2 && filename.substr(filename.size()-2) == ".v")
|
if (filename.size() > 2 && filename.substr(filename.size()-2) == ".v")
|
||||||
command = "verilog";
|
command = "verilog";
|
||||||
|
@ -1025,9 +1039,9 @@ struct ScriptPass : public Pass {
|
||||||
if (args.size() < 2)
|
if (args.size() < 2)
|
||||||
log_cmd_error("Missing script file.\n");
|
log_cmd_error("Missing script file.\n");
|
||||||
else if (args.size() == 2)
|
else if (args.size() == 2)
|
||||||
run_frontend(args[1], "script", design, NULL, NULL);
|
run_frontend(args[1], "script", design);
|
||||||
else if (args.size() == 3)
|
else if (args.size() == 3)
|
||||||
run_frontend(args[1], "script", design, NULL, &args[2]);
|
run_frontend(args[1], "script", NULL, &args[2], design);
|
||||||
else
|
else
|
||||||
extra_args(args, 2, design, false);
|
extra_args(args, 2, design, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,9 +253,10 @@ std::string proc_self_dirname();
|
||||||
std::string proc_share_dirname();
|
std::string proc_share_dirname();
|
||||||
const char *create_prompt(RTLIL::Design *design, int recursion_counter);
|
const char *create_prompt(RTLIL::Design *design, int recursion_counter);
|
||||||
|
|
||||||
void run_frontend(std::string filename, std::string command, RTLIL::Design *design, std::string *backend_command, std::string *from_to_label);
|
void run_pass(std::string command, RTLIL::Design *design = nullptr);
|
||||||
void run_pass(std::string command, RTLIL::Design *design);
|
void run_frontend(std::string filename, std::string command, std::string *backend_command, std::string *from_to_label = nullptr, RTLIL::Design *design = nullptr);
|
||||||
void run_backend(std::string filename, std::string command, RTLIL::Design *design);
|
void run_frontend(std::string filename, std::string command, RTLIL::Design *design = nullptr);
|
||||||
|
void run_backend(std::string filename, std::string command, RTLIL::Design *design = nullptr);
|
||||||
void shell(RTLIL::Design *design);
|
void shell(RTLIL::Design *design);
|
||||||
|
|
||||||
// from kernel/version_*.o (cc source generated from Makefile)
|
// from kernel/version_*.o (cc source generated from Makefile)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
// clang -o example -std=c++11 -I/usr/include/tcl8.5 -I include/ example.cc objs/*.o -lstdc++ -lm -lrt -lreadline -lffi -ldl -ltcl8.5
|
||||||
|
|
||||||
|
#include <yosys.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Yosys::log_streams.push_back(&std::cout);
|
||||||
|
Yosys::log_error_stderr = true;
|
||||||
|
|
||||||
|
Yosys::yosys_setup();
|
||||||
|
Yosys::yosys_banner();
|
||||||
|
|
||||||
|
Yosys::run_pass("read_verilog example.v");
|
||||||
|
Yosys::run_pass("synth -noabc");
|
||||||
|
Yosys::run_pass("clean -purge");
|
||||||
|
Yosys::run_pass("write_blif example.blif");
|
||||||
|
|
||||||
|
Yosys::yosys_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,9 @@ struct SynthPass : public Pass {
|
||||||
log(" -encfile <file>\n");
|
log(" -encfile <file>\n");
|
||||||
log(" passed to 'fsm_recode' via 'fsm'\n");
|
log(" passed to 'fsm_recode' via 'fsm'\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
log(" -noabc\n");
|
||||||
|
log(" do not run abc (as if yosys was compiled without ABC support)\n");
|
||||||
|
log("\n");
|
||||||
log(" -run <from_label>[:<to_label>]\n");
|
log(" -run <from_label>[:<to_label>]\n");
|
||||||
log(" only run the commands between the labels (see below). an empty\n");
|
log(" only run the commands between the labels (see below). an empty\n");
|
||||||
log(" from label is synonymous to 'begin', and empty to label is\n");
|
log(" from label is synonymous to 'begin', and empty to label is\n");
|
||||||
|
@ -96,6 +99,7 @@ struct SynthPass : public Pass {
|
||||||
{
|
{
|
||||||
std::string top_module, fsm_opts;
|
std::string top_module, fsm_opts;
|
||||||
std::string run_from, run_to;
|
std::string run_from, run_to;
|
||||||
|
bool noabc = false;
|
||||||
|
|
||||||
size_t argidx;
|
size_t argidx;
|
||||||
for (argidx = 1; argidx < args.size(); argidx++)
|
for (argidx = 1; argidx < args.size(); argidx++)
|
||||||
|
@ -119,6 +123,10 @@ struct SynthPass : public Pass {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (args[argidx] == "-noabc") {
|
||||||
|
noabc = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
extra_args(args, argidx, design);
|
extra_args(args, argidx, design);
|
||||||
|
@ -163,7 +171,7 @@ struct SynthPass : public Pass {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef YOSYS_ENABLE_ABC
|
#ifdef YOSYS_ENABLE_ABC
|
||||||
if (check_label(active, run_from, run_to, "abc"))
|
if (check_label(active, run_from, run_to, "abc") && !noabc)
|
||||||
{
|
{
|
||||||
Pass::call(design, "abc -fast");
|
Pass::call(design, "abc -fast");
|
||||||
Pass::call(design, "opt -fast");
|
Pass::call(design, "opt -fast");
|
||||||
|
|
Loading…
Reference in New Issue