Skip to content

Commit

Permalink
Merge branch 'feature/word_level_structures' of github.com:emsec/hal …
Browse files Browse the repository at this point in the history
…into feature/word_level_structures
  • Loading branch information
SimonKlx committed Sep 25, 2023
2 parents a16cb51 + dd2530e commit 890bc6e
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 39 deletions.
2 changes: 1 addition & 1 deletion deps/abc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ execute_process(
make
${ABC_READLINE_FLAGS}
${ABC_USE_NAMESPACE_FLAGS}
ARCHFLAGS_EXE=${CMAKE_CURRENT_BINARY_DIR}/abc_arch_flags_program.exe
ABC_USE_STDINT_H=1
ABC_MAKE_NO_DEPS=1
CC=${CMAKE_C_COMPILER}
CXX=${CMAKE_CXX_COMPILER}
Expand Down
2 changes: 1 addition & 1 deletion plugins/boolean_influence/src/plugin_boolean_influence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ int main(int argc, char *argv[]) {
replaced_e = replaced_e.substitute(from_vec, to_vec);

// translate expression into a c program
auto directory_res = utils::get_unique_temp_directory("boolean_influence/");
auto directory_res = utils::get_unique_temp_directory("boolean_influence_");
if (directory_res.is_error())
{
return ERR_APPEND(directory_res.get_error(), "unable to generate Boolean influence: could not create temporary directory");
Expand Down
86 changes: 82 additions & 4 deletions plugins/edif_parser/src/edif_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,84 @@ namespace hal
}
}

// process instances i.e. gates or other cells
for (const auto& instance : cell->m_instances)
{
// will later hold either module or gate, so attributes can be assigned properly
DataContainer* container = nullptr;

// assign actual signal names to ports
std::unordered_map<std::string, std::string> instance_assignments;

// if the instance is another cell (i.e., not a gate type) of the same library, recursively instantiate it
if (const auto gate_type_it = m_gate_types.find(instance->m_cell->m_name); gate_type_it == m_gate_types.end())
{
// expand port assignments
for (const auto& port_assignment : instance->m_cell->m_internal_port_assignments)
{
const auto& assignment = port_assignment.m_expanded_net_name;
auto port_name = port_assignment.m_port->m_name;
if (port_assignment.m_index != -1)
{
port_name += "(" + std::to_string(port_assignment.m_index) + ")";
}

if (const auto alias_it = signal_alias.find(assignment); alias_it != signal_alias.end())
{
instance_assignments[port_name] = alias_it->second;
}
else
{
return ERR("could not create instance '" + instance_name + "' of type '" + instance_type + "': port assignment '" + port_name + " = " + assignment + "' is invalid");
}
}

if (auto res = instantiate_module(instance->m_name, instance->m_cell, module, instance_assignments); res.is_error())
{
return ERR_APPEND(res.get_error(),
"could not create instance '" + instance_name + "' of type '" + instance_type + "': unable to create instance '" + instance->m_name + "' of type '"
+ instance->m_cell->m_name + "'");
}
else
{
container = res.get();
}
}
// otherwise it has to be an element from the gate library
else
{
// create the new gate
instance_alias[instance->m_name] = get_unique_alias(module->get_name(), instance->m_name, m_instance_name_occurences);

Gate* new_gate = m_netlist->create_gate(gate_type_it->second, instance_alias.at(instance->m_name));
if (new_gate == nullptr)
{
return ERR("could not create instance '" + instance_name + "' of type '" + instance_type + "': failed to create gate '" + instance->m_name + "'");
}

if (!module->is_top_module())
{
module->assign_gate(new_gate);
}

container = new_gate;

// if gate is of a GND or VCC gate type, mark it as such
if (m_vcc_gate_types.find(instance->m_type) != m_vcc_gate_types.end() && !new_gate->mark_vcc_gate())
{
return ERR("could not create instance '" + instance_name + "' of type '" + instance_type + "': failed to mark '" + instance->m_name + "' of type '" + instance->m_type
+ "' as GND gate");
}
if (m_gnd_gate_types.find(instance->m_type) != m_gnd_gate_types.end() && !new_gate->mark_gnd_gate())
{
return ERR("could not create instance '" + instance_name + "' of type '" + instance_type + "': failed to mark '" + instance->m_name + "' of type '" + instance->m_type
+ "' as VCC gate");
}

// TODO implement rest
}
}

// TODO create instances and assign nets

return ERR("not implemented");
Expand All @@ -1100,10 +1178,10 @@ namespace hal
{
return ERR("could not parse instance in line " + std::to_string(old_name.number) + ": renaming not yet supported");
}
else
{
log_warning("edif_parser", "renaming not yet supported, ignoring old name in line {}", old_name.number);
}
// else
// {
// log_warning("edif_parser", "renaming not yet supported, ignoring old name in line {}", old_name.number);
// }
}

return OK(new_name);
Expand Down
2 changes: 1 addition & 1 deletion plugins/hgl_parser/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if(BUILD_TESTS)

add_executable(runTest-hgl_parser hgl_parser.cpp)

target_link_libraries(runTest-hgl_parser hgl_parser pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-hgl_parser hgl_parser gtest hal::core hal::netlist test_utils)

add_test(runTest-hgl_parser ${CMAKE_BINARY_DIR}/bin/hal_plugins/runTest-hgl_parser --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)

Expand Down
2 changes: 1 addition & 1 deletion plugins/hgl_writer/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(BUILD_TESTS)

add_executable(runTest-hgl_writer hgl_writer.cpp)

target_link_libraries(runTest-hgl_writer hgl_writer hgl_parser pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-hgl_writer hgl_writer hgl_parser gtest hal::core hal::netlist test_utils)

add_test(runTest-hgl_writer ${CMAKE_BINARY_DIR}/bin/hal_plugins/runTest-hgl_writer --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)

Expand Down
2 changes: 1 addition & 1 deletion plugins/liberty_parser/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if(BUILD_TESTS)

add_executable(runTest-liberty_parser liberty_parser.cpp)

target_link_libraries(runTest-liberty_parser liberty_parser pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-liberty_parser liberty_parser gtest hal::core hal::netlist test_utils)

add_test(runTest-liberty_parser ${CMAKE_BINARY_DIR}/bin/hal_plugins/runTest-liberty_parser --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)

Expand Down
2 changes: 1 addition & 1 deletion plugins/netlist_preprocessing/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if(BUILD_TESTS)

add_executable(runTest-netlist_preprocessing netlist_preprocessing.cpp)

target_link_libraries(runTest-netlist_preprocessing netlist_preprocessing pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-netlist_preprocessing netlist_preprocessing gtest hal::core hal::netlist test_utils)

add_test(runTest-netlist_preprocessing ${CMAKE_BINARY_DIR}/bin/hal_plugins/runTest-netlist_preprocessing --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)

Expand Down
2 changes: 1 addition & 1 deletion plugins/verilog_parser/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if(BUILD_TESTS)

add_executable(runTest-verilog_parser verilog_parser.cpp)

target_link_libraries(runTest-verilog_parser verilog_parser pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-verilog_parser verilog_parser gtest hal::core hal::netlist test_utils)

add_test(runTest-verilog_parser ${CMAKE_BINARY_DIR}/bin/hal_plugins/runTest-verilog_parser --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)

Expand Down
2 changes: 1 addition & 1 deletion plugins/verilog_writer/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(BUILD_TESTS AND ((PL_VERILOG_PARSER) OR BUILD_ALL_PLUGINS))

add_executable(runTest-verilog_writer verilog_writer.cpp)

target_link_libraries(runTest-verilog_writer verilog_writer verilog_parser pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-verilog_writer verilog_writer verilog_parser gtest hal::core hal::netlist test_utils)

add_test(runTest-verilog_writer ${CMAKE_BINARY_DIR}/bin/hal_plugins/runTest-verilog_writer --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)

Expand Down
2 changes: 1 addition & 1 deletion plugins/vhdl_parser/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if(BUILD_TESTS)

add_executable(runTest-vhdl_parser vhdl_parser.cpp)

target_link_libraries(runTest-vhdl_parser vhdl_parser pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-vhdl_parser vhdl_parser gtest hal::core hal::netlist test_utils)

add_test(runTest-vhdl_parser ${CMAKE_BINARY_DIR}/bin/hal_plugins/runTest-vhdl_parser --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)

Expand Down
2 changes: 1 addition & 1 deletion plugins/z3_utils/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if(BUILD_TESTS)

add_executable(runTest-z3_utils z3_utils.cpp)

target_link_libraries(runTest-z3_utils z3_utils pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-z3_utils z3_utils gtest hal::core hal::netlist test_utils)

add_test(runTest-z3_utils ${CMAKE_BINARY_DIR}/bin/hal_plugins/runTest-z3_utils --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)

Expand Down
14 changes: 7 additions & 7 deletions tests/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ add_executable(runTest-plugin_manager
add_executable(runTest-result
result.cpp)

target_link_libraries(runTest-callback_hook pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-log pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-program_arguments pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-program_options pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-utils pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-plugin_manager pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-result pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-callback_hook gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-log gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-program_arguments gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-program_options gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-utils gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-plugin_manager gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-result gtest hal::core hal::netlist test_utils)


add_test(runTest-callback_hook_test ${CMAKE_BINARY_DIR}/bin/runTest-callback_hook --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)
Expand Down
30 changes: 15 additions & 15 deletions tests/netlist/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ add_executable(runTest-gate_library gate_library.cpp)
add_executable(runTest-netlist_utils netlist_utils.cpp)
add_executable(runTest-decorators decorators.cpp)

target_link_libraries(runTest-netlist pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-gate_type pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-gate pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-net pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-data_container pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-endpoint pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-module pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-grouping pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-netlist_factory pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-gate_library_manager pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-netlist_serializer pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-boolean_function pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-gate_library pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-netlist_utils pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-decorators pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-netlist gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-gate_type gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-gate gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-net gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-data_container gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-endpoint gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-module gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-grouping gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-netlist_factory gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-gate_library_manager gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-netlist_serializer gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-boolean_function gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-gate_library gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-netlist_utils gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-decorators gtest hal::core hal::netlist test_utils)

add_test(runTest-netlist ${CMAKE_BINARY_DIR}/bin/runTest-netlist --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)
add_test(runTest-gate_type ${CMAKE_BINARY_DIR}/bin/runTest-gate_type --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)
Expand Down
2 changes: 1 addition & 1 deletion tests/netlist_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/tests)

add_executable(runTest-netlist_parser_manager netlist_parser_manager.cpp)
target_link_libraries(runTest-netlist_parser_manager pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-netlist_parser_manager gtest hal::core hal::netlist test_utils)
add_test(runTest-netlist_parser_manager ${CMAKE_BINARY_DIR}/bin/runTest-netlist_parser_manager --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
Expand Down
2 changes: 1 addition & 1 deletion tests/netlist_writer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/tests)

add_executable(runTest-netlist_writer_manager netlist_writer_manager.cpp)
target_link_libraries(runTest-netlist_writer_manager pthread gtest hal::core hal::netlist test_utils)
target_link_libraries(runTest-netlist_writer_manager gtest hal::core hal::netlist test_utils)
add_test(runTest-netlist_writer_manager ${CMAKE_BINARY_DIR}/bin/runTest-netlist_writer_manager --gtest_output=xml:${CMAKE_BINARY_DIR}/gtestresults-runBasicTests.xml)

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gate_libraries/test.hgl ${CMAKE_BINAR

target_include_directories(test_utils PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")

target_link_libraries(test_utils pthread gtest hal::core hal::netlist)
target_link_libraries(test_utils gtest hal::core hal::netlist)

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_sanitizers(test_utils)
Expand Down

0 comments on commit 890bc6e

Please sign in to comment.