diff --git a/gen_input/templates/interp/CORENAME.cpp.gtl b/gen_input/templates/interp/CORENAME.cpp.gtl index c8b3af2..f305cbb 100644 --- a/gen_input/templates/interp/CORENAME.cpp.gtl +++ b/gen_input/templates/interp/CORENAME.cpp.gtl @@ -272,6 +272,9 @@ vm_impl::vm_impl(ARCH &core, unsigned core_id, unsigned cluster_id) } } +inline bool is_count_limit_enabled(finish_cond_e cond){ + return (cond & finish_cond_e::COUNT_LIMIT) == finish_cond_e::COUNT_LIMIT; +} template typename vm_base::virt_addr_t vm_impl::execute_inst(finish_cond_e cond, virt_addr_t start, uint64_t icount_limit){ // we fetch at max 4 byte, alignment is 2 @@ -279,8 +282,8 @@ typename vm_base::virt_addr_t vm_impl::execute_inst(finish_cond_e co code_word_t insn = 0; auto *const data = (uint8_t *)&insn; auto pc=start; - while(!core.should_stop() && - !((cond & finish_cond_e::COUNT_LIMIT) && core.get_icount() < icount)){ + while(!this->core.should_stop() && + !(is_count_limit_enabled(cond) && this->core.get_icount() >= icount_limit)){ auto res = fetch_ins(pc, data); if(res!=iss::Ok){ auto new_pc = super::core.enter_trap(TRAP_ID, pc.val); diff --git a/incl/sysc/core_complex.h b/incl/sysc/core_complex.h index b339ce0..22dd259 100644 --- a/incl/sysc/core_complex.h +++ b/incl/sysc/core_complex.h @@ -97,7 +97,7 @@ public: cci::cci_param reset_address{"reset_address", 0ULL}; - cci::cci_param backend{"backend", "tcc"}; + cci::cci_param backend{"backend", "interp"}; cci::cci_param gdb_server_port{"gdb_server_port", 0}; diff --git a/src/sysc/core_complex.cpp b/src/sysc/core_complex.cpp index c77648f..bf88030 100644 --- a/src/sysc/core_complex.cpp +++ b/src/sysc/core_complex.cpp @@ -290,6 +290,7 @@ void core_complex::before_end_of_elaboration() { cpu->set_mhartid(mhartid.get_value()); vm = create_cpu(cpu.get(), backend.get_value(), gdb_server_port.get_value()); + sc_assert(vm!=nullptr); #ifdef WITH_SCV vm->setDisassEnabled(enable_disass.get_value() || m_db != nullptr); #else diff --git a/src/vm/interp/vm_tgf_c.cpp b/src/vm/interp/vm_tgf_c.cpp index 2764ac8..11e811a 100644 --- a/src/vm/interp/vm_tgf_c.cpp +++ b/src/vm/interp/vm_tgf_c.cpp @@ -3435,6 +3435,9 @@ vm_impl::vm_impl(ARCH &core, unsigned core_id, unsigned cluster_id) } } +inline bool is_count_limit_enabled(finish_cond_e cond){ + return (cond & finish_cond_e::COUNT_LIMIT) == finish_cond_e::COUNT_LIMIT; +} template typename vm_base::virt_addr_t vm_impl::execute_inst(finish_cond_e cond, virt_addr_t start, uint64_t icount_limit){ // we fetch at max 4 byte, alignment is 2 @@ -3443,8 +3446,7 @@ typename vm_base::virt_addr_t vm_impl::execute_inst(finish_cond_e co auto *const data = (uint8_t *)&insn; auto pc=start; while(!this->core.should_stop() && - !((cond & finish_cond_e::COUNT_LIMIT) == finish_cond_e::COUNT_LIMIT && - this->core.get_icount() < icount_limit)){ + !(is_count_limit_enabled(cond) && this->core.get_icount() >= icount_limit)){ auto res = fetch_ins(pc, data); if(res!=iss::Ok){ auto new_pc = super::core.enter_trap(TRAP_ID, pc.val);