This commit is contained in:
parent
621de301c7
commit
540cd772e4
|
|
@ -145,6 +145,10 @@ After running Make, the C++ compiler may produce the following:
|
|||
- Intermediate objects
|
||||
* - *{prefix}*\
|
||||
- Final executable (from --exe)
|
||||
* - lib\ *{prefix}*\ .a
|
||||
- Final archive (default lib mode)
|
||||
* - libverilated.a
|
||||
- Runtime for verilated model (default lib mode)
|
||||
* - *{prefix}*\ __ALL.a
|
||||
- Library of all Verilated objects
|
||||
* - *{prefix}*\ __ALL.cpp
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ public:
|
|||
} else if (!v3Global.opt.libCreate().empty()) {
|
||||
of.puts("default: lib" + v3Global.opt.libCreate() + "\n");
|
||||
} else {
|
||||
of.puts("default: " + v3Global.opt.prefix() + "__ALL.a\n");
|
||||
of.puts("default: lib" + v3Global.opt.prefix() + "\n");
|
||||
}
|
||||
of.puts("\n### Constants...\n");
|
||||
of.puts("# Perl executable (from $PERL)\n");
|
||||
|
|
@ -239,13 +239,12 @@ public:
|
|||
|
||||
if (v3Global.opt.exe()) {
|
||||
of.puts("\n### Link rules... (from --exe)\n");
|
||||
// let default rule depend on '{prefix}__ALL.a', for compatibility
|
||||
of.puts(v3Global.opt.exeName()
|
||||
+ ": $(VK_USER_OBJS) $(VK_GLOBAL_OBJS) $(VM_PREFIX)__ALL.a $(VM_HIER_LIBS)\n");
|
||||
of.puts("\t$(LINK) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) $(LIBS) $(SC_LIBS) -o $@\n");
|
||||
of.puts("\n");
|
||||
}
|
||||
|
||||
if (!v3Global.opt.libCreate().empty()) {
|
||||
} else if (!v3Global.opt.libCreate().empty()) {
|
||||
const string libCreateDeps = "$(VK_OBJS) $(VK_USER_OBJS) $(VK_GLOBAL_OBJS) "
|
||||
+ v3Global.opt.libCreate() + ".o $(VM_HIER_LIBS)";
|
||||
of.puts("\n### Library rules from --lib-create\n");
|
||||
|
|
@ -272,6 +271,15 @@ public:
|
|||
of.puts("lib" + v3Global.opt.libCreate() + ": " + v3Global.opt.libCreateName(false)
|
||||
+ " " + v3Global.opt.libCreateName(true) + "\n");
|
||||
}
|
||||
} else {
|
||||
const string libname = "lib" + v3Global.opt.prefix() + ".a";
|
||||
of.puts("\n### Library rules (default lib mode)\n");
|
||||
// The rule to create .a is defined in verilated.mk, so just define dependency here.
|
||||
of.puts(libname + ": $(VK_OBJS) $(VK_USER_OBJS) $(VM_HIER_LIBS)\n");
|
||||
of.puts("libverilated.a: $(VK_GLOBAL_OBJS)\n");
|
||||
// let default rule depend on '{prefix}__ALL.a', for compatibility
|
||||
of.puts("lib" + v3Global.opt.prefix() + ": " + libname
|
||||
+ " libverilated.a $(VM_PREFIX)__ALL.a\n");
|
||||
}
|
||||
|
||||
of.puts("\n");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
||||
//*************************************************************************
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2023 by Shupei Fan.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
//
|
||||
//*************************************************************************
|
||||
|
||||
#include "Vt_flag_lib_dpi__Dpi.h"
|
||||
#include "svdpi.h"
|
||||
|
||||
#include <iostream>
|
||||
void write_all_finished() { std::cout << "*-* All Finished *-*" << std::endl; }
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# DESCRIPTION: Verilator: Makefile for Verilog Test module
|
||||
#
|
||||
# This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
# any use, without warranty, 2023 by Shupei Fan.
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
include Vt_flag_lib_dpi.mk
|
||||
|
||||
t_flag_lib_dpi_test: libVt_flag_lib_dpi.a libverilated.a
|
||||
$(LINK) $(LDFLAGS) $^ $(LDLIBS) -o $@
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
# any use, without warranty, 2023 by Shupei Fan.
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
scenarios(vlt => 1);
|
||||
|
||||
run(logfile => "$Self->{obj_dir}/vlt_compile.log",
|
||||
cmd => ["perl",
|
||||
"$ENV{VERILATOR_ROOT}/bin/verilator",
|
||||
"-cc",
|
||||
"--build",
|
||||
'--no-timing',
|
||||
"-Mdir",
|
||||
"$Self->{obj_dir}",
|
||||
"t/t_flag_lib_dpi.v",
|
||||
"$Self->{t_dir}/t_flag_lib_dpi.cpp",
|
||||
"$Self->{t_dir}/t_flag_lib_dpi_main.cpp"],
|
||||
verilator_run => 1,
|
||||
);
|
||||
|
||||
run(logfile => "$Self->{obj_dir}/cxx_compile.log",
|
||||
cmd => ["cd $Self->{obj_dir}"
|
||||
. " && cp $Self->{t_dir}/t_flag_lib_dpi.mk t_flag_lib_dpi.mk"
|
||||
. " && $ENV{MAKE} -f t_flag_lib_dpi.mk t_flag_lib_dpi_test"
|
||||
. " && ./t_flag_lib_dpi_test"],
|
||||
check_finished => 1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2023 by Shupei Fan.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
import "DPI-C" function void write_all_finished();
|
||||
|
||||
module t (/*AUTOARG*/);
|
||||
|
||||
initial begin
|
||||
write_all_finished;
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
||||
//*************************************************************************
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2023 by Shupei Fan.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
//
|
||||
//*************************************************************************
|
||||
//
|
||||
// DESCRIPTION: main() calling loop, created with Verilator --main
|
||||
|
||||
#include "verilated.h"
|
||||
|
||||
#include "Vt_flag_lib_dpi.h"
|
||||
|
||||
//======================
|
||||
|
||||
int main(int argc, char** argv, char**) {
|
||||
// Setup context, defaults, and parse command line
|
||||
Verilated::debug(0);
|
||||
const std::unique_ptr<VerilatedContext> contextp{new VerilatedContext};
|
||||
contextp->commandArgs(argc, argv);
|
||||
|
||||
// Construct the Verilated model, from Vtop.h generated from Verilating
|
||||
const std::unique_ptr<Vt_flag_lib_dpi> topp{new Vt_flag_lib_dpi{contextp.get()}};
|
||||
|
||||
// Simulate until $finish
|
||||
while (!contextp->gotFinish()) {
|
||||
// Evaluate model
|
||||
topp->eval();
|
||||
// Advance time
|
||||
contextp->timeInc(1);
|
||||
}
|
||||
|
||||
if (!contextp->gotFinish()) {
|
||||
VL_DEBUG_IF(VL_PRINTF("+ Exiting without $finish; no events left\n"););
|
||||
}
|
||||
|
||||
// Final model cleanup
|
||||
topp->final();
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue