5 Commits

31 changed files with 687 additions and 5238 deletions

1
.gitignore vendored
View File

@ -30,6 +30,5 @@ language.settings.xml
/.gdbinit /.gdbinit
/*.out /*.out
/dump.json /dump.json
/src-gen/
/*.yaml /*.yaml
/*.json /*.json

View File

@ -29,32 +29,35 @@ endif()
add_subdirectory(softfloat) add_subdirectory(softfloat)
# library files # library files
FILE(GLOB TGC_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/iss/*.cpp) FILE(GLOB GEN_SOURCES
FILE(GLOB TGC_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/interp/vm_*.cpp) ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/interp/vm_*.cpp
)
set(LIB_SOURCES set(LIB_SOURCES
src/vm/fp_functions.cpp src/vm/fp_functions.cpp
src/plugin/instruction_count.cpp src/iss/plugin/instruction_count.cpp
src/iss/arch/tgc_c.cpp
${TGC_SOURCES} src/vm/interp/vm_tgc_c.cpp
${TGC_VM_SOURCES} src/vm/fp_functions.cpp
${GEN_SOURCES}
) )
if(TARGET RapidJSON) if(TARGET RapidJSON)
list(APPEND LIB_SOURCES src/plugin/cycle_estimate.cpp src/plugin/pctrace.cpp) list(APPEND LIB_SOURCES src/iss/plugin/cycle_estimate.cpp src/iss/plugin/pctrace.cpp)
endif() endif()
if(WITH_LLVM) if(WITH_LLVM)
FILE(GLOB TGC_LLVM_SOURCES FILE(GLOB LLVM_GEN_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/vm/llvm/vm_*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/llvm/vm_*.cpp
) )
list(APPEND LIB_SOURCES ${TGC_LLVM_SOURCES}) list(APPEND LIB_SOURCES ${LLVM_GEN_SOURCES})
endif() endif()
if(WITH_TCC) if(WITH_TCC)
FILE(GLOB TGC_TCC_SOURCES FILE(GLOB TCC_GEN_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/vm/tcc/vm_*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/tcc/vm_*.cpp
) )
list(APPEND LIB_SOURCES ${TGC_TCC_SOURCES}) list(APPEND LIB_SOURCES ${TCC_GEN_SOURCES})
endif() endif()
# Define the library # Define the library
@ -69,7 +72,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE /wd4293) target_compile_options(${PROJECT_NAME} PRIVATE /wd4293)
endif() endif()
target_include_directories(${PROJECT_NAME} PUBLIC incl) target_include_directories(${PROJECT_NAME} PUBLIC src)
target_include_directories(${PROJECT_NAME} PUBLIC src-gen)
target_link_libraries(${PROJECT_NAME} PUBLIC softfloat scc-util jsoncpp Boost::coroutine) target_link_libraries(${PROJECT_NAME} PUBLIC softfloat scc-util jsoncpp Boost::coroutine)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-rise-core -Wl,--no-whole-archive) target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-rise-core -Wl,--no-whole-archive)

View File

@ -37,9 +37,9 @@ def getRegisterSizes(){
return regs return regs
} }
%> %>
#include "${coreDef.name.toLowerCase()}.h"
#include "util/ities.h" #include "util/ities.h"
#include <util/logging.h> #include <util/logging.h>
#include <iss/arch/${coreDef.name.toLowerCase()}.h>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>

View File

@ -36,7 +36,7 @@ def nativeTypeSize(int size){
if(size<=8) return 8; else if(size<=16) return 16; else if(size<=32) return 32; else return 64; if(size<=8) return 8; else if(size<=16) return 16; else if(size<=32) return 32; else return 64;
} }
%> %>
#include "../fp_functions.h" #include <vm/fp_functions.h>
#include <iss/arch/${coreDef.name.toLowerCase()}.h> #include <iss/arch/${coreDef.name.toLowerCase()}.h>
#include <iss/arch/riscv_hart_m_p.h> #include <iss/arch/riscv_hart_m_p.h>
#include <iss/debugger/gdb_session.h> #include <iss/debugger/gdb_session.h>
@ -314,11 +314,9 @@ typename vm_base<ARCH>::virt_addr_t vm_impl<ARCH>::execute_inst(finish_cond_e co
<%}}%>// calculate next pc value <%}}%>// calculate next pc value
*NEXT_PC = *PC + ${instr.length/8}; *NEXT_PC = *PC + ${instr.length/8};
// execute instruction // execute instruction
try {
<%instr.behavior.eachLine{%>${it} <%instr.behavior.eachLine{%>${it}
<%}%>} catch(...){} <%}%>TRAP_${instr.name}:break;
} }// @suppress("No break at end of case")<%}%>
break;<%}%>
default: { default: {
*NEXT_PC = *PC + ((instr & 3) == 3 ? 4 : 2); *NEXT_PC = *PC + ((instr & 3) == 3 ? 4 : 2);
raise(0, 2); raise(0, 2);

View File

@ -1 +0,0 @@
/tgc_*.h

2
src-gen/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/iss
/vm

View File

@ -30,9 +30,9 @@
* *
*******************************************************************************/ *******************************************************************************/
#include "tgc_c.h"
#include "util/ities.h" #include "util/ities.h"
#include <util/logging.h> #include <util/logging.h>
#include <iss/arch/tgc_c.h>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>

View File

@ -4,39 +4,44 @@
#include "riscv_hart_m_p.h" #include "riscv_hart_m_p.h"
#include "tgc_c.h" #include "tgc_c.h"
using tgc_c_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_c>; using tgc_c_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_c>;
#ifdef CORE_TGC_A
#include "riscv_hart_m_p.h"
#include <iss/arch/tgc_a.h>
using tgc_a_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_a>;
#endif
#ifdef CORE_TGC_B #ifdef CORE_TGC_B
#include "riscv_hart_m_p.h" #include "riscv_hart_m_p.h"
#include "tgc_b.h" #include <iss/arch/tgc_b.h>
using tgc_b_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_b>; using tgc_b_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_b>;
#endif #endif
#ifdef CORE_TGC_C_XRB_NN #ifdef CORE_TGC_C_XRB_NN
#include "riscv_hart_m_p.h" #include "riscv_hart_m_p.h"
#include "tgc_c_xrb_nn.h" #include <iss/arch/tgc_c_xrb_nn.h>
using tgc_c_xrb_nn_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_c_xrb_nn>; using tgc_c_xrb_nn_plat_type = iss::arch::riscv_hart_m_p<iss::arch::tgc_c_xrb_nn>;
#endif #endif
#ifdef CORE_TGC_D #ifdef CORE_TGC_D
#include "riscv_hart_mu_p.h" #include "riscv_hart_mu_p.h"
#include "tgc_d.h" #include <iss/arch/tgc_d.h>
using tgc_d_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>; using tgc_d_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
#endif #endif
#ifdef CORE_TGC_D_XRB_MAC #ifdef CORE_TGC_D_XRB_MAC
#include "riscv_hart_mu_p.h" #include "riscv_hart_mu_p.h"
#include "tgc_d_xrb_mac.h" #include <iss/arch/tgc_d_xrb_mac.h>
using tgc_d_xrb_mac_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d_xrb_mac, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>; using tgc_d_xrb_mac_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d_xrb_mac, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
#endif #endif
#ifdef CORE_TGC_D_XRB_NN #ifdef CORE_TGC_D_XRB_NN
#include "riscv_hart_mu_p.h" #include "riscv_hart_mu_p.h"
#include "tgc_d_xrb_nn.h" #include <iss/arch/tgc_d_xrb_nn.h>
using tgc_d_xrb_nn_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d_xrb_nn, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>; using tgc_d_xrb_nn_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_d_xrb_nn, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
#endif #endif
#ifdef CORE_TGC_E #ifdef CORE_TGC_E
#include "riscv_hart_mu_p.h" #include "riscv_hart_mu_p.h"
#include "tgc_e.h" #include <iss/arch/tgc_e.h>
using tgc_e_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_e, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>; using tgc_e_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_e, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N)>;
#endif #endif
#ifdef CORE_TGC_X #ifdef CORE_TGC_X
#include "riscv_hart_mu_p.h" #include "riscv_hart_mu_p.h"
#include "tgc_x.h" #include <iss/arch/tgc_x.h>
using tgc_x_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_x, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N | iss::arch::FEAT_TCM)>; using tgc_x_plat_type = iss::arch::riscv_hart_mu_p<iss::arch::tgc_x, (iss::arch::features_e)(iss::arch::FEAT_PMP | iss::arch::FEAT_CLIC | iss::arch::FEAT_EXT_N | iss::arch::FEAT_TCM)>;
#endif #endif

View File

@ -32,14 +32,14 @@
* eyck@minres.com - initial API and implementation * eyck@minres.com - initial API and implementation
******************************************************************************/ ******************************************************************************/
#include "iss/plugin/cycle_estimate.h" #include "cycle_estimate.h"
#include <iss/arch_if.h> #include <iss/arch_if.h>
#include <util/logging.h> #include <util/logging.h>
#include <rapidjson/document.h> #include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h> #include <rapidjson/istreamwrapper.h>
#include "rapidjson/writer.h" #include <rapidjson/writer.h>
#include "rapidjson/stringbuffer.h" #include <rapidjson/stringbuffer.h>
#include <rapidjson/ostreamwrapper.h> #include <rapidjson/ostreamwrapper.h>
#include <rapidjson/error/en.h> #include <rapidjson/error/en.h>
#include <fstream> #include <fstream>
@ -48,7 +48,7 @@ using namespace rapidjson;
using namespace std; using namespace std;
iss::plugin::cycle_estimate::cycle_estimate(string const& config_file_name) iss::plugin::cycle_estimate::cycle_estimate(string const& config_file_name)
: arch_instr(nullptr) : instr_if(nullptr)
, config_file_name(config_file_name) , config_file_name(config_file_name)
{ {
} }
@ -57,9 +57,9 @@ iss::plugin::cycle_estimate::~cycle_estimate() {
} }
bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if& vm) { bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if& vm) {
arch_instr = vm.get_arch()->get_instrumentation_if(); instr_if = vm.get_arch()->get_instrumentation_if();
if(!arch_instr) return false; if(!instr_if) return false;
const string core_name = arch_instr->core_type_name(); const string core_name = instr_if->core_type_name();
if (config_file_name.length() > 0) { if (config_file_name.length() > 0) {
ifstream is(config_file_name); ifstream is(config_file_name);
if (is.is_open()) { if (is.is_open()) {
@ -108,11 +108,11 @@ bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if&
} }
void iss::plugin::cycle_estimate::callback(instr_info_t instr_info, exec_info const& exc_info) { void iss::plugin::cycle_estimate::callback(instr_info_t instr_info, exec_info const& exc_info) {
assert(arch_instr && "No instrumentation interface available but callback executed"); assert(instr_if && "No instrumentation interface available but callback executed");
auto entry = delays[instr_info.instr_id]; auto entry = delays[instr_info.instr_id];
bool taken = exc_info.branch_taken; bool taken = exc_info.branch_taken;
if (exc_info.branch_taken && (entry.taken > 1)) if (exc_info.branch_taken && (entry.taken > 1))
arch_instr->set_curr_instr_cycles(entry.taken); instr_if->set_curr_instr_cycles(entry.taken);
else if (entry.not_taken > 1) else if (entry.not_taken > 1)
arch_instr->set_curr_instr_cycles(entry.not_taken); instr_if->set_curr_instr_cycles(entry.not_taken);
} }

View File

@ -81,7 +81,7 @@ public:
void callback(instr_info_t instr_info, exec_info const&) override; void callback(instr_info_t instr_info, exec_info const&) override;
private: private:
iss::instrumentation_if *arch_instr; iss::instrumentation_if *instr_if;
std::vector<instr_desc> delays; std::vector<instr_desc> delays;
struct pair_hash { struct pair_hash {
size_t operator()(const std::pair<uint64_t, uint64_t> &p) const { size_t operator()(const std::pair<uint64_t, uint64_t> &p) const {

View File

@ -32,8 +32,8 @@
* eyck@minres.com - initial API and implementation * eyck@minres.com - initial API and implementation
******************************************************************************/ ******************************************************************************/
#include "iss/plugin/instruction_count.h" #include "instruction_count.h"
#include "iss/instrumentation_if.h" #include <iss/instrumentation_if.h>
#include <iss/arch_if.h> #include <iss/arch_if.h>
#include <util/logging.h> #include <util/logging.h>

View File

@ -1,11 +1,11 @@
#include <iss/arch_if.h> #include <iss/arch_if.h>
#include <iss/plugin/pctrace.h> #include "pctrace.h"
#include <util/logging.h> #include <util/logging.h>
#include <util/ities.h> #include <util/ities.h>
#include <rapidjson/document.h> #include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h> #include <rapidjson/istreamwrapper.h>
#include "rapidjson/writer.h" #include <rapidjson/writer.h>
#include "rapidjson/stringbuffer.h" #include <rapidjson/stringbuffer.h>
#include <rapidjson/ostreamwrapper.h> #include <rapidjson/ostreamwrapper.h>
#include <rapidjson/error/en.h> #include <rapidjson/error/en.h>
#include <fstream> #include <fstream>
@ -159,10 +159,15 @@ void cov::callback(instr_info_t iinfo, const exec_info& einfo) {
auto instr = instr_if->get_instr_word(); auto instr = instr_if->get_instr_word();
auto call = (id==2 || id==3) && bit_sub<7,5>(instr)!=0; auto call = (id==2 || id==3) && bit_sub<7,5>(instr)!=0;
bool taken = einfo.branch_taken; bool taken = einfo.branch_taken;
if (einfo.branch_taken) if (einfo.branch_taken) {
delay = entry.taken; delay = entry.taken;
else if(entry.taken > 1)
instr_if->set_curr_instr_cycles(entry.taken);
} else {
delay = entry.not_taken; delay = entry.not_taken;
if (entry.not_taken > 1)
instr_if->set_curr_instr_cycles(entry.not_taken);
}
#ifndef WITH_LZ4 #ifndef WITH_LZ4
output<<std::hex <<"0x" << instr_if->get_pc() <<"," << delay <<"," << call<< "\n"; output<<std::hex <<"0x" << instr_if->get_pc() <<"," << delay <<"," << call<< "\n";
#else #else

View File

@ -35,14 +35,14 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <iss/arch/tgc_mapper.h> #include "iss/arch/tgc_mapper.h"
#ifdef WITH_LLVM #ifdef WITH_LLVM
#include <iss/llvm/jit_helper.h> #include <iss/llvm/jit_helper.h>
#endif #endif
#include <iss/log_categories.h> #include <iss/log_categories.h>
#include <iss/plugin/cycle_estimate.h> #include "iss/plugin/cycle_estimate.h"
#include <iss/plugin/instruction_count.h> #include "iss/plugin/instruction_count.h"
#include <iss/plugin/pctrace.h> #include "iss/plugin/pctrace.h"
#include <iss/plugin/loader.h> #include <iss/plugin/loader.h>
#if defined(HAS_LUA) #if defined(HAS_LUA)
#include <iss/plugin/lua.h> #include <iss/plugin/lua.h>

View File

@ -38,7 +38,7 @@
#include <iss/iss.h> #include <iss/iss.h>
#include <iss/vm_types.h> #include <iss/vm_types.h>
#include <iss/plugin/loader.h> #include <iss/plugin/loader.h>
#include <sysc/core_complex.h> #include "core_complex.h"
#include <iss/arch/tgc_mapper.h> #include <iss/arch/tgc_mapper.h>
#include <scc/report.h> #include <scc/report.h>
#include <util/ities.h> #include <util/ities.h>

View File

@ -1 +0,0 @@
/vm_tgc_*.cpp

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@
* *
*******************************************************************************/ *******************************************************************************/
#include <iss/arch/tgf_c.h> #include <iss/arch/tgc_c.h>
#include <iss/arch/riscv_hart_m_p.h> #include <iss/arch/riscv_hart_m_p.h>
#include <iss/debugger/gdb_session.h> #include <iss/debugger/gdb_session.h>
#include <iss/debugger/server.h> #include <iss/debugger/server.h>
@ -52,7 +52,7 @@ namespace fp_impl {
void add_fp_functions_2_module(::llvm::Module *, unsigned, unsigned); void add_fp_functions_2_module(::llvm::Module *, unsigned, unsigned);
} }
namespace tgf_c { namespace tgc_c {
using namespace ::llvm; using namespace ::llvm;
using namespace iss::arch; using namespace iss::arch;
using namespace iss::debugger; using namespace iss::debugger;
@ -4151,11 +4151,11 @@ template <typename ARCH> inline void vm_impl<ARCH>::gen_trap_check(BasicBlock *b
bb, this->trap_blk, 1); bb, this->trap_blk, 1);
} }
} // namespace tgf_c } // namespace tgc_c
template <> template <>
std::unique_ptr<vm_if> create<arch::tgf_c>(arch::tgf_c *core, unsigned short port, bool dump) { std::unique_ptr<vm_if> create<arch::tgc_c>(arch::tgc_c *core, unsigned short port, bool dump) {
auto ret = new tgf_c::vm_impl<arch::tgf_c>(*core, dump); auto ret = new tgc_c::vm_impl<arch::tgc_c>(*core, dump);
if (port != 0) debugger::server<debugger::gdb_session>::run_server(ret, port); if (port != 0) debugger::server<debugger::gdb_session>::run_server(ret, port);
return std::unique_ptr<vm_if>(ret); return std::unique_ptr<vm_if>(ret);
} }

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@
* *
*******************************************************************************/ *******************************************************************************/
#include <iss/arch/tgf_c.h> #include <iss/arch/tgc_c.h>
#include <iss/arch/riscv_hart_m_p.h> #include <iss/arch/riscv_hart_m_p.h>
#include <iss/debugger/gdb_session.h> #include <iss/debugger/gdb_session.h>
#include <iss/debugger/server.h> #include <iss/debugger/server.h>
@ -49,7 +49,7 @@
namespace iss { namespace iss {
namespace tcc { namespace tcc {
namespace tgf_c { namespace tgc_c {
using namespace iss::arch; using namespace iss::arch;
using namespace iss::debugger; using namespace iss::debugger;
@ -3251,8 +3251,8 @@ template <typename ARCH> void vm_impl<ARCH>::gen_trap_behavior(tu_builder& tu) {
} // namespace mnrv32 } // namespace mnrv32
template <> template <>
std::unique_ptr<vm_if> create<arch::tgf_c>(arch::tgf_c *core, unsigned short port, bool dump) { std::unique_ptr<vm_if> create<arch::tgc_c>(arch::tgc_c *core, unsigned short port, bool dump) {
auto ret = new tgf_c::vm_impl<arch::tgf_c>(*core, dump); auto ret = new tgc_c::vm_impl<arch::tgc_c>(*core, dump);
if (port != 0) debugger::server<debugger::gdb_session>::run_server(ret, port); if (port != 0) debugger::server<debugger::gdb_session>::run_server(ret, port);
return std::unique_ptr<vm_if>(ret); return std::unique_ptr<vm_if>(ret);
} }

File diff suppressed because it is too large Load Diff