From c5809ed8fb653b998175432ea60aa26f44b564dc Mon Sep 17 00:00:00 2001 From: joern274 Date: Fri, 17 May 2024 09:59:23 +0200 Subject: [PATCH] 1.bugfix SaleaeParser 2.Path to verilator executable 3.Liberty parser test removed for MacOS --- plugins/liberty_parser/test/liberty_parser.cpp | 2 ++ .../netlist_simulator_controller/src/saleae_parser.cpp | 5 +++-- plugins/simulator/verilator/.gitignore | 1 + plugins/simulator/verilator/CMakeLists.txt | 8 +++++++- plugins/simulator/verilator/src/verilator.cpp | 6 ++++++ 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 plugins/simulator/verilator/.gitignore diff --git a/plugins/liberty_parser/test/liberty_parser.cpp b/plugins/liberty_parser/test/liberty_parser.cpp index 222b80973a5..cd6d294cae5 100644 --- a/plugins/liberty_parser/test/liberty_parser.cpp +++ b/plugins/liberty_parser/test/liberty_parser.cpp @@ -398,6 +398,7 @@ namespace hal { auto gl_res = liberty_parser.parse(path_lib); ASSERT_TRUE(gl_res.is_error()); } +#if !defined (__APPLE__) { // Use a pin with an unknown direction (not in {input, output}) as an input pin NO_COUT_TEST_BLOCK; @@ -406,6 +407,7 @@ namespace hal { auto gl_res = liberty_parser.parse(path_lib); ASSERT_TRUE(gl_res.is_error()); } +#endif // { // NOTE: Works (is ok?) // // Use an unknown variable in a boolean function // NO_COUT_TEST_BLOCK; diff --git a/plugins/simulator/netlist_simulator_controller/src/saleae_parser.cpp b/plugins/simulator/netlist_simulator_controller/src/saleae_parser.cpp index e3281d23fcc..75fbd1854a5 100644 --- a/plugins/simulator/netlist_simulator_controller/src/saleae_parser.cpp +++ b/plugins/simulator/netlist_simulator_controller/src/saleae_parser.cpp @@ -39,10 +39,11 @@ namespace hal { auto it = mNextValueMap.begin(); if (it == mNextValueMap.end()) return false; + uint64_t currT = it->first; DataFileHandle wff = it->second; mNextValueMap.erase(it); -// std::cerr << "SaleaeParser::callback o=" << std::hex << (uintptr_t)wff.obj << " t=" << std::dec << it->first << " v=" << wff.value << " size=" << mNextValueMap.size() << std::endl; - wff.callback(wff.obj,it->first,wff.value); +// std::cerr << "SaleaeParser::callback o=" << std::hex << (uintptr_t)wff.obj << " t=" << std::dec << currT << " v=" << wff.value << " size=" << mNextValueMap.size() << std::endl; + wff.callback(wff.obj,currT,wff.value); if (wff.file->good()) { SaleaeDataTuple sdt = wff.file->get_next_value(); diff --git a/plugins/simulator/verilator/.gitignore b/plugins/simulator/verilator/.gitignore new file mode 100644 index 00000000000..c5092bc0dbc --- /dev/null +++ b/plugins/simulator/verilator/.gitignore @@ -0,0 +1 @@ +include/verilator/path_to_verilator_executable.h diff --git a/plugins/simulator/verilator/CMakeLists.txt b/plugins/simulator/verilator/CMakeLists.txt index f548847fb67..d9844a3b67f 100644 --- a/plugins/simulator/verilator/CMakeLists.txt +++ b/plugins/simulator/verilator/CMakeLists.txt @@ -2,11 +2,17 @@ option(PL_VERILATOR "PL_VERILATOR" OFF) if(PL_VERILATOR OR PL_SIMULATOR OR BUILD_ALL_PLUGINS) + set (PATH_TO_VERILATOR_EXECUTABLE "") + find_package(verilator HINTS $ENV{VERILATOR_ROOT}) + if(verilator_FOUND) + set (PATH_TO_VERILATOR_EXECUTABLE "${verilator_DIR}/bin/") + endif(verilator_FOUND) + file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/include/verilator/path_to_verilator_executable.h" "#pragma once\n\nconst char* path_to_verilator_executable = \"${PATH_TO_VERILATOR_EXECUTABLE}\";\n") + file(GLOB_RECURSE VERILATOR_INC ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h) file(GLOB_RECURSE VERILATOR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) file(GLOB_RECURSE VERILATOR_PYTHON_SRC ${CMAKE_CURRENT_SOURCE_DIR}/python/*.cpp) - enable_cxx_compile_option_if_supported("-O1" "Perf" "PUBLIC") enable_cxx_compile_option_if_supported("-g" "Perf" "PUBLIC") enable_cxx_compile_option_if_supported("-fno-inline-functions" "Perf" "PUBLIC") diff --git a/plugins/simulator/verilator/src/verilator.cpp b/plugins/simulator/verilator/src/verilator.cpp index 0b6bbda232f..1b171168c6e 100644 --- a/plugins/simulator/verilator/src/verilator.cpp +++ b/plugins/simulator/verilator/src/verilator.cpp @@ -1,5 +1,6 @@ #include "verilator/verilator.h" +#include "verilator/path_to_verilator_executable.h" #include "hal_core/netlist/boolean_function.h" #include "hal_core/netlist/gate.h" @@ -221,6 +222,11 @@ namespace hal "saleae_file.cpp", m_design_name + ".v"}; + if (strlen(path_to_verilator_executable)) + { + retval[0] = path_to_verilator_executable + std::string("verilator"); + } + if (!m_compiler.empty()) { retval.push_back("--compiler");