diff --git a/CMakeLists.txt b/CMakeLists.txt index b3dd546..4974c54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,9 @@ if(NOT DEFINED VERILATOR_ROOT) set(ENV{VERILATOR_ROOT} "/home/blur/gits/verilator") endif() +# 设置 Verilator 头文件目录 +include_directories($ENV{VERILATOR_ROOT}/include) + # 设置编译器参数 if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") message("Turn On Debugger") @@ -52,8 +55,6 @@ set(LACPU lacpu) set(LAVSIM lavsim) set(LA_VSIM_TARGET ${PROJECT_NAME}-vsim) -include_directories(${verilator_DIR}/include) - find_package(verilator HINTS $ENV{VERILATOR_ROOT} ${VERILATOR_ROOT}) if (NOT verilator_FOUND) diff --git a/lavsim/main.cc b/lavsim/main.cc index f2df7b5..4576bd9 100644 --- a/lavsim/main.cc +++ b/lavsim/main.cc @@ -18,18 +18,15 @@ int main(int argc, char** argv) { // real project, it is better to start with a more complete example, // e.g. examples/c_tracing. - // Construct a VerilatedContext to hold simulation time, etc. - VerilatedContext* contextp = new VerilatedContext; - // Pass arguments so Verilated code can see them, e.g. $value$plusargs // This needs to be called before you create any model - contextp->commandArgs(argc, argv); + Verilated::commandArgs(argc, argv); // Construct the Verilated model, from Vtop.h generated from Verilating "top.v" - Vtop* top = new Vtop{contextp}; + Vtop* top = new Vtop(); // Simulate until $finish - while (!contextp->gotFinish()) { + while (!Verilated::gotFinish()) { // Evaluate model top->eval();