Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ Options:
--verbose Verbose mode
-e,--example Build example project, default is OFF
--autobuild BOOLEAN [1] Auto build the generated project, default is true
-j,--build-threads INT [0] Maximum parallel build threads; 0 uses all available CPU cores
```

Static Multi-Module Support:
Expand Down
2 changes: 2 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Options:
--verbose Verbose mode
-e,--example Build example project, default is OFF
--autobuild BOOLEAN [1] Auto build the generated project, default is true
-j,--build-threads INT [0] 最大并行构建线程数;0 表示使用所有可用 CPU 核心
```

pack 子命令用于将 UVM 中的 sequence_item 转换为其他语言,然后通过 TLM 进行通信(目前支持 Python,其他语言在开发中)
Expand Down Expand Up @@ -227,6 +228,7 @@ Options:
- `--verbose`: 可选。详细模式
- `-e,--example`: 可选。构建示例项目,默认是 OFF
- `--autobuild BOOLEAN [1]`: 可选。自动构建生成的项目,默认是 true
- `-j,--build-threads INT [0]`: 可选。限制生成项目的最大并行构建线程数,0 表示使用所有可用 CPU 核心

静态多模块支持:

Expand Down
1 change: 1 addition & 0 deletions include/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typedef struct export_opts {
bool verbose;
bool example;
bool autobuild;
int build_threads;
bool cp_lib;
SignalAccessType rw_type;
std::vector<std::string> transaction;
Expand Down
3 changes: 3 additions & 0 deletions src/codegen/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ namespace picker { namespace codegen {
data["__VERDI_MODE__"] = opts.verdi_mode;
data["__RW_TYPE__"] = opts.rw_type == picker::SignalAccessType::MEM_DIRECT ? "MEM_DIRECT" : "DPI";
data["__TARGET_LANGUAGE__"] = opts.language;
data["__BUILD_THREADS__"] =
opts.build_threads > 0 ? std::to_string(opts.build_threads) :
"$(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)";
data["__FILELIST__"] = ofilelist;
data["__LIB_DPI_FUNC_NAME_HASH__"] = std::string(lib_random_hash);
data["__GENERATOR_PICKER_PATH__"] =
Expand Down
3 changes: 2 additions & 1 deletion src/parser/sv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ namespace picker { namespace parser {
{
driver.addStandardArgs();

std::vector<std::string> args = {"picker-slang", "--single-unit", "--ignore-unknown-modules"};
std::vector<std::string> args = {"picker-slang", "--single-unit", "--ignore-unknown-modules",
"--exclude-ext", "so,a,o"};
if (opts.sim == "vcs") {
args.push_back("--compat");
args.push_back("vcs");
Expand Down
4 changes: 4 additions & 0 deletions src/picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ int set_options_export_rtl(CLI::App &top_app)
app->add_flag("-e,--example", export_opts.example, "Build example project, default is OFF");
app->add_option("--autobuild", export_opts.autobuild, "Auto build the generated project, default is true")
->default_val(true);
app->add_option("-j,--build-threads", export_opts.build_threads,
"Maximum parallel build threads; 0 uses all available CPU cores")
->default_val(0)
->check(CLI::NonNegativeNumber);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion template/cpp/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CURRENT_DIR := $(shell pwd)
NPROC := $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
NPROC ?= $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
.PHONY: all test compile clean purge copy_xspcomm

all: test clean
Expand Down
2 changes: 1 addition & 1 deletion template/golang/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CURRENT_DIR := $(shell pwd)
NPROC := $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
NPROC ?= $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
.PHONY: all test compile clean purge copy_xspcomm

all: test clean
Expand Down
2 changes: 1 addition & 1 deletion template/java/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CURRENT_DIR := $(shell pwd)
NPROC := $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
NPROC ?= $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
.PHONY: all test compile clean purge copy_xspcomm

all: test clean
Expand Down
2 changes: 1 addition & 1 deletion template/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export COVERAGE := {{__COVERAGE__}}
export CHECKPOINTS := {{__CHECKPOINTS__}}
export VPI := {{__VPI__}}
export RW_TYPE := {{__RW_TYPE__}}
NPROC := $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
export NPROC := {{__BUILD_THREADS__}}

ifeq ($(SIMULATOR), verilator)
MEM_DIRECT_TARGET_FILE := build/DPI{{__TOP_MODULE_NAME__}}/V{{__TOP_MODULE_NAME__}}___024root.h
Expand Down
2 changes: 1 addition & 1 deletion template/lua/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CURRENT_DIR := $(shell pwd)
NPROC := $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
NPROC ?= $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
.PHONY: all test compile clean purge copy_xspcomm

all: test clean
Expand Down
2 changes: 1 addition & 1 deletion template/python/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CURRENT_DIR := $(shell pwd)
NPROC := $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
NPROC ?= $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
.PHONY: all test compile clean purge copy_xspcomm

all: test clean
Expand Down
2 changes: 1 addition & 1 deletion template/scala/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CURRENT_DIR := $(shell pwd)
NPROC := $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
NPROC ?= $(shell (nproc 2>/dev/null || sysctl -n hw.ncpu) 2>/dev/null)
.PHONY: all test compile clean purge copy_xspcomm

all: test clean
Expand Down
3 changes: 3 additions & 0 deletions test/scripts/test_export_filelist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ OUT_DIR="${TMP_DIR}/out/FileListTop"
blue "[export-filelist] Exporting from a filelist with a minimal tool PATH"
env PATH="/usr/bin:/bin" "${PICKER_BIN}" export \
--autobuild false \
--build-threads 3 \
--sdir "${ROOT_DIR}/template" \
--sname FileListTop \
--fs "${TMP_DIR}/list/design.f" \
Expand All @@ -48,5 +49,7 @@ env PATH="/usr/bin:/bin" "${PICKER_BIN}" export \
test -d "${OUT_DIR}"
test -f "${OUT_DIR}/CMakeLists.txt"
test -d "${OUT_DIR}/python"
grep -Fxq 'export NPROC := 3' "${OUT_DIR}/Makefile"
grep -Fq 'NPROC ?=' "${OUT_DIR}/python/Makefile"

green "[export-filelist] OK"
11 changes: 10 additions & 1 deletion test/test_codegen_filelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ int main()
write_text(base / "sub" / "rtl2.v", "module n; endmodule\n");
write_text(base / "sub2" / "ignore.txt", "noop\n");
write_text(base / "sub2" / "rtl3.sv", "module p; endmodule\n");
write_text(base / "dependency.so", "shared library placeholder\n");
write_text(base / "dependency.a", "archive placeholder\n");
write_text(base / "dependency.o", "object placeholder\n");
write_text(cwd_base / "rtl1.sv", "module wrong; endmodule\n");

const fs::path filelist = base / "filelist.f";
Expand Down Expand Up @@ -160,7 +163,10 @@ int main()
write_text(filelist4,
"defs.vh\n"
"macro.svh\n"
"rtl1.sv\n");
"rtl1.sv\n"
"dependency.so\n"
"dependency.a\n"
"dependency.o\n");

std::string ofilelist4;
std::vector<std::string> incdirs4;
Expand All @@ -172,6 +178,9 @@ int main()
assert(contains_line(ofilelist4, (base / "rtl1.sv").string()));
assert(!contains_line(ofilelist4, (base / "defs.vh").string()));
assert(!contains_line(ofilelist4, (base / "macro.svh").string()));
assert(contains_line(ofilelist4, (base / "dependency.so").string()));
assert(contains_line(ofilelist4, (base / "dependency.a").string()));
assert(contains_line(ofilelist4, (base / "dependency.o").string()));
std::set<std::string> incset4(incdirs4.begin(), incdirs4.end());
assert(incset4.size() == 1);
assert(incset4.count(base.string()) == 1);
Expand Down
35 changes: 35 additions & 0 deletions test/test_parser_sv_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,40 @@ namespace {
fs::remove_all(base);
}

void test_filelist_ignores_linker_inputs()
{
namespace fs = std::filesystem;
const fs::path base = fs::temp_directory_path() / "picker_test_sv_filelist_linker_inputs";
fs::remove_all(base);
fs::create_directories(base);

write_text(base / "linker_top.sv",
"module LinkerTop(input logic clk);\n"
"endmodule\n");
write_text(base / "dependency.so", "not SystemVerilog\n");
write_text(base / "dependency.a", "not SystemVerilog\n");
write_text(base / "dependency.o", "not SystemVerilog\n");
write_text(base / "filelist.f",
"linker_top.sv\n"
"dependency.so\n"
"dependency.a\n"
"dependency.o\n");

picker::export_opts opts {};
opts.filelists = {(base / "filelist.f").string()};
opts.source_module_name_list = {"LinkerTop"};

std::vector<picker::sv_module_define> modules;
picker::parser::sv(opts, modules);

assert(modules.size() == 1);
assert(modules.front().module_name == "LinkerTop");
assert(modules.front().pins.size() == 1);
assert(modules.front().pins.front().logic_pin == "clk");

fs::remove_all(base);
}

void test_missing_child_modules_do_not_block_top_port_extraction()
{
namespace fs = std::filesystem;
Expand Down Expand Up @@ -273,6 +307,7 @@ int main()
test_filelist_macro_defines_are_shared_across_sources();
test_filelist_dependencies_are_used_without_explicit_module_name();
test_filelist_order_wins_when_explicit_file_is_duplicate();
test_filelist_ignores_linker_inputs();
test_missing_child_modules_do_not_block_top_port_extraction();
return 0;
}
Loading