diff options
| author | ruki <[email protected]> | 2023-01-12 00:50:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-01-13 20:50:56 +0800 |
| commit | 6b830187bc5feb14a2390aa20e448137a71dd012 (patch) | |
| tree | 9f6b7ddafd64f177ffbfd9c9186f2ee687142127 | |
| parent | 195b23ef65bb65db80d8ba321162636f0357f2f7 (diff) | |
improve iverilog rule
| -rw-r--r-- | tests/projects/embed/iverilog/hello/src/main.v | 4 | ||||
| -rw-r--r-- | tests/projects/embed/iverilog/hello/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/iverilog/xmake.lua | 35 |
3 files changed, 18 insertions, 23 deletions
diff --git a/tests/projects/embed/iverilog/hello/src/main.v b/tests/projects/embed/iverilog/hello/src/main.v index 05e777eee..9661c433e 100644 --- a/tests/projects/embed/iverilog/hello/src/main.v +++ b/tests/projects/embed/iverilog/hello/src/main.v @@ -1,6 +1,8 @@ -module main(); +module hello; initial begin $display("hello world!"); + $dumpfile("hello.vcd"); + $dumpvars(0, hello); $finish ; end endmodule diff --git a/tests/projects/embed/iverilog/hello/xmake.lua b/tests/projects/embed/iverilog/hello/xmake.lua index c876de531..a59478b51 100644 --- a/tests/projects/embed/iverilog/hello/xmake.lua +++ b/tests/projects/embed/iverilog/hello/xmake.lua @@ -1,5 +1,5 @@ add_requires("iverilog") target("hello") - add_rules("iverilog.wave") + add_rules("iverilog.binary") set_toolchains("@iverilog") add_files("src/*.v") diff --git a/xmake/rules/iverilog/xmake.lua b/xmake/rules/iverilog/xmake.lua index 5e19469e1..955c8f762 100644 --- a/xmake/rules/iverilog/xmake.lua +++ b/xmake/rules/iverilog/xmake.lua @@ -18,47 +18,40 @@ -- @file xmake.lua -- -rule("iverilog.wave") +rule("iverilog.binary") set_extensions(".v", ".vhd") on_load(function (target) target:set("kind", "binary") if not target:get("extension") then - target:set("extension", ".vcd") + target:set("extension", ".vvp") end end) on_buildcmd_files(function(target, batchcmds, sourcebatch, opt) + end) + + on_linkcmd(function (target, batchcmds, opt) local toolchain = assert(target:toolchain("iverilog"), 'we need set_toolchains("iverilog") in target("%s")', target:name()) local iverilog = assert(toolchain:config("iverilog"), "iverilog not found!") -- compile wave file local targetfile = target:targetfile() local targetdir = path.directory(targetfile) - local vvpfile = path.join(targetdir, path.basename(targetfile) .. ".vvp") - local argv = {"-o", vvpfile} + local argv = {"-o", targetfile} + local sourcebatch = target:sourcebatches()["iverilog.binary"] local sourcefiles = sourcebatch.sourcefiles - for _, sourcefile in ipairs(sourcefiles) do - batchcmds:show_progress(opt.progress, "${color.build.object}compiling.iverilog %s", path.filename(sourcefile)) - table.insert(argv, path(sourcefile)) - batchcmds:add_depfiles(sourcefile) - end + table.join2(argv, sourcefiles) + batchcmds:show_progress(opt.progress, "${color.build.target}linking.iverilog %s", path.filename(targetfile)) batchcmds:mkdir(targetdir) batchcmds:vrunv(iverilog, argv) - batchcmds:set_depmtime(os.mtime(vvpfile)) - batchcmds:set_depcache(target:dependfile(vvpfile)) + batchcmds:add_depfiles(sourcefiles) + batchcmds:set_depmtime(os.mtime(targetfile)) + batchcmds:set_depcache(target:dependfile(targetfile)) end) - on_linkcmd(function (target, batchcmds, opt) + on_run(function (target) local toolchain = assert(target:toolchain("iverilog"), 'we need set_toolchains("iverilog") in target("%s")', target:name()) local vvp = assert(toolchain:config("vvp"), "vvp not found!") - -- generate wave.lxt - local targetfile = target:targetfile() - local targetdir = path.directory(targetfile) - local vvpfile = path.join(targetdir, path.basename(targetfile) .. ".vvp") - batchcmds:show_progress(opt.progress, "${color.build.target}linking.iverilog %s", path.filename(targetfile)) - batchcmds:vrunv(vvp, {"-n", vvpfile, "-lxt2"}) - batchcmds:add_depfiles(vvpfile) - batchcmds:set_depmtime(os.mtime(targetfile)) - batchcmds:set_depcache(target:dependfile(targetfile)) + os.execv(vvp, {"-n", target:targetfile(), "-lxt2"}) end) |
