From 3fb8fe765ae0a4603b952804811ce075337360f3 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Tue, 26 Sep 2023 20:17:16 +0200 Subject: [PATCH 01/13] aligns riscv_hart_msu_vp with riscv_hart_m_p --- src/iss/arch/riscv_hart_msu_vp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iss/arch/riscv_hart_msu_vp.h b/src/iss/arch/riscv_hart_msu_vp.h index ccf9e31..9627eff 100644 --- a/src/iss/arch/riscv_hart_msu_vp.h +++ b/src/iss/arch/riscv_hart_msu_vp.h @@ -286,7 +286,7 @@ public: return m[mode]; } - riscv_hart_msu_vp(); + riscv_hart_msu_vp(feature_config cfg = feature_config{}); virtual ~riscv_hart_msu_vp() = default; void reset(uint64_t address) override; From 2095ac985b3a070a19ddf12dbab51ab21e345514 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Wed, 27 Sep 2023 06:19:59 +0200 Subject: [PATCH 02/13] fixes forgotten removal of pctrace in core_complex --- src/sysc/core_complex.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/sysc/core_complex.cpp b/src/sysc/core_complex.cpp index a11c901..78eb36e 100644 --- a/src/sysc/core_complex.cpp +++ b/src/sysc/core_complex.cpp @@ -50,7 +50,6 @@ #include #include #include -#include // clang-format on @@ -283,10 +282,6 @@ void core_complex::before_end_of_elaboration() { auto *plugin = new iss::plugin::cycle_estimate(filename); cpu->vm->register_plugin(*plugin); plugin_list.push_back(plugin); - } else if (plugin_name == "pctrace") { - auto *plugin = new iss::plugin::pctrace(filename); - cpu->vm->register_plugin(*plugin); - plugin_list.push_back(plugin); } else { #ifndef WIN32 std::array a{{filename.c_str()}}; From b7f023756e0f6c0bb3600ffe59dae96026ad1bbe Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Wed, 27 Sep 2023 07:51:49 +0200 Subject: [PATCH 03/13] fixes constructor calls of derived riscv_hart classes --- src/iss/arch/hwl.h | 4 ++-- src/iss/arch/riscv_hart_common.h | 2 ++ src/iss/arch/wt_cache.h | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/iss/arch/hwl.h b/src/iss/arch/hwl.h index 9e954ba..80f0798 100644 --- a/src/iss/arch/hwl.h +++ b/src/iss/arch/hwl.h @@ -46,7 +46,7 @@ public: using this_class = hwl; using reg_t = typename BASE::reg_t; - hwl(); + hwl(feature_config cfg = feature_config{}); virtual ~hwl() = default; protected: @@ -56,7 +56,7 @@ protected: template -inline hwl::hwl() { +inline hwl::hwl(feature_config cfg): BASE(cfg) { for (unsigned addr = 0x800; addr < 0x803; ++addr){ this->register_custom_csr_rd(addr); this->register_custom_csr_wr(addr); diff --git a/src/iss/arch/riscv_hart_common.h b/src/iss/arch/riscv_hart_common.h index 45fc000..4125297 100644 --- a/src/iss/arch/riscv_hart_common.h +++ b/src/iss/arch/riscv_hart_common.h @@ -226,6 +226,8 @@ struct feature_config { unsigned clic_num_trigger{0}; uint64_t tcm_base{0x10000000}; uint64_t tcm_size{0x8000}; + uint64_t io_address{0xf0000000}; + uint64_t io_addr_mask{0xf0000000}; }; class trap_load_access_fault : public trap_access { diff --git a/src/iss/arch/wt_cache.h b/src/iss/arch/wt_cache.h index 2b3835b..7108b9d 100644 --- a/src/iss/arch/wt_cache.h +++ b/src/iss/arch/wt_cache.h @@ -81,7 +81,7 @@ public: using mem_write_f = typename BASE::mem_write_f; using phys_addr_t = typename BASE::phys_addr_t; - wt_cache(); + wt_cache(feature_config cfg = feature_config{}); virtual ~wt_cache() = default; unsigned size{4096}; @@ -103,7 +103,11 @@ protected: template -inline wt_cache::wt_cache() { +inline wt_cache::wt_cache(feature_config cfg) +:BASE(cfg) +, io_address{cfg.io_address} +, io_addr_mask{cfg.io_addr_mask} +{ auto cb = base_class::replace_mem_access( [this](phys_addr_t a, unsigned l, uint8_t* const d) -> iss::status { return read_cache(a, l,d);}, [this](phys_addr_t a, unsigned l, uint8_t const* const d) -> iss::status { return write_cache(a, l,d);}); From b97853ff5a681acfb6138f4e46c5da881ec64f3b Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 30 Sep 2023 22:10:24 +0200 Subject: [PATCH 04/13] update plugins to read YAML file --- CMakeLists.txt | 14 +- TGC_C_instr.yaml => TGC5C_instr.yaml | 201 +++++++++++--------- gen_input/templates/CORENAME_instr.yaml.gtl | 4 +- src/iss/plugin/cycle_estimate.cpp | 63 +++--- src/iss/plugin/instruction_count.cpp | 50 ++--- src/iss/plugin/instruction_count.h | 3 +- src/main.cpp | 11 +- 7 files changed, 171 insertions(+), 175 deletions(-) rename TGC_C_instr.yaml => TGC5C_instr.yaml (90%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 765aafc..86197b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,13 +53,9 @@ if(WITH_TCC) list(APPEND LIB_SOURCES ${TCC_GEN_SOURCES}) endif() -if(TARGET RapidJSON OR TARGET RapidJSON::RapidJSON) +if(TARGET yaml-cpp::yaml-cpp) list(APPEND LIB_SOURCES src/iss/plugin/cycle_estimate.cpp - ) -endif() -if(TARGET jsoncpp::jsoncpp) - list(APPEND LIB_SOURCES src/iss/plugin/instruction_count.cpp ) endif() @@ -84,11 +80,9 @@ if(NOT (DBT_CORE_DEFS STREQUAL DBT_CORE_DEFS-NOTFOUND)) endif() target_link_libraries(${PROJECT_NAME} PUBLIC elfio::elfio softfloat scc-util Boost::coroutine) -if(TARGET jsoncpp::jsoncpp) - target_link_libraries(${PROJECT_NAME} PUBLIC jsoncpp::jsoncpp) -endif() -if(TARGET RapidJSON) - target_link_libraries(${PROJECT_NAME} PUBLIC RapidJSON) +if(TARGET yaml-cpp::yaml-cpp) + target_compile_definitions(${PROJECT_NAME} PUBLIC WITH_PLUGINS) + target_link_libraries(${PROJECT_NAME} PUBLIC yaml-cpp::yaml-cpp) endif() if(WITH_LLVM) diff --git a/TGC_C_instr.yaml b/TGC5C_instr.yaml similarity index 90% rename from TGC_C_instr.yaml rename to TGC5C_instr.yaml index e28cb64..8f14fe9 100644 --- a/TGC_C_instr.yaml +++ b/TGC5C_instr.yaml @@ -1,297 +1,297 @@ RV32I: - - LUI: + LUI: encoding: 0b00000000000000000000000000110111 mask: 0b00000000000000000000000001111111 size: 32 branch: false delay: 1 - - AUIPC: + AUIPC: encoding: 0b00000000000000000000000000010111 mask: 0b00000000000000000000000001111111 size: 32 branch: false delay: 1 - - JAL: + JAL: encoding: 0b00000000000000000000000001101111 mask: 0b00000000000000000000000001111111 size: 32 branch: true delay: 1 - - JALR: + JALR: encoding: 0b00000000000000000000000001100111 mask: 0b00000000000000000111000001111111 size: 32 branch: true - delay: 1 - - BEQ: + delay: [1,1] + BEQ: encoding: 0b00000000000000000000000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true - delay: 1 - - BNE: + delay: [1,1] + BNE: encoding: 0b00000000000000000001000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true - delay: 1 - - BLT: + delay: [1,1] + BLT: encoding: 0b00000000000000000100000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true - delay: 1 - - BGE: + delay: [1,1] + BGE: encoding: 0b00000000000000000101000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true - delay: 1 - - BLTU: + delay: [1,1] + BLTU: encoding: 0b00000000000000000110000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true - delay: 1 - - BGEU: + delay: [1,1] + BGEU: encoding: 0b00000000000000000111000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true - delay: 1 - - LB: + delay: [1,1] + LB: encoding: 0b00000000000000000000000000000011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - LH: + LH: encoding: 0b00000000000000000001000000000011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - LW: + LW: encoding: 0b00000000000000000010000000000011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - LBU: + LBU: encoding: 0b00000000000000000100000000000011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - LHU: + LHU: encoding: 0b00000000000000000101000000000011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - SB: + SB: encoding: 0b00000000000000000000000000100011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - SH: + SH: encoding: 0b00000000000000000001000000100011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - SW: + SW: encoding: 0b00000000000000000010000000100011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - ADDI: + ADDI: encoding: 0b00000000000000000000000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - SLTI: + SLTI: encoding: 0b00000000000000000010000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - SLTIU: + SLTIU: encoding: 0b00000000000000000011000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - XORI: + XORI: encoding: 0b00000000000000000100000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - ORI: + ORI: encoding: 0b00000000000000000110000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - ANDI: + ANDI: encoding: 0b00000000000000000111000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - SLLI: + SLLI: encoding: 0b00000000000000000001000000010011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - SRLI: + SRLI: encoding: 0b00000000000000000101000000010011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - SRAI: + SRAI: encoding: 0b01000000000000000101000000010011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - ADD: + ADD: encoding: 0b00000000000000000000000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - SUB: + SUB: encoding: 0b01000000000000000000000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - SLL: + SLL: encoding: 0b00000000000000000001000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - SLT: + SLT: encoding: 0b00000000000000000010000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - SLTU: + SLTU: encoding: 0b00000000000000000011000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - XOR: + XOR: encoding: 0b00000000000000000100000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - SRL: + SRL: encoding: 0b00000000000000000101000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - SRA: + SRA: encoding: 0b01000000000000000101000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - OR: + OR: encoding: 0b00000000000000000110000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - AND: + AND: encoding: 0b00000000000000000111000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - FENCE: + FENCE: encoding: 0b00000000000000000000000000001111 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - ECALL: + ECALL: encoding: 0b00000000000000000000000001110011 mask: 0b11111111111111111111111111111111 size: 32 branch: false delay: 1 - - EBREAK: + EBREAK: encoding: 0b00000000000100000000000001110011 mask: 0b11111111111111111111111111111111 size: 32 branch: false delay: 1 - - MRET: + MRET: encoding: 0b00110000001000000000000001110011 mask: 0b11111111111111111111111111111111 attributes: [[name:no_cont]] size: 32 branch: false delay: 1 - - WFI: + WFI: encoding: 0b00010000010100000000000001110011 mask: 0b11111111111111111111111111111111 size: 32 branch: false delay: 1 Zicsr: - - CSRRW: + CSRRW: encoding: 0b00000000000000000001000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - CSRRS: + CSRRS: encoding: 0b00000000000000000010000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - CSRRC: + CSRRC: encoding: 0b00000000000000000011000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - CSRRWI: + CSRRWI: encoding: 0b00000000000000000101000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - CSRRSI: + CSRRSI: encoding: 0b00000000000000000110000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 - - CSRRCI: + CSRRCI: encoding: 0b00000000000000000111000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 Zifencei: - - FENCE_I: + FENCE_I: encoding: 0b00000000000000000001000000001111 mask: 0b00000000000000000111000001111111 attributes: [[name:flush]] @@ -299,218 +299,231 @@ Zifencei: branch: false delay: 1 RV32M: - - MUL: + MUL: encoding: 0b00000010000000000000000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - MULH: + MULH: encoding: 0b00000010000000000001000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - MULHSU: + MULHSU: encoding: 0b00000010000000000010000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - MULHU: + MULHU: encoding: 0b00000010000000000011000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - DIV: + DIV: encoding: 0b00000010000000000100000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - DIVU: + DIVU: encoding: 0b00000010000000000101000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - REM: + REM: encoding: 0b00000010000000000110000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 - - REMU: + REMU: encoding: 0b00000010000000000111000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 RV32IC: - - CADDI4SPN: + C__ADDI4SPN: encoding: 0b0000000000000000 mask: 0b1110000000000011 size: 16 branch: false delay: 1 - - CLW: + C__LW: encoding: 0b0100000000000000 mask: 0b1110000000000011 size: 16 branch: false delay: 1 - - CSW: + C__SW: encoding: 0b1100000000000000 mask: 0b1110000000000011 size: 16 branch: false delay: 1 - - CADDI: + C__ADDI: encoding: 0b0000000000000001 mask: 0b1110000000000011 size: 16 branch: false delay: 1 - - CNOP: + C__NOP: encoding: 0b0000000000000001 mask: 0b1110111110000011 size: 16 branch: false delay: 1 - - CJAL: + C__JAL: encoding: 0b0010000000000001 mask: 0b1110000000000011 size: 16 branch: true delay: 1 - - CLI: + C__LI: encoding: 0b0100000000000001 mask: 0b1110000000000011 size: 16 branch: false delay: 1 - - CLUI: + C__LUI: encoding: 0b0110000000000001 mask: 0b1110000000000011 size: 16 branch: false delay: 1 - - CADDI16SP: + C__ADDI16SP: encoding: 0b0110000100000001 mask: 0b1110111110000011 size: 16 branch: false delay: 1 - - CSRLI: + __reserved_clui: + encoding: 0b0110000000000001 + mask: 0b1111000001111111 + size: 16 + branch: false + delay: 1 + C__SRLI: encoding: 0b1000000000000001 mask: 0b1111110000000011 size: 16 branch: false delay: 1 - - CSRAI: + C__SRAI: encoding: 0b1000010000000001 mask: 0b1111110000000011 size: 16 branch: false delay: 1 - - CANDI: + C__ANDI: encoding: 0b1000100000000001 mask: 0b1110110000000011 size: 16 branch: false delay: 1 - - CSUB: + C__SUB: encoding: 0b1000110000000001 mask: 0b1111110001100011 size: 16 branch: false delay: 1 - - CXOR: + C__XOR: encoding: 0b1000110000100001 mask: 0b1111110001100011 size: 16 branch: false delay: 1 - - COR: + C__OR: encoding: 0b1000110001000001 mask: 0b1111110001100011 size: 16 branch: false delay: 1 - - CAND: + C__AND: encoding: 0b1000110001100001 mask: 0b1111110001100011 size: 16 branch: false delay: 1 - - CJ: + C__J: encoding: 0b1010000000000001 mask: 0b1110000000000011 size: 16 branch: true delay: 1 - - CBEQZ: + C__BEQZ: encoding: 0b1100000000000001 mask: 0b1110000000000011 size: 16 branch: true - delay: 1 - - CBNEZ: + delay: [1,1] + C__BNEZ: encoding: 0b1110000000000001 mask: 0b1110000000000011 size: 16 branch: true - delay: 1 - - CSLLI: + delay: [1,1] + C__SLLI: encoding: 0b0000000000000010 mask: 0b1111000000000011 + attributes: [[name:enable, value:1]] size: 16 branch: false delay: 1 - - CLWSP: + C__LWSP: encoding: 0b0100000000000010 mask: 0b1110000000000011 size: 16 branch: false delay: 1 - - CMV: + C__MV: encoding: 0b1000000000000010 mask: 0b1111000000000011 size: 16 branch: false delay: 1 - - CJR: + C__JR: encoding: 0b1000000000000010 mask: 0b1111000001111111 size: 16 branch: true delay: 1 - - CADD: + __reserved_cmv: + encoding: 0b1000000000000010 + mask: 0b1111111111111111 + size: 16 + branch: false + delay: 1 + C__ADD: encoding: 0b1001000000000010 mask: 0b1111000000000011 size: 16 branch: false delay: 1 - - CJALR: + C__JALR: encoding: 0b1001000000000010 mask: 0b1111000001111111 size: 16 branch: true delay: 1 - - CEBREAK: + C__EBREAK: encoding: 0b1001000000000010 mask: 0b1111111111111111 size: 16 branch: false delay: 1 - - CSWSP: + C__SWSP: encoding: 0b1100000000000010 mask: 0b1110000000000011 size: 16 branch: false delay: 1 - - DII: + DII: encoding: 0b0000000000000000 mask: 0b1111111111111111 size: 16 diff --git a/gen_input/templates/CORENAME_instr.yaml.gtl b/gen_input/templates/CORENAME_instr.yaml.gtl index eb344ff..6710a1a 100644 --- a/gen_input/templates/CORENAME_instr.yaml.gtl +++ b/gen_input/templates/CORENAME_instr.yaml.gtl @@ -9,8 +9,8 @@ } instrGroups }%><%getInstructionGroups().each{name, instrList -> %> -${name}: <% instrList.findAll{!it.instruction.name.startsWith("__")}.each { %> - - ${it.instruction.name}: +${name}: <% instrList.each { %> + ${it.instruction.name}: encoding: ${it.encoding} mask: ${it.mask}<%if(it.attributes.size) {%> attributes: ${it.attributes}<%}%> diff --git a/src/iss/plugin/cycle_estimate.cpp b/src/iss/plugin/cycle_estimate.cpp index 77d4c5b..267c88e 100644 --- a/src/iss/plugin/cycle_estimate.cpp +++ b/src/iss/plugin/cycle_estimate.cpp @@ -33,18 +33,12 @@ ******************************************************************************/ #include "cycle_estimate.h" +#include #include #include -#include -#include -#include -#include -#include -#include #include -using namespace rapidjson; using namespace std; iss::plugin::cycle_estimate::cycle_estimate(string const& config_file_name) @@ -61,40 +55,31 @@ bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if& if(!instr_if) return false; const string core_name = instr_if->core_type_name(); if (config_file_name.length() > 0) { - ifstream is(config_file_name); + std::ifstream is(config_file_name); if (is.is_open()) { try { - IStreamWrapper isw(is); - Document d; - ParseResult ok = d.ParseStream(isw); - if(ok) { - Value& val = d[core_name.c_str()]; - if(val.IsArray()){ - delays.reserve(val.Size()); - for (auto it = val.Begin(); it != val.End(); ++it) { - auto& name = (*it)["name"]; - auto& size = (*it)["size"]; - auto& delay = (*it)["delay"]; - auto& branch = (*it)["branch"]; - if(delay.IsArray()) { - auto dt = delay[0].Get(); - auto dnt = delay[1].Get(); - delays.push_back(instr_desc{size.Get(), dt, dnt, branch.Get()}); - } else if(delay.Is()) { - auto d = delay.Get(); - delays.push_back(instr_desc{size.Get(), d, d, branch.Get()}); - } else - throw runtime_error("JSON parse error"); - } - } else { - LOG(ERR)<<"plugin cycle_estimate: could not find an entry for "<(); + auto delay = instr.second["delay"]; + if(delay.IsSequence()) { + res.not_taken = delay[0].as(); + res.taken = delay[1].as(); + } else { + res.not_taken = delay.as(); + res.taken = res.not_taken; + } + delays.push_back(std::move(res)); + } + } + } catch (YAML::ParserException &e) { LOG(ERR) << "Could not parse input file " << config_file_name << ", reason: " << e.what(); return false; } diff --git a/src/iss/plugin/instruction_count.cpp b/src/iss/plugin/instruction_count.cpp index 7613b27..01fb45c 100644 --- a/src/iss/plugin/instruction_count.cpp +++ b/src/iss/plugin/instruction_count.cpp @@ -34,6 +34,7 @@ #include "instruction_count.h" #include +#include #include #include @@ -44,8 +45,30 @@ iss::plugin::instruction_count::instruction_count(std::string config_file_name) std::ifstream is(config_file_name); if (is.is_open()) { try { - is >> root; - } catch (Json::RuntimeError &e) { + auto root = YAML::LoadAll(is); + if(root.size()!=1) { + LOG(ERR) << "Too many rro nodes in YAML file " << config_file_name; + } + for (auto p : root[0]) { + auto isa_subset = p.first; + auto instructions = p.second; + for (auto const& instr : instructions) { + instr_delay res; + res.instr_name = instr.first.as(); + res.size = instr.second["encoding"].as().size()-2; // not counting 0b + auto delay = instr.second["delay"]; + if(delay.IsSequence()) { + res.not_taken_delay = delay[0].as(); + res.taken_delay = delay[1].as(); + } else { + res.not_taken_delay = delay.as(); + res.taken_delay = res.not_taken_delay; + } + delays.push_back(std::move(res)); + } + } + rep_counts.resize(delays.size()); + } catch (YAML::ParserException &e) { LOG(ERR) << "Could not parse input file " << config_file_name << ", reason: " << e.what(); } } else { @@ -57,7 +80,7 @@ iss::plugin::instruction_count::instruction_count(std::string config_file_name) iss::plugin::instruction_count::~instruction_count() { size_t idx=0; for(auto it:delays){ - if(rep_counts[idx]>0) + if(rep_counts[idx]>0 && it.instr_name.find("__"!=0)) LOG(INFO)<get_instrumentation_if(); if(!instr_if) return false; - const std::string core_name = instr_if->core_type_name(); - Json::Value &val = root[core_name]; - if(!val.isNull() && val.isArray()){ - delays.reserve(val.size()); - for(auto it:val){ - auto name = it["name"]; - auto size = it["size"]; - auto delay = it["delay"]; - if(!name.isString() || !size.isUInt() || !(delay.isUInt() || delay.isArray())) throw std::runtime_error("JSON parse error"); - if(delay.isUInt()){ - const instr_delay entry{name.asCString(), size.asUInt(), delay.asUInt(), 0}; - delays.push_back(entry); - } else { - const instr_delay entry{name.asCString(), size.asUInt(), delay[0].asUInt(), delay[1].asUInt()}; - delays.push_back(entry); - } - } - rep_counts.resize(delays.size()); - } else { - LOG(ERR)<<"plugin instruction_count: could not find an entry for "< -#include #include +#include namespace iss { namespace plugin { @@ -72,7 +72,6 @@ public: void callback(instr_info_t) override; private: - Json::Value root; std::vector delays; std::vector rep_counts; }; diff --git a/src/main.cpp b/src/main.cpp index 1d3d8e9..c93d558 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) { ("mem,m", po::value(), "the memory input file") ("plugin,p", po::value>(), "plugin to activate") ("backend", po::value()->default_value("interp"), "the ISS backend to use, options are: interp, tcc") - ("isa", po::value()->default_value("tgc5c"), "isa to use for simulation"); + ("isa", po::value()->default_value("tgc5c"), "core or isa name to use for simulation, use '?' to get list"); // clang-format on auto parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); try { @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) { std::tie(cpu, vm) = f.create(isa_opt+"|"+clim["backend"].as(), clim["gdb-port"].as()); } else { auto base_isa = isa_opt.substr(0, 5); - if(base_isa=="tgc_d" || base_isa=="tgc_e") { + if(base_isa=="tgc5d" || base_isa=="tgc5e") { isa_opt += "|mu_p_clic_pmp|"+clim["backend"].as(); } else { isa_opt += "|m_p|"+clim["backend"].as(); @@ -148,6 +148,7 @@ int main(int argc, char *argv[]) { plugin_name = opt_val.substr(0, found); arg = opt_val.substr(found + 1, opt_val.size()); } +#if defined(WITH_PLUGINS) if (plugin_name == "ic") { auto *ic_plugin = new iss::plugin::instruction_count(arg); vm->register_plugin(*ic_plugin); @@ -156,8 +157,10 @@ int main(int argc, char *argv[]) { auto *ce_plugin = new iss::plugin::cycle_estimate(arg); vm->register_plugin(*ce_plugin); plugin_list.push_back(ce_plugin); - }else { -#ifndef WIN32 + } else +#endif + { +#if !defined(WIN32) std::vector a{}; if(arg.length()) a.push_back({arg.c_str()}); From b9b165465da738fb6116137b688fce74aa004ab2 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 30 Sep 2023 22:17:18 +0200 Subject: [PATCH 05/13] adds some template updates --- gen_input/{TGC_C.core_desc => TGC5C.core_desc} | 0 gen_input/templates/interp/CORENAME.cpp.gtl | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename gen_input/{TGC_C.core_desc => TGC5C.core_desc} (100%) diff --git a/gen_input/TGC_C.core_desc b/gen_input/TGC5C.core_desc similarity index 100% rename from gen_input/TGC_C.core_desc rename to gen_input/TGC5C.core_desc diff --git a/gen_input/templates/interp/CORENAME.cpp.gtl b/gen_input/templates/interp/CORENAME.cpp.gtl index cfb6a76..d92ed44 100644 --- a/gen_input/templates/interp/CORENAME.cpp.gtl +++ b/gen_input/templates/interp/CORENAME.cpp.gtl @@ -40,10 +40,11 @@ def nativeTypeSize(int size){ #include #include #include -#include #include #include #include +#include +#include #ifndef FMT_HEADER_ONLY #define FMT_HEADER_ONLY From ee6a068b067c64c8c1e4f6fa729817efc315713d Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 1 Oct 2023 18:33:14 +0200 Subject: [PATCH 06/13] streamlines backends and reporting --- src/main.cpp | 4 +++- src/vm/interp/vm_tgc5c.cpp | 4 ++-- src/vm/llvm/vm_tgc5c.cpp | 4 ++-- src/vm/tcc/vm_tgc5c.cpp | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c93d558..bd9638c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -118,7 +118,9 @@ int main(int argc, char *argv[]) { iss::cpu_ptr cpu{nullptr}; std::string isa_opt(clim["isa"].as()); if(isa_opt.size()==0 || isa_opt == "?") { - std::cout<<"Available cores: "<(), clim["gdb-port"].as()); diff --git a/src/vm/interp/vm_tgc5c.cpp b/src/vm/interp/vm_tgc5c.cpp index f05220b..4f4e494 100644 --- a/src/vm/interp/vm_tgc5c.cpp +++ b/src/vm/interp/vm_tgc5c.cpp @@ -2699,13 +2699,13 @@ volatile std::array dummy = { auto vm = new interp::tgc5c::vm_impl(*cpu, false); if (port != 0) debugger::server::run_server(vm, port); return {cpu_ptr{cpu}, vm_ptr{vm}}; - }), + })/*, core_factory::instance().register_creator("tgc5c|mu_p|interp", [](unsigned port, void*) -> std::tuple{ auto* cpu = new iss::arch::riscv_hart_mu_p(); auto vm = new interp::tgc5c::vm_impl(*cpu, false); if (port != 0) debugger::server::run_server(vm, port); return {cpu_ptr{cpu}, vm_ptr{vm}}; - }) + })*/ }; } } diff --git a/src/vm/llvm/vm_tgc5c.cpp b/src/vm/llvm/vm_tgc5c.cpp index 2229db3..460a9d7 100644 --- a/src/vm/llvm/vm_tgc5c.cpp +++ b/src/vm/llvm/vm_tgc5c.cpp @@ -4549,13 +4549,13 @@ volatile std::array dummy = { auto* vm = new llvm::tgc5c::vm_impl(*cpu, false); if (port != 0) debugger::server::run_server(vm, port); return {cpu_ptr{cpu}, vm_ptr{vm}}; - }), + })/*, core_factory::instance().register_creator("tgc5c|mu_p|llvm", [](unsigned port, void*) -> std::tuple{ auto* cpu = new iss::arch::riscv_hart_mu_p(); auto* vm = new llvm::tgc5c::vm_impl(*cpu, false); if (port != 0) debugger::server::run_server(vm, port); return {cpu_ptr{cpu}, vm_ptr{vm}}; - }) + })*/ }; } } diff --git a/src/vm/tcc/vm_tgc5c.cpp b/src/vm/tcc/vm_tgc5c.cpp index 965b9c7..3e8511b 100644 --- a/src/vm/tcc/vm_tgc5c.cpp +++ b/src/vm/tcc/vm_tgc5c.cpp @@ -3655,13 +3655,13 @@ volatile std::array dummy = { auto vm = new tcc::tgc5c::vm_impl(*cpu, false); if (port != 0) debugger::server::run_server(vm, port); return {cpu_ptr{cpu}, vm_ptr{vm}}; - }), + })/*, core_factory::instance().register_creator("tgc5c|mu_p|tcc", [](unsigned port, void*) -> std::tuple{ auto* cpu = new iss::arch::riscv_hart_mu_p(); auto vm = new tcc::tgc5c::vm_impl(*cpu, false); if (port != 0) debugger::server::run_server(vm, port); return {cpu_ptr{cpu}, vm_ptr{vm}}; - }) + })*/ }; } } From 9180ad1f9c0af678e6080b3fd0db6727213a99eb Mon Sep 17 00:00:00 2001 From: Stanislaw Kaushanski Date: Fri, 6 Oct 2023 21:39:48 +0200 Subject: [PATCH 07/13] debugger memory accesses should never lead to traps --- src/iss/arch/riscv_hart_m_p.h | 4 ++-- src/iss/arch/riscv_hart_msu_vp.h | 4 ++-- src/iss/arch/riscv_hart_mu_p.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/iss/arch/riscv_hart_m_p.h b/src/iss/arch/riscv_hart_m_p.h index 935c774..26e327d 100644 --- a/src/iss/arch/riscv_hart_m_p.h +++ b/src/iss/arch/riscv_hart_m_p.h @@ -682,7 +682,7 @@ iss::status riscv_hart_m_p::read(const address_type type, const acce } else { res = hart_mem_rd_delegate( phys_addr, length, data); } - if (unlikely(res != iss::Ok)){ + if (unlikely(res != iss::Ok && (access & access_type::DEBUG) == 0)){ this->reg.trap_state = (1UL << 31) | (5 << 16); // issue trap 5 (load access fault fault_data=addr; } @@ -775,7 +775,7 @@ iss::status riscv_hart_m_p::write(const address_type type, const acc } else { res = write_mem( phys_addr, length, data); } - if (unlikely(res != iss::Ok)) { + if (unlikely(res != iss::Ok && (access & access_type::DEBUG) == 0)) { this->reg.trap_state = (1UL << 31) | (7 << 16); // issue trap 7 (Store/AMO access fault) fault_data=addr; } diff --git a/src/iss/arch/riscv_hart_msu_vp.h b/src/iss/arch/riscv_hart_msu_vp.h index 9627eff..56c7209 100644 --- a/src/iss/arch/riscv_hart_msu_vp.h +++ b/src/iss/arch/riscv_hart_msu_vp.h @@ -636,7 +636,7 @@ iss::status riscv_hart_msu_vp::read(const address_type type, const access_ } } auto res = read_mem( BASE::v2p(iss::addr_t{access, type, space, addr}), length, data); - if (unlikely(res != iss::Ok)){ + if (unlikely(res != iss::Ok && (access & access_type::DEBUG) == 0)){ this->reg.trap_state = (1 << 31) | (5 << 16); // issue trap 5 (load access fault fault_data=addr; } @@ -734,7 +734,7 @@ iss::status riscv_hart_msu_vp::write(const address_type type, const access } } auto res = write_mem(paddr, length, data); - if (unlikely(res != iss::Ok)) { + if (unlikely(res != iss::Ok && (access & access_type::DEBUG) == 0)) { this->reg.trap_state = (1UL << 31) | (7UL << 16); // issue trap 7 (Store/AMO access fault) fault_data=addr; } diff --git a/src/iss/arch/riscv_hart_mu_p.h b/src/iss/arch/riscv_hart_mu_p.h index 48cf106..33089af 100644 --- a/src/iss/arch/riscv_hart_mu_p.h +++ b/src/iss/arch/riscv_hart_mu_p.h @@ -850,7 +850,7 @@ iss::status riscv_hart_mu_p::read(const address_type type, const acc } else { res = hart_mem_rd_delegate( phys_addr, length, data); } - if (unlikely(res != iss::Ok)){ + if (unlikely(res != iss::Ok && (access & access_type::DEBUG) == 0)){ this->reg.trap_state = (1UL << 31) | (5 << 16); // issue trap 5 (load access fault fault_data=addr; } @@ -951,7 +951,7 @@ iss::status riscv_hart_mu_p::write(const address_type type, const ac } else { res = hart_mem_wr_delegate( phys_addr, length, data); } - if (unlikely(res != iss::Ok)) { + if (unlikely(res != iss::Ok && (access & access_type::DEBUG) == 0)) { this->reg.trap_state = (1UL << 31) | (7UL << 16); // issue trap 7 (Store/AMO access fault) fault_data=addr; } From ae4322c1b967e7d9e98ff30a3cb7bd94476e9ada Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 15 Oct 2023 09:03:31 +0200 Subject: [PATCH 08/13] =?UTF-8?q?=E2=80=9Esrc/main.cpp=E2=80=9C=20=C3=A4nd?= =?UTF-8?q?ern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 444 +++++++++++++++++++++++++-------------------------- 1 file changed, 222 insertions(+), 222 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bd9638c..03a68d0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,222 +1,222 @@ -/******************************************************************************* - * Copyright (C) 2017, 2018 MINRES Technologies GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - *******************************************************************************/ - -#include -#include -#include -#include - -#include -#include -#include "iss/arch/tgc_mapper.h" -#ifdef WITH_LLVM -#include -#endif -#include -#include "iss/plugin/cycle_estimate.h" -#include "iss/plugin/instruction_count.h" -#ifndef WIN32 -#include -#endif -#if defined(HAS_LUA) -#include -#endif - -namespace po = boost::program_options; - -int main(int argc, char *argv[]) { - /* - * Define and parse the program options - */ - po::variables_map clim; - po::options_description desc("Options"); - // clang-format off - desc.add_options() - ("help,h", "Print help message") - ("verbose,v", po::value()->default_value(4), "Sets logging verbosity") - ("logfile,l", po::value(), "Sets default log file.") - ("disass,d", po::value()->implicit_value(""), "Enables disassembly") - ("gdb-port,g", po::value()->default_value(0), "enable gdb server and specify port to use") - ("instructions,i", po::value()->default_value(std::numeric_limits::max()), "max. number of instructions to simulate") - ("reset,r", po::value(), "reset address") - ("dump-ir", "dump the intermediate representation") - ("elf,f", po::value>(), "ELF file(s) to load") - ("mem,m", po::value(), "the memory input file") - ("plugin,p", po::value>(), "plugin to activate") - ("backend", po::value()->default_value("interp"), "the ISS backend to use, options are: interp, tcc") - ("isa", po::value()->default_value("tgc5c"), "core or isa name to use for simulation, use '?' to get list"); - // clang-format on - auto parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); - try { - po::store(parsed, clim); // can throw - // --help option - if (clim.count("help")) { - std::cout << "DBT-RISE-RiscV simulator for RISC-V" << std::endl << desc << std::endl; - return 0; - } - po::notify(clim); // throws on error, so do after help in case - } catch (po::error &e) { - // there are problems - std::cerr << "ERROR: " << e.what() << std::endl << std::endl; - std::cerr << desc << std::endl; - return 1; - } - std::vector args = collect_unrecognized(parsed.options, po::include_positional); - - LOGGER(DEFAULT)::print_time() = false; - LOGGER(connection)::print_time() = false; - auto l = logging::as_log_level(clim["verbose"].as()); - LOGGER(DEFAULT)::reporting_level() = l; - LOGGER(connection)::reporting_level() = l; - if (clim.count("logfile")) { - // configure the connection logger - auto f = fopen(clim["logfile"].as().c_str(), "w"); - LOG_OUTPUT(DEFAULT)::stream() = f; - LOG_OUTPUT(connection)::stream() = f; - } - - std::vector plugin_list; - auto res = 0; - try { -#ifdef WITH_LLVM - // application code comes here // - iss::init_jit_debug(argc, argv); -#endif - bool dump = clim.count("dump-ir"); - auto & f = iss::core_factory::instance(); - // instantiate the simulator - iss::vm_ptr vm{nullptr}; - iss::cpu_ptr cpu{nullptr}; - std::string isa_opt(clim["isa"].as()); - if(isa_opt.size()==0 || isa_opt == "?") { - auto list = f.get_names(); - std::sort(std::begin(list), std::end(list)); - std::cout<<"Available implementations (core|platform|backend):\n - "<(), clim["gdb-port"].as()); - } else { - auto base_isa = isa_opt.substr(0, 5); - if(base_isa=="tgc5d" || base_isa=="tgc5e") { - isa_opt += "|mu_p_clic_pmp|"+clim["backend"].as(); - } else { - isa_opt += "|m_p|"+clim["backend"].as(); - } - std::tie(cpu, vm) = f.create(isa_opt, clim["gdb-port"].as()); - } - if(!cpu ){ - LOG(ERR) << "Could not create cpu for isa " << isa_opt << " and backend " <()<< std::endl; - return 127; - } - if(!vm ){ - LOG(ERR) << "Could not create vm for isa " << isa_opt << " and backend " <()<< std::endl; - return 127; - } - if (clim.count("plugin")) { - for (std::string const& opt_val : clim["plugin"].as>()) { - std::string plugin_name=opt_val; - std::string arg{""}; - std::size_t found = opt_val.find('='); - if (found != std::string::npos) { - plugin_name = opt_val.substr(0, found); - arg = opt_val.substr(found + 1, opt_val.size()); - } -#if defined(WITH_PLUGINS) - if (plugin_name == "ic") { - auto *ic_plugin = new iss::plugin::instruction_count(arg); - vm->register_plugin(*ic_plugin); - plugin_list.push_back(ic_plugin); - } else if (plugin_name == "ce") { - auto *ce_plugin = new iss::plugin::cycle_estimate(arg); - vm->register_plugin(*ce_plugin); - plugin_list.push_back(ce_plugin); - } else -#endif - { -#if !defined(WIN32) - std::vector a{}; - if(arg.length()) - a.push_back({arg.c_str()}); - iss::plugin::loader l(plugin_name, {{"initPlugin"}}); - auto* plugin = l.call_function("initPlugin", a.size(), a.data()); - if(plugin){ - vm->register_plugin(*plugin); - plugin_list.push_back(plugin); - } else -#endif - { - LOG(ERR) << "Unknown plugin name: " << plugin_name << ", valid names are 'ce', 'ic'" << std::endl; - return 127; - } - } - } - } - if (clim.count("disass")) { - vm->setDisassEnabled(true); - LOGGER(disass)::reporting_level() = logging::INFO; - LOGGER(disass)::print_time() = false; - auto file_name = clim["disass"].as(); - if (file_name.length() > 0) { - LOG_OUTPUT(disass)::stream() = fopen(file_name.c_str(), "w"); - LOGGER(disass)::print_severity() = false; - } - } - uint64_t start_address = 0; - if (clim.count("mem")) - vm->get_arch()->load_file(clim["mem"].as()); - if (clim.count("elf")) - for (std::string input : clim["elf"].as>()) { - auto start_addr = vm->get_arch()->load_file(input); - if (start_addr.second) start_address = start_addr.first; - } - for (std::string input : args) { - auto start_addr = vm->get_arch()->load_file(input); // treat remaining arguments as elf files - if (start_addr.second) start_address = start_addr.first; - } - if (clim.count("reset")) { - auto str = clim["reset"].as(); - start_address = str.find("0x") == 0 ? std::stoull(str.substr(2), nullptr, 16) : std::stoull(str, nullptr, 10); - } - vm->reset(start_address); - auto cycles = clim["instructions"].as(); - res = vm->start(cycles, dump); - } catch (std::exception &e) { - LOG(ERR) << "Unhandled Exception reached the top of main: " << e.what() << ", application will now exit" - << std::endl; - res = 2; - } - // cleanup to let plugins report of needed - for (auto *p : plugin_list) { - delete p; - } - return res; -} +/******************************************************************************* + * Copyright (C) 2017, 2018 MINRES Technologies GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + *******************************************************************************/ + +#include +#include +#include +#include + +#include +#include +#include "iss/arch/tgc_mapper.h" +#ifdef WITH_LLVM +#include +#endif +#include +#include "iss/plugin/cycle_estimate.h" +#include "iss/plugin/instruction_count.h" +#ifndef WIN32 +#include +#endif +#if defined(HAS_LUA) +#include +#endif + +namespace po = boost::program_options; + +int main(int argc, char *argv[]) { + /* + * Define and parse the program options + */ + po::variables_map clim; + po::options_description desc("Options"); + // clang-format off + desc.add_options() + ("help,h", "Print help message") + ("verbose,v", po::value()->default_value(4), "Sets logging verbosity") + ("logfile,l", po::value(), "Sets default log file.") + ("disass,d", po::value()->implicit_value(""), "Enables disassembly") + ("gdb-port,g", po::value()->default_value(0), "enable gdb server and specify port to use") + ("instructions,i", po::value()->default_value(std::numeric_limits::max()), "max. number of instructions to simulate") + ("reset,r", po::value(), "reset address") + ("dump-ir", "dump the intermediate representation") + ("elf,f", po::value>(), "ELF file(s) to load") + ("mem,m", po::value(), "the memory input file") + ("plugin,p", po::value>(), "plugin to activate") + ("backend", po::value()->default_value("interp"), "the ISS backend to use, options are: interp, tcc") + ("isa", po::value()->default_value("tgc5c"), "core or isa name to use for simulation, use '?' to get list"); + // clang-format on + auto parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); + try { + po::store(parsed, clim); // can throw + // --help option + if (clim.count("help")) { + std::cout << "DBT-RISE-TGC simulator for TGC RISC-V cores" << std::endl << desc << std::endl; + return 0; + } + po::notify(clim); // throws on error, so do after help in case + } catch (po::error &e) { + // there are problems + std::cerr << "ERROR: " << e.what() << std::endl << std::endl; + std::cerr << desc << std::endl; + return 1; + } + std::vector args = collect_unrecognized(parsed.options, po::include_positional); + + LOGGER(DEFAULT)::print_time() = false; + LOGGER(connection)::print_time() = false; + auto l = logging::as_log_level(clim["verbose"].as()); + LOGGER(DEFAULT)::reporting_level() = l; + LOGGER(connection)::reporting_level() = l; + if (clim.count("logfile")) { + // configure the connection logger + auto f = fopen(clim["logfile"].as().c_str(), "w"); + LOG_OUTPUT(DEFAULT)::stream() = f; + LOG_OUTPUT(connection)::stream() = f; + } + + std::vector plugin_list; + auto res = 0; + try { +#ifdef WITH_LLVM + // application code comes here // + iss::init_jit_debug(argc, argv); +#endif + bool dump = clim.count("dump-ir"); + auto & f = iss::core_factory::instance(); + // instantiate the simulator + iss::vm_ptr vm{nullptr}; + iss::cpu_ptr cpu{nullptr}; + std::string isa_opt(clim["isa"].as()); + if(isa_opt.size()==0 || isa_opt == "?") { + auto list = f.get_names(); + std::sort(std::begin(list), std::end(list)); + std::cout<<"Available implementations (core|platform|backend):\n - "<(), clim["gdb-port"].as()); + } else { + auto base_isa = isa_opt.substr(0, 5); + if(base_isa=="tgc5d" || base_isa=="tgc5e") { + isa_opt += "|mu_p_clic_pmp|"+clim["backend"].as(); + } else { + isa_opt += "|m_p|"+clim["backend"].as(); + } + std::tie(cpu, vm) = f.create(isa_opt, clim["gdb-port"].as()); + } + if(!cpu ){ + LOG(ERR) << "Could not create cpu for isa " << isa_opt << " and backend " <()<< std::endl; + return 127; + } + if(!vm ){ + LOG(ERR) << "Could not create vm for isa " << isa_opt << " and backend " <()<< std::endl; + return 127; + } + if (clim.count("plugin")) { + for (std::string const& opt_val : clim["plugin"].as>()) { + std::string plugin_name=opt_val; + std::string arg{""}; + std::size_t found = opt_val.find('='); + if (found != std::string::npos) { + plugin_name = opt_val.substr(0, found); + arg = opt_val.substr(found + 1, opt_val.size()); + } +#if defined(WITH_PLUGINS) + if (plugin_name == "ic") { + auto *ic_plugin = new iss::plugin::instruction_count(arg); + vm->register_plugin(*ic_plugin); + plugin_list.push_back(ic_plugin); + } else if (plugin_name == "ce") { + auto *ce_plugin = new iss::plugin::cycle_estimate(arg); + vm->register_plugin(*ce_plugin); + plugin_list.push_back(ce_plugin); + } else +#endif + { +#if !defined(WIN32) + std::vector a{}; + if(arg.length()) + a.push_back({arg.c_str()}); + iss::plugin::loader l(plugin_name, {{"initPlugin"}}); + auto* plugin = l.call_function("initPlugin", a.size(), a.data()); + if(plugin){ + vm->register_plugin(*plugin); + plugin_list.push_back(plugin); + } else +#endif + { + LOG(ERR) << "Unknown plugin name: " << plugin_name << ", valid names are 'ce', 'ic'" << std::endl; + return 127; + } + } + } + } + if (clim.count("disass")) { + vm->setDisassEnabled(true); + LOGGER(disass)::reporting_level() = logging::INFO; + LOGGER(disass)::print_time() = false; + auto file_name = clim["disass"].as(); + if (file_name.length() > 0) { + LOG_OUTPUT(disass)::stream() = fopen(file_name.c_str(), "w"); + LOGGER(disass)::print_severity() = false; + } + } + uint64_t start_address = 0; + if (clim.count("mem")) + vm->get_arch()->load_file(clim["mem"].as()); + if (clim.count("elf")) + for (std::string input : clim["elf"].as>()) { + auto start_addr = vm->get_arch()->load_file(input); + if (start_addr.second) start_address = start_addr.first; + } + for (std::string input : args) { + auto start_addr = vm->get_arch()->load_file(input); // treat remaining arguments as elf files + if (start_addr.second) start_address = start_addr.first; + } + if (clim.count("reset")) { + auto str = clim["reset"].as(); + start_address = str.find("0x") == 0 ? std::stoull(str.substr(2), nullptr, 16) : std::stoull(str, nullptr, 10); + } + vm->reset(start_address); + auto cycles = clim["instructions"].as(); + res = vm->start(cycles, dump); + } catch (std::exception &e) { + LOG(ERR) << "Unhandled Exception reached the top of main: " << e.what() << ", application will now exit" + << std::endl; + res = 2; + } + // cleanup to let plugins report of needed + for (auto *p : plugin_list) { + delete p; + } + return res; +} From aa12e93177eadbf5e4131a9768056c1b14e7fa8c Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Wed, 18 Oct 2023 11:17:20 +0200 Subject: [PATCH 09/13] adds RPATH setting to install --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86197b5..fed2f4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,7 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss COMPONENT ${PROJECT_NAME} ############################################################################### # ############################################################################### +set(CMAKE_INSTALL_RPATH $ORIGIN/../${CMAKE_INSTALL_LIBDIR}) project(tgc-sim) find_package(Boost COMPONENTS program_options thread REQUIRED) From 74ff1d455a43d83929c28017a31f14247077dfa8 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Fri, 20 Oct 2023 20:38:59 +0200 Subject: [PATCH 10/13] fixes install routine --- CMakeLists.txt | 2 ++ src/iss/plugin/cycle_estimate.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fed2f4b..59e613c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ endif() # library files FILE(GLOB GEN_ISS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp) FILE(GLOB GEN_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/interp/vm_*.cpp) +FILE(GLOB GEN_YAML_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.yaml) list(APPEND LIB_SOURCES ${GEN_ISS_SOURCES} ${GEN_VM_SOURCES}) foreach(FILEPATH ${GEN_ISS_SOURCES}) get_filename_component(CORE ${FILEPATH} NAME_WE) @@ -112,6 +113,7 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss COMPONENT ${PROJECT_NAME} FILES_MATCHING # install only matched files PATTERN "*.h" # select header files ) +install(FILES ${GEN_YAML_SOURCES} DESTINATION share/tgc-vp) ############################################################################### # ############################################################################### diff --git a/src/iss/plugin/cycle_estimate.cpp b/src/iss/plugin/cycle_estimate.cpp index 267c88e..b389cb4 100644 --- a/src/iss/plugin/cycle_estimate.cpp +++ b/src/iss/plugin/cycle_estimate.cpp @@ -1,3 +1,4 @@ + /******************************************************************************* * Copyright (C) 2017 - 2023, MINRES Technologies GmbH * All rights reserved. @@ -60,7 +61,7 @@ bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if& try { auto root = YAML::LoadAll(is); if(root.size()!=1) { - LOG(ERR) << "Too many rro nodes in YAML file " << config_file_name; + LOG(ERR) << "Too many root nodes in YAML file " << config_file_name; } for (auto p : root[0]) { auto isa_subset = p.first; @@ -97,7 +98,7 @@ void iss::plugin::cycle_estimate::callback(instr_info_t instr_info) { auto entry = delays[instr_info.instr_id]; bool taken = instr_if->is_branch_taken(); if (taken && (entry.taken > 1)) - instr_if->update_last_instr_cycles(entry.taken); - else if (entry.not_taken > 1) - instr_if->update_last_instr_cycles(entry.not_taken); + instr_if->update_last_instr_cycles(entry.taken); + else if (entry.not_taken > 1) + instr_if->update_last_instr_cycles(entry.not_taken); } From 3a86f4f9de436172a6c4427686127fb81b6244e6 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Oct 2023 17:19:24 +0200 Subject: [PATCH 11/13] does some cleanup of generated files --- .settings/org.eclipse.cdt.codan.core.prefs | 73 -------------- .settings/org.eclipse.cdt.core.prefs | 13 --- .../org.eclipse.cdt.managedbuilder.core.prefs | 37 -------- .../instr/TGC5C_instr.yaml | 94 ++++++++++++++++++- gen_input/templates/CORENAME_instr.yaml.gtl | 3 +- 5 files changed, 95 insertions(+), 125 deletions(-) delete mode 100644 .settings/org.eclipse.cdt.codan.core.prefs delete mode 100644 .settings/org.eclipse.cdt.core.prefs delete mode 100644 .settings/org.eclipse.cdt.managedbuilder.core.prefs rename TGC5C_instr.yaml => contrib/instr/TGC5C_instr.yaml (89%) diff --git a/.settings/org.eclipse.cdt.codan.core.prefs b/.settings/org.eclipse.cdt.codan.core.prefs deleted file mode 100644 index 067d6fd..0000000 --- a/.settings/org.eclipse.cdt.codan.core.prefs +++ /dev/null @@ -1,73 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.cdt.codan.checkers.errnoreturn=Warning -org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false} -org.eclipse.cdt.codan.checkers.errreturnvalue=Error -org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"} -org.eclipse.cdt.codan.checkers.nocommentinside=-Error -org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"} -org.eclipse.cdt.codan.checkers.nolinecomment=-Error -org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"} -org.eclipse.cdt.codan.checkers.noreturn=Error -org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false} -org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error -org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"} -org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error -org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"} -org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning -org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"} -org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error -org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"} -org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning -org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false} -org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning -org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()} -org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error -org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"} -org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning -org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true} -org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem=Error -org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"} -org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error -org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"} -org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error -org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"} -org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error -org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"} -org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error -org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"} -org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error -org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"} -org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error -org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"} -org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error -org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"} -org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info -org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} -org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning -org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"} -org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error -org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"} -org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error -org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"} -org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error -org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"} -org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning -org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"} -org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning -org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"} -org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning -org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()} -org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning -org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false} -org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning -org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false} -org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error -org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"} -org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning -org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true} -org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning -org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true} -org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning -org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")} -org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error -org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"} diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs deleted file mode 100644 index 7982989..0000000 --- a/.settings/org.eclipse.cdt.core.prefs +++ /dev/null @@ -1,13 +0,0 @@ -eclipse.preferences.version=1 -environment/project/cdt.managedbuild.config.gnu.exe.debug.1751741082/append=true -environment/project/cdt.managedbuild.config.gnu.exe.debug.1751741082/appendContributed=true -environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/LLVM_HOME/delimiter=\: -environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/LLVM_HOME/operation=append -environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/LLVM_HOME/value=/usr/lib/llvm-6.0 -environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/append=true -environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/appendContributed=true -environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171/LLVM_HOME/delimiter=\: -environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171/LLVM_HOME/operation=append -environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171/LLVM_HOME/value=/usr/lib/llvm-6.0 -environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171/append=true -environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171/appendContributed=true diff --git a/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/.settings/org.eclipse.cdt.managedbuilder.core.prefs deleted file mode 100644 index f299fce..0000000 --- a/.settings/org.eclipse.cdt.managedbuilder.core.prefs +++ /dev/null @@ -1,37 +0,0 @@ -eclipse.preferences.version=1 -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/CPATH/delimiter=\: -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/CPATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/CPLUS_INCLUDE_PATH/delimiter=\: -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/CPLUS_INCLUDE_PATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/C_INCLUDE_PATH/delimiter=\: -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/C_INCLUDE_PATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/append=true -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/appendContributed=true -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/CPATH/delimiter=\: -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/CPATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/CPLUS_INCLUDE_PATH/delimiter=\: -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/CPLUS_INCLUDE_PATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/C_INCLUDE_PATH/delimiter=\: -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/C_INCLUDE_PATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/append=true -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/appendContributed=true -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/CPATH/delimiter=\: -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/CPATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/CPLUS_INCLUDE_PATH/delimiter=\: -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/CPLUS_INCLUDE_PATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/C_INCLUDE_PATH/delimiter=\: -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/C_INCLUDE_PATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/append=true -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/appendContributed=true -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1751741082/LIBRARY_PATH/delimiter=\: -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1751741082/LIBRARY_PATH/operation=remove -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1751741082/append=true -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1751741082/appendContributed=true -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/LIBRARY_PATH/delimiter=\: -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/LIBRARY_PATH/operation=remove -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/append=true -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/appendContributed=true -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171/LIBRARY_PATH/delimiter=\: -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171/LIBRARY_PATH/operation=remove -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171/append=true -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171/appendContributed=true diff --git a/TGC5C_instr.yaml b/contrib/instr/TGC5C_instr.yaml similarity index 89% rename from TGC5C_instr.yaml rename to contrib/instr/TGC5C_instr.yaml index 8f14fe9..6ea4d78 100644 --- a/TGC5C_instr.yaml +++ b/contrib/instr/TGC5C_instr.yaml @@ -1,246 +1,289 @@ RV32I: LUI: + index: 0 encoding: 0b00000000000000000000000000110111 mask: 0b00000000000000000000000001111111 size: 32 branch: false delay: 1 AUIPC: + index: 1 encoding: 0b00000000000000000000000000010111 mask: 0b00000000000000000000000001111111 size: 32 branch: false delay: 1 JAL: + index: 2 encoding: 0b00000000000000000000000001101111 mask: 0b00000000000000000000000001111111 size: 32 branch: true delay: 1 JALR: + index: 3 encoding: 0b00000000000000000000000001100111 mask: 0b00000000000000000111000001111111 size: 32 branch: true delay: [1,1] BEQ: + index: 4 encoding: 0b00000000000000000000000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true delay: [1,1] BNE: + index: 5 encoding: 0b00000000000000000001000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true delay: [1,1] BLT: + index: 6 encoding: 0b00000000000000000100000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true delay: [1,1] BGE: + index: 7 encoding: 0b00000000000000000101000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true delay: [1,1] BLTU: + index: 8 encoding: 0b00000000000000000110000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true delay: [1,1] BGEU: + index: 9 encoding: 0b00000000000000000111000001100011 mask: 0b00000000000000000111000001111111 size: 32 branch: true delay: [1,1] LB: + index: 10 encoding: 0b00000000000000000000000000000011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 LH: + index: 11 encoding: 0b00000000000000000001000000000011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 LW: + index: 12 encoding: 0b00000000000000000010000000000011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 LBU: + index: 13 encoding: 0b00000000000000000100000000000011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 LHU: + index: 14 encoding: 0b00000000000000000101000000000011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 SB: + index: 15 encoding: 0b00000000000000000000000000100011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 SH: + index: 16 encoding: 0b00000000000000000001000000100011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 SW: + index: 17 encoding: 0b00000000000000000010000000100011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 ADDI: + index: 18 encoding: 0b00000000000000000000000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 SLTI: + index: 19 encoding: 0b00000000000000000010000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 SLTIU: + index: 20 encoding: 0b00000000000000000011000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 XORI: + index: 21 encoding: 0b00000000000000000100000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 ORI: + index: 22 encoding: 0b00000000000000000110000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 ANDI: + index: 23 encoding: 0b00000000000000000111000000010011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 SLLI: + index: 24 encoding: 0b00000000000000000001000000010011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 SRLI: + index: 25 encoding: 0b00000000000000000101000000010011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 SRAI: + index: 26 encoding: 0b01000000000000000101000000010011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 ADD: + index: 27 encoding: 0b00000000000000000000000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 SUB: + index: 28 encoding: 0b01000000000000000000000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 SLL: + index: 29 encoding: 0b00000000000000000001000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 SLT: + index: 30 encoding: 0b00000000000000000010000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 SLTU: + index: 31 encoding: 0b00000000000000000011000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 XOR: + index: 32 encoding: 0b00000000000000000100000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 SRL: + index: 33 encoding: 0b00000000000000000101000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 SRA: + index: 34 encoding: 0b01000000000000000101000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 OR: + index: 35 encoding: 0b00000000000000000110000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 AND: + index: 36 encoding: 0b00000000000000000111000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 FENCE: + index: 37 encoding: 0b00000000000000000000000000001111 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 ECALL: + index: 38 encoding: 0b00000000000000000000000001110011 mask: 0b11111111111111111111111111111111 + attributes: [[name:no_cont]] size: 32 branch: false delay: 1 EBREAK: + index: 39 encoding: 0b00000000000100000000000001110011 mask: 0b11111111111111111111111111111111 + attributes: [[name:no_cont]] size: 32 branch: false delay: 1 MRET: + index: 40 encoding: 0b00110000001000000000000001110011 mask: 0b11111111111111111111111111111111 attributes: [[name:no_cont]] @@ -248,6 +291,7 @@ RV32I: branch: false delay: 1 WFI: + index: 41 encoding: 0b00010000010100000000000001110011 mask: 0b11111111111111111111111111111111 size: 32 @@ -255,36 +299,42 @@ RV32I: delay: 1 Zicsr: CSRRW: + index: 42 encoding: 0b00000000000000000001000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 CSRRS: + index: 43 encoding: 0b00000000000000000010000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 CSRRC: + index: 44 encoding: 0b00000000000000000011000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 CSRRWI: + index: 45 encoding: 0b00000000000000000101000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 CSRRSI: + index: 46 encoding: 0b00000000000000000110000001110011 mask: 0b00000000000000000111000001111111 size: 32 branch: false delay: 1 CSRRCI: + index: 47 encoding: 0b00000000000000000111000001110011 mask: 0b00000000000000000111000001111111 size: 32 @@ -292,6 +342,7 @@ Zicsr: delay: 1 Zifencei: FENCE_I: + index: 48 encoding: 0b00000000000000000001000000001111 mask: 0b00000000000000000111000001111111 attributes: [[name:flush]] @@ -300,175 +351,207 @@ Zifencei: delay: 1 RV32M: MUL: + index: 49 encoding: 0b00000010000000000000000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 MULH: + index: 50 encoding: 0b00000010000000000001000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 MULHSU: + index: 51 encoding: 0b00000010000000000010000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 MULHU: + index: 52 encoding: 0b00000010000000000011000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 DIV: + index: 53 encoding: 0b00000010000000000100000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 DIVU: + index: 54 encoding: 0b00000010000000000101000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 REM: + index: 55 encoding: 0b00000010000000000110000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 REMU: + index: 56 encoding: 0b00000010000000000111000000110011 mask: 0b11111110000000000111000001111111 size: 32 branch: false delay: 1 -RV32IC: +Zca: C__ADDI4SPN: + index: 57 encoding: 0b0000000000000000 mask: 0b1110000000000011 size: 16 branch: false delay: 1 C__LW: + index: 58 encoding: 0b0100000000000000 mask: 0b1110000000000011 size: 16 branch: false delay: 1 C__SW: + index: 59 encoding: 0b1100000000000000 mask: 0b1110000000000011 size: 16 branch: false delay: 1 C__ADDI: + index: 60 encoding: 0b0000000000000001 mask: 0b1110000000000011 size: 16 branch: false delay: 1 C__NOP: + index: 61 encoding: 0b0000000000000001 mask: 0b1110111110000011 size: 16 branch: false delay: 1 C__JAL: + index: 62 encoding: 0b0010000000000001 mask: 0b1110000000000011 + attributes: [[name:enable, value:1]] size: 16 branch: true delay: 1 C__LI: + index: 63 encoding: 0b0100000000000001 mask: 0b1110000000000011 size: 16 branch: false delay: 1 C__LUI: + index: 64 encoding: 0b0110000000000001 mask: 0b1110000000000011 size: 16 branch: false delay: 1 C__ADDI16SP: + index: 65 encoding: 0b0110000100000001 mask: 0b1110111110000011 size: 16 branch: false delay: 1 __reserved_clui: + index: 66 encoding: 0b0110000000000001 mask: 0b1111000001111111 size: 16 branch: false delay: 1 C__SRLI: + index: 67 encoding: 0b1000000000000001 mask: 0b1111110000000011 + attributes: [[name:enable, value:1]] size: 16 branch: false delay: 1 C__SRAI: + index: 68 encoding: 0b1000010000000001 mask: 0b1111110000000011 + attributes: [[name:enable, value:1]] size: 16 branch: false delay: 1 C__ANDI: + index: 69 encoding: 0b1000100000000001 mask: 0b1110110000000011 size: 16 branch: false delay: 1 C__SUB: + index: 70 encoding: 0b1000110000000001 mask: 0b1111110001100011 size: 16 branch: false delay: 1 C__XOR: + index: 71 encoding: 0b1000110000100001 mask: 0b1111110001100011 size: 16 branch: false delay: 1 C__OR: + index: 72 encoding: 0b1000110001000001 mask: 0b1111110001100011 size: 16 branch: false delay: 1 C__AND: + index: 73 encoding: 0b1000110001100001 mask: 0b1111110001100011 size: 16 branch: false delay: 1 C__J: + index: 74 encoding: 0b1010000000000001 mask: 0b1110000000000011 size: 16 branch: true delay: 1 C__BEQZ: + index: 75 encoding: 0b1100000000000001 mask: 0b1110000000000011 size: 16 branch: true delay: [1,1] C__BNEZ: + index: 76 encoding: 0b1110000000000001 mask: 0b1110000000000011 size: 16 branch: true delay: [1,1] C__SLLI: + index: 77 encoding: 0b0000000000000010 mask: 0b1111000000000011 attributes: [[name:enable, value:1]] @@ -476,54 +559,63 @@ RV32IC: branch: false delay: 1 C__LWSP: + index: 78 encoding: 0b0100000000000010 mask: 0b1110000000000011 size: 16 branch: false delay: 1 C__MV: + index: 79 encoding: 0b1000000000000010 mask: 0b1111000000000011 size: 16 branch: false delay: 1 C__JR: + index: 80 encoding: 0b1000000000000010 mask: 0b1111000001111111 size: 16 branch: true delay: 1 __reserved_cmv: + index: 81 encoding: 0b1000000000000010 mask: 0b1111111111111111 size: 16 branch: false delay: 1 C__ADD: + index: 82 encoding: 0b1001000000000010 mask: 0b1111000000000011 size: 16 branch: false delay: 1 C__JALR: + index: 83 encoding: 0b1001000000000010 mask: 0b1111000001111111 size: 16 branch: true delay: 1 C__EBREAK: + index: 84 encoding: 0b1001000000000010 mask: 0b1111111111111111 size: 16 branch: false delay: 1 C__SWSP: + index: 85 encoding: 0b1100000000000010 mask: 0b1110000000000011 size: 16 branch: false delay: 1 DII: + index: 86 encoding: 0b0000000000000000 mask: 0b1111111111111111 size: 16 diff --git a/gen_input/templates/CORENAME_instr.yaml.gtl b/gen_input/templates/CORENAME_instr.yaml.gtl index 6710a1a..d9fdcbf 100644 --- a/gen_input/templates/CORENAME_instr.yaml.gtl +++ b/gen_input/templates/CORENAME_instr.yaml.gtl @@ -8,9 +8,10 @@ instrGroups[groupName]+=it; } instrGroups -}%><%getInstructionGroups().each{name, instrList -> %> +}%><%int index = 0; getInstructionGroups().each{name, instrList -> %> ${name}: <% instrList.each { %> ${it.instruction.name}: + index: ${index++} encoding: ${it.encoding} mask: ${it.mask}<%if(it.attributes.size) {%> attributes: ${it.attributes}<%}%> From 82c26acfc871c0ba82a69481f8383733ad174509 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Oct 2023 17:26:03 +0200 Subject: [PATCH 12/13] does some cleanup of the directory structure --- CMakeLists.txt | 2 +- contrib/{ => pa}/.gitignore | 0 contrib/{ => pa}/README.md | 4 ++-- contrib/{ => pa}/build.tcl | 0 contrib/{ => pa}/hello.dis | 0 contrib/{ => pa}/hello.elf | Bin contrib/{ => pa}/minres.png | Bin contrib/{ => pa}/tgc_import.cc | 0 contrib/{ => pa}/tgc_import.tcl | 0 contrib/{ => pa}/tgc_import_tb.tcl | 0 10 files changed, 3 insertions(+), 3 deletions(-) rename contrib/{ => pa}/.gitignore (100%) rename contrib/{ => pa}/README.md (96%) rename contrib/{ => pa}/build.tcl (100%) rename contrib/{ => pa}/hello.dis (100%) rename contrib/{ => pa}/hello.elf (100%) rename contrib/{ => pa}/minres.png (100%) rename contrib/{ => pa}/tgc_import.cc (100%) rename contrib/{ => pa}/tgc_import.tcl (100%) rename contrib/{ => pa}/tgc_import_tb.tcl (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59e613c..42448ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ endif() # library files FILE(GLOB GEN_ISS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp) FILE(GLOB GEN_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/interp/vm_*.cpp) -FILE(GLOB GEN_YAML_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.yaml) +FILE(GLOB GEN_YAML_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/contrib/instr/*.yaml) list(APPEND LIB_SOURCES ${GEN_ISS_SOURCES} ${GEN_VM_SOURCES}) foreach(FILEPATH ${GEN_ISS_SOURCES}) get_filename_component(CORE ${FILEPATH} NAME_WE) diff --git a/contrib/.gitignore b/contrib/pa/.gitignore similarity index 100% rename from contrib/.gitignore rename to contrib/pa/.gitignore diff --git a/contrib/README.md b/contrib/pa/README.md similarity index 96% rename from contrib/README.md rename to contrib/pa/README.md index c65d9f6..3c1c287 100644 --- a/contrib/README.md +++ b/contrib/pa/README.md @@ -19,7 +19,7 @@ setenv CXX $COWAREHOME/SLS/linux/common/bin/g++ cmake -S . -B build/PA -DCMAKE_BUILD_TYPE=Debug -DUSE_CWR_SYSTEMC=ON -DBUILD_SHARED_LIBS=ON \ -DCODEGEN=OFF -DCMAKE_INSTALL_PREFIX=${TGFS_INSTALL_ROOT} cmake --build build/PA --target install -j16 -cd dbt-rise-tgc/contrib +cd dbt-rise-tgc/contrib/pa # import the TGC core itself pct tgc_import_tb.tcl ``` @@ -37,7 +37,7 @@ export CXX=$COWAREHOME/SLS/linux/common/bin/g++ cmake -S . -B build/PA -DCMAKE_BUILD_TYPE=Debug -DUSE_CWR_SYSTEMC=ON -DBUILD_SHARED_LIBS=ON \ -DCODEGEN=OFF -DCMAKE_INSTALL_PREFIX=${TGFS_INSTALL_ROOT} cmake --build build/PA --target install -j16 -cd dbt-rise-tgc/contrib +cd dbt-rise-tgc/contrib/pa # import the TGC core itself pct tgc_import_tb.tcl ``` \ No newline at end of file diff --git a/contrib/build.tcl b/contrib/pa/build.tcl similarity index 100% rename from contrib/build.tcl rename to contrib/pa/build.tcl diff --git a/contrib/hello.dis b/contrib/pa/hello.dis similarity index 100% rename from contrib/hello.dis rename to contrib/pa/hello.dis diff --git a/contrib/hello.elf b/contrib/pa/hello.elf similarity index 100% rename from contrib/hello.elf rename to contrib/pa/hello.elf diff --git a/contrib/minres.png b/contrib/pa/minres.png similarity index 100% rename from contrib/minres.png rename to contrib/pa/minres.png diff --git a/contrib/tgc_import.cc b/contrib/pa/tgc_import.cc similarity index 100% rename from contrib/tgc_import.cc rename to contrib/pa/tgc_import.cc diff --git a/contrib/tgc_import.tcl b/contrib/pa/tgc_import.tcl similarity index 100% rename from contrib/tgc_import.tcl rename to contrib/pa/tgc_import.tcl diff --git a/contrib/tgc_import_tb.tcl b/contrib/pa/tgc_import_tb.tcl similarity index 100% rename from contrib/tgc_import_tb.tcl rename to contrib/pa/tgc_import_tb.tcl From 4c3a7386b0481dc117fef9e3639748d60e72a4c7 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 22 Oct 2023 08:51:08 +0200 Subject: [PATCH 13/13] updates generated files --- contrib/instr/.gitignore | 1 + src/vm/interp/vm_tgc5c.cpp | 13 ++++++------- src/vm/tcc/vm_tgc5c.cpp | 23 +++++++++++------------ 3 files changed, 18 insertions(+), 19 deletions(-) create mode 100644 contrib/instr/.gitignore diff --git a/contrib/instr/.gitignore b/contrib/instr/.gitignore new file mode 100644 index 0000000..88b59f2 --- /dev/null +++ b/contrib/instr/.gitignore @@ -0,0 +1 @@ +/*.yaml \ No newline at end of file diff --git a/src/vm/interp/vm_tgc5c.cpp b/src/vm/interp/vm_tgc5c.cpp index 4f4e494..d5d635c 100644 --- a/src/vm/interp/vm_tgc5c.cpp +++ b/src/vm/interp/vm_tgc5c.cpp @@ -36,10 +36,11 @@ #include #include #include -#include #include #include #include +#include +#include #ifndef FMT_HEADER_ONLY #define FMT_HEADER_ONLY @@ -2522,8 +2523,7 @@ typename vm_base::virt_addr_t vm_impl::execute_inst(finish_cond_e co // execute instruction { if(rs1 && rs1 < traits::RFS) { - uint32_t addr_mask = (uint32_t)- 2; - *NEXT_PC = *(X+rs1 % traits::RFS) & addr_mask; + *NEXT_PC = *(X+rs1 % traits::RFS) & ~ 0x1; this->core.reg.last_branch = 1; } else { @@ -2589,10 +2589,9 @@ typename vm_base::virt_addr_t vm_impl::execute_inst(finish_cond_e co raise(0, 2); } else { - uint32_t addr_mask = (uint32_t)- 2; uint32_t new_pc = *(X+rs1); *(X+1) = (uint32_t)(*PC + 2); - *NEXT_PC = new_pc & addr_mask; + *NEXT_PC = new_pc & ~ 0x1; this->core.reg.last_branch = 1; } } @@ -2699,13 +2698,13 @@ volatile std::array dummy = { auto vm = new interp::tgc5c::vm_impl(*cpu, false); if (port != 0) debugger::server::run_server(vm, port); return {cpu_ptr{cpu}, vm_ptr{vm}}; - })/*, + }), core_factory::instance().register_creator("tgc5c|mu_p|interp", [](unsigned port, void*) -> std::tuple{ auto* cpu = new iss::arch::riscv_hart_mu_p(); auto vm = new interp::tgc5c::vm_impl(*cpu, false); if (port != 0) debugger::server::run_server(vm, port); return {cpu_ptr{cpu}, vm_ptr{vm}}; - })*/ + }) }; } } diff --git a/src/vm/tcc/vm_tgc5c.cpp b/src/vm/tcc/vm_tgc5c.cpp index 3e8511b..23a0060 100644 --- a/src/vm/tcc/vm_tgc5c.cpp +++ b/src/vm/tcc/vm_tgc5c.cpp @@ -3303,12 +3303,12 @@ private: pc=pc+ 2; gen_set_pc(tu, pc, traits::NEXT_PC); tu.open_scope(); - if(rs1&&rs1(traits:: RFS)){ auto addr_mask = tu.assignment(tu.constant((uint32_t)- 2,32),32); - auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and( - tu.load(rs1%static_cast(traits:: RFS)+ traits::X0, 0), - addr_mask),32); - tu.store(traits::NEXT_PC, PC_val_v); - tu.store(traits::LAST_BRANCH, tu.constant(2U, 2)); + if(rs1&&rs1(traits:: RFS)) { + auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and( + tu.load(rs1%static_cast(traits:: RFS)+ traits::X0, 0), + tu.constant(~ 0x1,8)),32); + tu.store(traits::NEXT_PC, PC_val_v); + tu.store(traits::LAST_BRANCH, tu.constant(2U, 2)); } else{ this->gen_raise_trap(tu, 0, 2); @@ -3401,13 +3401,12 @@ private: this->gen_raise_trap(tu, 0, 2); } else{ - auto addr_mask = tu.assignment(tu.constant((uint32_t)- 2,32),32); auto new_pc = tu.assignment(tu.load(rs1+ traits::X0, 0),32); tu.store(1 + traits::X0, tu.constant((uint32_t)(PC+ 2),32)); auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and( new_pc, - addr_mask),32); + tu.constant(~ 0x1,8)),32); tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2)); } @@ -3433,7 +3432,7 @@ private: gen_set_pc(tu, pc, traits::NEXT_PC); tu.open_scope(); this->gen_raise_trap(tu, 0, 3); - auto returnValue = std::make_tuple(TRAP); + auto returnValue = std::make_tuple(CONT); tu.close_scope(); gen_trap_check(tu); @@ -3490,7 +3489,7 @@ private: gen_set_pc(tu, pc, traits::NEXT_PC); tu.open_scope(); this->gen_raise_trap(tu, 0, 2); - auto returnValue = std::make_tuple(TRAP); + auto returnValue = std::make_tuple(CONT); tu.close_scope(); gen_trap_check(tu); @@ -3655,13 +3654,13 @@ volatile std::array dummy = { auto vm = new tcc::tgc5c::vm_impl(*cpu, false); if (port != 0) debugger::server::run_server(vm, port); return {cpu_ptr{cpu}, vm_ptr{vm}}; - })/*, + }), core_factory::instance().register_creator("tgc5c|mu_p|tcc", [](unsigned port, void*) -> std::tuple{ auto* cpu = new iss::arch::riscv_hart_mu_p(); auto vm = new tcc::tgc5c::vm_impl(*cpu, false); if (port != 0) debugger::server::run_server(vm, port); return {cpu_ptr{cpu}, vm_ptr{vm}}; - })*/ + }) }; } }