summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzilong <[email protected]>2023-07-10 11:00:45 +0800
committerzilong <[email protected]>2023-07-10 11:00:45 +0800
commit2d0da9231087fe5b47eba5534f37108c50abd102 (patch)
tree39955002630d334291f0ffc9073f2111b4a2eb5f
parent710f14b26f29c5d6eaccdf9af197eeca4789ae35 (diff)
Add systemverilog support,Fix verilator build error
1. Add extension .sv to enable systemverilog support 2. Remove unnecessary flags in test 3. Add libz dependance when enable TRACE_FST
-rw-r--r--xmake/rules/verilator/verilator.lua16
-rw-r--r--xmake/rules/verilator/xmake.lua2
2 files changed, 11 insertions, 7 deletions
diff --git a/xmake/rules/verilator/verilator.lua b/xmake/rules/verilator/verilator.lua
index 2314bad23..eebee4121 100644
--- a/xmake/rules/verilator/verilator.lua
+++ b/xmake/rules/verilator/verilator.lua
@@ -20,6 +20,7 @@
-- imports
import("utils.progress")
+import("core.base.hashset")
import("core.project.depend")
import("private.action.build.object", {alias = "build_objectfiles"})
@@ -112,14 +113,14 @@ function config(target)
local sourcefile = path.join(tmpdir, "main.v")
local argv = {"--cc", "--make", "cmake", "--prefix", "test", "--Mdir", tmpdir, "main.v"}
local flags = target:values("verilator.flags")
+ local switches_flags = hashset.of( "sc", "coverage", "timing", "trace", "trace-fst", "threads")
if flags then
- for _, flag in ipairs(flags) do
- -- we need ignore some unused flags in this stub testing
- --
- -- e.g. add_values("verilator.flags", "-GWIDTH=4", "--trace")
- -- error: %Error: Parameters from the command line were not found in the design: WIDTH
- if not flag:startswith("-G") then
+ for idx, flag in ipairs(flags) do
+ if flag:startswith("--") and switches_flags:has(flag:sub(3)) then
table.insert(argv, flag)
+ if flag:startswith("--threads") then
+ table.insert(argv, flags[idx + 1])
+ end
end
end
end
@@ -199,6 +200,9 @@ endmodule]])
if target:is_plat("linux", "macosx") and switches.THREADS == "1" then
target:add("syslinks", "pthread")
end
+ if target:is_plat("linux", "macosx") and switches.TRACE_FST == "1" then
+ target:add("syslinks", "z")
+ end
os.rm(tmpdir)
end
diff --git a/xmake/rules/verilator/xmake.lua b/xmake/rules/verilator/xmake.lua
index cc7a24b27..4272ed91f 100644
--- a/xmake/rules/verilator/xmake.lua
+++ b/xmake/rules/verilator/xmake.lua
@@ -20,7 +20,7 @@
-- @see https://github.com/xmake-io/xmake/issues/3257
rule("verilator.binary")
- set_extensions(".v")
+ set_extensions(".v", ".sv")
on_load(function (target)
target:set("kind", "binary")
end)