Skip to content

Commit

Permalink
Merge branch 'master' into feature/hawkeye
Browse files Browse the repository at this point in the history
  • Loading branch information
SJulianS committed May 21, 2024
2 parents 2312184 + d42c005 commit 212aff6
Show file tree
Hide file tree
Showing 16 changed files with 129 additions and 46 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,18 @@ jobs:
run: |
mkdir -p build
cd build
export PATH="/usr/local/opt/qt@5/bin:$PATH"
ls ..
cmake -G Ninja .. -DQt5_DIR=/usr/local/opt/qt@5/lib/cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_ALL_PLUGINS=ON -DBUILD_TESTS=ON -DPL_GUI=ON -DCMAKE_C_COMPILER=/usr/local/opt/llvm@14/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@14/bin/clang++
export PATH="$(brew --prefix qt@5)/bin:$PATH"
brew ls llvm@14
brew --prefix llvm@14
ls -l /usr/local
ls -l /opt/homebrew/opt
ls -l /opt/homebrew/opt/llvm@14
ls -l /opt/homebrew/opt/llvm@14/bin
ls -l /opt/homebrew/opt/llvm@14/bin/clang
cmake -G Ninja .. -DQt5_DIR="$(brew --prefix qt@5)/lib/cmake" -DCMAKE_BUILD_TYPE=Debug -DBUILD_ALL_PLUGINS=ON -DBUILD_TESTS=ON -DPL_GUI=ON -DCMAKE_C_COMPILER=$(brew --prefix llvm@14)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@14)/bin/clang++
env:
LDFLAGS: "-L/usr/local/opt/qt@5/lib -L/usr/local/opt/llvm@14/lib -Wl,-rpath,/usr/local/opt/llvm@14/lib"
CPPFLAGS: "-I/usr/local/opt/llvm@14/include"
LDFLAGS: "-L$(brew --prefix qt@5)/lib -L$(brew --prefix llvm@14)/lib -Wl,-rpath,$(brew --prefix llvm@14)/lib"
CPPFLAGS: "-I$(brew --prefix llvm@14)/include"
HAL_BASE_PATH: ${{runner.workspace}}/hal/build
CCACHE_DIR: ${{runner.workspace}}/.ccache
CCACHE_COMPRESS: true
Expand All @@ -107,12 +113,12 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: |
cd build
export PATH="/usr/local/opt/qt/bin:$PATH"
export PATH="$(brew --prefix qt@5)/bin:$PATH"
export BUILD_TYPE=Debug
cmake --build . --target all --clean-first --config $BUILD_TYPE
env:
LDFLAGS: "-L/usr/local/opt/qt@5/lib -L/usr/local/opt/llvm@14/lib -Wl,-rpath,/usr/local/opt/llvm@14/lib"
CPPFLAGS: "-I/usr/local/opt/llvm@14/include"
LDFLAGS: "-L$(brew --prefix qt@5)/lib -L$(brew --prefix llvm@14)/lib -Wl,-rpath,$(brew --prefix llvm@14)/lib"
CPPFLAGS: "-I$(brew --prefix llvm@14)/include"
HAL_BASE_PATH: ${{runner.workspace}}/hal/build
CCACHE_DIR: ${{runner.workspace}}/.ccache
CCACHE_COMPRESS: true
Expand All @@ -133,8 +139,8 @@ jobs:
# ninja -v hal_coverage
# bash <(curl -s https://codecov.io/bash) -f hal_coverage.info.cleaned || echo "Codecov did not collect coverage reports"
env:
LDFLAGS: "-L/usr/local/opt/qt@5/lib -L/usr/local/opt/llvm@14/lib -Wl,-rpath,/usr/local/opt/llvm@14/lib"
CPPFLAGS: "-I/usr/local/opt/llvm@14/include"
LDFLAGS: "-L$(brew --prefix qt@5)/lib -L$(brew --prefix llvm@14)/lib -Wl,-rpath,$(brew --prefix llvm@14)/lib"
CPPFLAGS: "-I$(brew --prefix llvm@14)/include"
HAL_BASE_PATH: ${{runner.workspace}}/hal/build
CCACHE_DIR: ${{runner.workspace}}/.ccache
CCACHE_COMPRESS: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ubuntu 20.04
name: Ubuntu 24.04

on:
push:
Expand All @@ -7,13 +7,13 @@ on:
# - v*

jobs:
build_ubuntu_20_04:
name: Build and Test on Ubuntu 20.04
build_ubuntu_24_04:
name: Build and Test on Ubuntu 24.04

strategy:
matrix:
# runs-on: [ ubuntu-20.04, macOS-latest]
runs-on: [ ubuntu-20.04 ]
# runs-on: [ ubuntu-22.04, macOS-latest]
runs-on: [ ubuntu-24.04 ]
fail-fast: false

runs-on: ${{ matrix.runs-on }}
Expand Down
2 changes: 1 addition & 1 deletion include/hal_core/netlist/pins/pin_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ namespace hal
* @param[in] pin - The pin.
* @returns The index of the pin on success, an error message otherwise.
*/
Result<u32> get_index(const T* pin) const
Result<i32> get_index(const T* pin) const
{
if (pin == nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/graph_algorithm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ if(PL_GRAPH_ALGORITHM OR BUILD_ALL_PLUGINS)

add_dependencies(graph_algorithm igraph_0_10)

endif()
endif()
3 changes: 2 additions & 1 deletion plugins/liberty_parser/src/liberty_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ namespace hal
{
return ERR("could not parse pin: invalid pin direction '" + direction_str + "' (line " + std::to_string(pin.line_number) + ")");
}

pin_str.consume(";", true);
}
else if (next_token == "function")
Expand Down Expand Up @@ -1314,4 +1315,4 @@ namespace hal

return OK(res);
}
} // namespace hal
} // namespace hal
2 changes: 2 additions & 0 deletions plugins/liberty_parser/test/liberty_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1290,20 +1290,20 @@ namespace hal {

mTimeframe.setSceneMaxTime(tmax);
if (mustUpdateClocks) updateClocks();
qDebug() << "setMaxTime-Tfc" << mTimeframe.sceneMaxTime();
// qDebug() << "setMaxTime-Tfc" << mTimeframe.sceneMaxTime();
Q_EMIT timeframeChanged(&mTimeframe);
}

void WaveDataList::emitTimeframeChanged()
{
qDebug() << "emitTimeframeChanged-Tfc" << mTimeframe.sceneMaxTime();
// qDebug() << "emitTimeframeChanged-Tfc" << mTimeframe.sceneMaxTime();
Q_EMIT timeframeChanged(&mTimeframe);
}

void WaveDataList::incrementSimulTime(u64 deltaT)
{
mTimeframe.mSimulateMaxTime += deltaT;
qDebug() << "incrementSimulTime-Tfc" << mTimeframe.mSimulateMaxTime << ">" << mTimeframe.mSceneMaxTime;
// qDebug() << "incrementSimulTime-Tfc" << mTimeframe.mSimulateMaxTime << ">" << mTimeframe.mSceneMaxTime;
if (mTimeframe.mSimulateMaxTime > mTimeframe.mSceneMaxTime)
setMaxTime(mTimeframe.mSimulateMaxTime);
}
Expand All @@ -1323,7 +1323,7 @@ namespace hal {
wd->clear();
}
}
qDebug() << "setUserTimeframe-Tfc" << mTimeframe.sceneMaxTime();
// qDebug() << "setUserTimeframe-Tfc" << mTimeframe.sceneMaxTime();
Q_EMIT timeframeChanged(&mTimeframe);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ namespace hal
plugin_manager::unload_all_plugins();
}

void dump_engine_log(std::string directory)
{
std::cout << std::endl;
std::ifstream ff(directory + "/engine_log.html");
while (ff.good())
{
std::string line;
std::getline(ff,line);
std::cout << line << std::endl;
}
}

bool cmp_sim_data(NetlistSimulatorController* reference_simulation_ctrl, NetlistSimulatorController* simulation_ctrl, int tolerance = 200)
{
bool no_errors = true;
Expand Down Expand Up @@ -429,6 +441,7 @@ namespace hal
}
if (verilator_engine->get_state() == SimulationEngine::State::Failed)
{
dump_engine_log(verilator_engine->get_working_directory());
FAIL() << "engine failed";
}

Expand Down Expand Up @@ -545,6 +558,7 @@ namespace hal

if (verilator_engine->get_state() == SimulationEngine::State::Failed)
{
dump_engine_log(verilator_engine->get_working_directory());
FAIL() << "engine failed";
}

Expand Down Expand Up @@ -719,6 +733,7 @@ namespace hal

if (verilator_engine->get_state() == SimulationEngine::State::Failed)
{
dump_engine_log(verilator_engine->get_working_directory());
FAIL() << "engine failed";
}

Expand Down Expand Up @@ -877,6 +892,7 @@ namespace hal
if (verilator_engine->get_state() == SimulationEngine::State::Failed)
{
dump_engine_log(verilator_engine->get_working_directory());
FAIL() << "engine failed";
}
Expand Down Expand Up @@ -1333,6 +1349,7 @@ namespace hal

if (verilator_engine->get_state() == SimulationEngine::State::Failed)
{
dump_engine_log(verilator_engine->get_working_directory());
FAIL() << "engine failed";
}

Expand Down
1 change: 1 addition & 0 deletions plugins/simulator/verilator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include/verilator/path_to_verilator_executable.h
29 changes: 28 additions & 1 deletion plugins/simulator/verilator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,38 @@ 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)

set (PATH_TO_RAPIDJSON_INCLUDEDIR ${RAPIDJSON_INCLUDEDIR})
if (NOT PATH_TO_RAPIDJSON_INCLUDEDIR)
find_package(RapidJSON REQUIRED)
if(RapidJSON_FOUND AND NOT TARGET RapidJSON::RapidJSON)
if(NOT RAPIDJSON_INCLUDEDIR)
set(RAPIDJSON_INCLUDEDIR ${RAPIDJSON_INCLUDE_DIRS})
endif()

# fix for macOS if most recent version
if(NOT RAPIDJSON_INCLUDEDIR)
set(RAPIDJSON_INCLUDEDIR ${RapidJSON_INCLUDE_DIRS})
endif()
set (PATH_TO_RAPIDJSON_INCLUDEDIR ${RAPIDJSON_INCLUDEDIR})
endif(RapidJSON_FOUND)
endif()

file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/include/verilator/path_to_verilator_executable.h" "\
#pragma once\n\
\n\
const char* path_to_verilator_executable = \"${PATH_TO_VERILATOR_EXECUTABLE}\";\n\
const char* path_to_rapidjson_includedir = \"${PATH_TO_RAPIDJSON_INCLUDEDIR}\";\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")
Expand Down
25 changes: 19 additions & 6 deletions plugins/simulator/verilator/src/verilator.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -190,10 +191,12 @@ namespace hal
switch (lineIndex)
{
case 0: {
std::vector<std::string> retval = {"verilator",
"-I.",
"-Wall",
"-Wno-fatal",
std::vector<std::string> retval = {"verilator", // 0
"-I.", // 1
"-Wall", // 2
"-Wno-fatal", // 3
"-CFLAGS", // 4
"-O3", // 5
"--MMD",
"-trace",
// "--trace-threads",
Expand All @@ -206,8 +209,6 @@ namespace hal
"obj_dir",
"-O3",
"--noassert",
"-CFLAGS",
"-O3",
"--exe",
"-cc",
"-DSIM_VERILATOR",
Expand All @@ -221,6 +222,18 @@ namespace hal
"saleae_file.cpp",
m_design_name + ".v"};

#if defined(__APPLE__)
if (strlen(path_to_verilator_executable))
{
retval[0] = path_to_verilator_executable + std::string("verilator");
}
#endif

if (strlen(path_to_rapidjson_includedir))
{
retval[5] = retval[5] + " -I" + path_to_rapidjson_includedir;
}

if (!m_compiler.empty())
{
retval.push_back("--compiler");
Expand Down
2 changes: 2 additions & 0 deletions plugins/verilog_parser/test/verilog_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3195,6 +3195,7 @@ namespace hal {
EXPECT_TRUE(nl_res.is_error());
}
// ------ Verilog specific tests ------
#if !defined(__APPLE__)
{
// The Module has no identifier
NO_COUT_TEST_BLOCK;
Expand Down Expand Up @@ -3246,6 +3247,7 @@ namespace hal {
auto nl_res = verilog_parser.parse_and_instantiate(verilog_file, gate_lib);
EXPECT_TRUE(nl_res.is_error());
}
#endif
if(test_utils::known_issue_tests_active())
{
// one side of the direct assignment is empty
Expand Down
4 changes: 2 additions & 2 deletions src/netlist/decorators/boolean_function_net_decorator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace hal

try
{
return OK(std::stoul(var_name.substr(VAR_NET_PREFIX.size())));
return OK((u32) std::stoul(var_name.substr(VAR_NET_PREFIX.size())));
}
catch (const std::invalid_argument& e)
{
Expand Down Expand Up @@ -99,4 +99,4 @@ namespace hal
return ERR_APPEND(var_name_res.get_error(), "could not get net from Boolean function '" + var.to_string() + "': unable to get variable name");
}
}
} // namespace hal
} // namespace hal
2 changes: 1 addition & 1 deletion src/netlist/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace hal
{
if (utils::trim(name).empty())
{
log_error("module", "module name cannot be empty.");
log_warning("module", "module name cannot be empty.");
return;
}
if (name != m_name)
Expand Down
Loading

0 comments on commit 212aff6

Please sign in to comment.