Fixed implementation of RV64 so that remaining riscv-test pass
This commit is contained in:
+21
-12
@@ -4,22 +4,16 @@ set(LIB_HEADERS ${RiscVSCHeaders} )
|
||||
set(LIB_SOURCES
|
||||
iss/rv32gc.cpp
|
||||
iss/rv32imac.cpp
|
||||
iss/rv64ia.cpp
|
||||
iss/rv64i.cpp
|
||||
iss/rv64gc.cpp
|
||||
internal/fp_functions.cpp
|
||||
internal/vm_rv32gc.cpp
|
||||
internal/vm_rv32imac.cpp
|
||||
internal/vm_rv64ia.cpp
|
||||
internal/vm_rv64i.cpp
|
||||
internal/vm_rv64gc.cpp
|
||||
plugin/instruction_count.cpp
|
||||
plugin/cycle_estimate.cpp)
|
||||
|
||||
if(SystemC_FOUND)
|
||||
set(LIB_SOURCES ${LIB_SOURCES} sysc/core_complex.cpp)
|
||||
endif()
|
||||
|
||||
set(APP_HEADERS )
|
||||
|
||||
set(APP_SOURCES main.cpp)
|
||||
|
||||
# Define two variables in order not to repeat ourselves.
|
||||
set(LIBRARY_NAME riscv)
|
||||
|
||||
@@ -31,8 +25,11 @@ set_target_properties(${LIBRARY_NAME} PROPERTIES
|
||||
FRAMEWORK FALSE
|
||||
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
||||
)
|
||||
#set_property(TARGET ${LIBRARY_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(SystemC_FOUND)
|
||||
set(SC_LIBRARY_NAME riscv_sc)
|
||||
add_library(${SC_LIBRARY_NAME} SHARED sysc/core_complex.cpp)
|
||||
add_definitions(-DWITH_SYSTEMC)
|
||||
include_directories(${SystemC_INCLUDE_DIRS})
|
||||
|
||||
@@ -42,18 +39,30 @@ if(SystemC_FOUND)
|
||||
add_definitions(-DWITH_SCV)
|
||||
include_directories(${SCV_INCLUDE_DIRS})
|
||||
endif()
|
||||
set_target_properties(${SC_LIBRARY_NAME} PROPERTIES
|
||||
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
|
||||
FRAMEWORK FALSE
|
||||
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
||||
)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} ${LIBRARY_NAME})
|
||||
target_link_libraries(${SC_LIBRARY_NAME} dbt-core)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} softfloat)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} sc-components)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} external)
|
||||
target_link_libraries(${SC_LIBRARY_NAME} ${llvm_libs})
|
||||
target_link_libraries(${SC_LIBRARY_NAME} ${Boost_LIBRARIES} )
|
||||
endif()
|
||||
|
||||
# This is a make target, so you can do a "make riscv-sc"
|
||||
set(APPLICATION_NAME riscv-sim)
|
||||
|
||||
add_executable(${APPLICATION_NAME} ${APP_SOURCES})
|
||||
add_executable(${APPLICATION_NAME} main.cpp)
|
||||
|
||||
# Links the target exe against the libraries
|
||||
target_link_libraries(${APPLICATION_NAME} ${LIBRARY_NAME})
|
||||
target_link_libraries(${APPLICATION_NAME} jsoncpp)
|
||||
target_link_libraries(${APPLICATION_NAME} dbt-core)
|
||||
target_link_libraries(${APPLICATION_NAME} softfloat)
|
||||
target_link_libraries(${APPLICATION_NAME} sc-components)
|
||||
target_link_libraries(${APPLICATION_NAME} external)
|
||||
target_link_libraries(${APPLICATION_NAME} ${llvm_libs})
|
||||
target_link_libraries(${APPLICATION_NAME} ${Boost_LIBRARIES} )
|
||||
|
||||
@@ -70,7 +70,7 @@ using namespace std;
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
void add_fp_functions_2_module(Module *mod, uint32_t flen) {
|
||||
void add_fp_functions_2_module(Module *mod, uint32_t flen, uint32_t xlen) {
|
||||
if(flen){
|
||||
FDECL(fget_flags, INT_TYPE(32));
|
||||
FDECL(fadd_s, INT_TYPE(32), INT_TYPE(32), INT_TYPE(32), INT_TYPE(8));
|
||||
@@ -83,6 +83,8 @@ void add_fp_functions_2_module(Module *mod, uint32_t flen) {
|
||||
FDECL(fmadd_s, INT_TYPE(32), INT_TYPE(32), INT_TYPE(32), INT_TYPE(32), INT_TYPE(32), INT_TYPE(8));
|
||||
FDECL(fsel_s, INT_TYPE(32), INT_TYPE(32), INT_TYPE(32), INT_TYPE(32));
|
||||
FDECL(fclass_s, INT_TYPE(32), INT_TYPE(32));
|
||||
FDECL(fcvt_32_64, INT_TYPE(64), INT_TYPE(32), INT_TYPE(32), INT_TYPE(8));
|
||||
FDECL(fcvt_64_32, INT_TYPE(32), INT_TYPE(64), INT_TYPE(32), INT_TYPE(8));
|
||||
if(flen>32){
|
||||
FDECL(fconv_d2f, INT_TYPE(32), INT_TYPE(64), INT_TYPE(8));
|
||||
FDECL(fconv_f2d, INT_TYPE(64), INT_TYPE(32), INT_TYPE(8));
|
||||
@@ -96,6 +98,8 @@ void add_fp_functions_2_module(Module *mod, uint32_t flen) {
|
||||
FDECL(fmadd_d, INT_TYPE(64), INT_TYPE(64), INT_TYPE(64), INT_TYPE(64), INT_TYPE(32), INT_TYPE(8));
|
||||
FDECL(fsel_d, INT_TYPE(64), INT_TYPE(64), INT_TYPE(64), INT_TYPE(32));
|
||||
FDECL(fclass_d, INT_TYPE(64), INT_TYPE(64));
|
||||
FDECL(unbox_s, INT_TYPE(32), INT_TYPE(64));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,13 +202,15 @@ uint32_t fcvt_s(uint32_t v1, uint32_t op, uint8_t mode) {
|
||||
float32_t v1f{v1};
|
||||
softfloat_exceptionFlags=0;
|
||||
float32_t r;
|
||||
int32_t res;
|
||||
switch(op){
|
||||
case 0: //w->s, fp to int32
|
||||
res = f32_to_i32(v1f,rmm_map[mode&0x7],true);
|
||||
case 0:{ //w->s, fp to int32
|
||||
uint_fast32_t res = f32_to_i32(v1f,rmm_map[mode&0x7],true);
|
||||
return (uint32_t)res;
|
||||
case 1: //wu->s
|
||||
return f32_to_ui32(v1f,rmm_map[mode&0x7],true);
|
||||
}
|
||||
case 1:{ //wu->s
|
||||
uint_fast32_t res = f32_to_ui32(v1f,rmm_map[mode&0x7],true);
|
||||
return (uint32_t)res;
|
||||
}
|
||||
case 2: //s->w
|
||||
r=i32_to_f32(v1);
|
||||
return r.v;
|
||||
@@ -373,17 +379,19 @@ uint64_t fcvt_d(uint64_t v1, uint32_t op, uint8_t mode) {
|
||||
float64_t v1f{v1};
|
||||
softfloat_exceptionFlags=0;
|
||||
float64_t r;
|
||||
int32_t res;
|
||||
switch(op){
|
||||
case 0: //w->s, fp to int32
|
||||
res = f64_to_i64(v1f,rmm_map[mode&0x7],true);
|
||||
case 0:{ //l->d, fp to int32
|
||||
int64_t res = f64_to_i64(v1f,rmm_map[mode&0x7],true);
|
||||
return (uint64_t)res;
|
||||
case 1: //wu->s
|
||||
return f64_to_ui64(v1f,rmm_map[mode&0x7],true);
|
||||
case 2: //s->w
|
||||
}
|
||||
case 1:{ //lu->s
|
||||
uint64_t res = f64_to_ui64(v1f,rmm_map[mode&0x7],true);
|
||||
return res;
|
||||
}
|
||||
case 2: //s->l
|
||||
r=i64_to_f64(v1);
|
||||
return r.v;
|
||||
case 3: //s->wu
|
||||
case 3: //s->lu
|
||||
r=ui64_to_f64(v1);
|
||||
return r.v;
|
||||
}
|
||||
@@ -454,5 +462,53 @@ uint64_t fclass_d(uint64_t v1 ){
|
||||
( isNaN && !isSNaN ) << 9;
|
||||
}
|
||||
|
||||
uint64_t fcvt_32_64(uint32_t v1, uint32_t op, uint8_t mode) {
|
||||
float32_t v1f{v1};
|
||||
softfloat_exceptionFlags=0;
|
||||
float64_t r;
|
||||
switch(op){
|
||||
case 0: //l->s, fp to int32
|
||||
return f32_to_i64(v1f,rmm_map[mode&0x7],true);
|
||||
case 1: //wu->s
|
||||
return f32_to_ui64(v1f,rmm_map[mode&0x7],true);
|
||||
case 2: //s->w
|
||||
r=i32_to_f64(v1);
|
||||
return r.v;
|
||||
case 3: //s->wu
|
||||
r=ui32_to_f64(v1);
|
||||
return r.v;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t fcvt_64_32(uint64_t v1, uint32_t op, uint8_t mode) {
|
||||
softfloat_exceptionFlags=0;
|
||||
float32_t r;
|
||||
switch(op){
|
||||
case 0:{ //wu->s
|
||||
int32_t r=f64_to_i32(float64_t{v1}, rmm_map[mode&0x7],true);
|
||||
return r;
|
||||
}
|
||||
case 1:{ //wu->s
|
||||
uint32_t r=f64_to_ui32(float64_t{v1}, rmm_map[mode&0x7],true);
|
||||
return r;
|
||||
}
|
||||
case 2: //l->s, fp to int32
|
||||
r=i64_to_f32(v1);
|
||||
return r.v;
|
||||
case 3: //wu->s
|
||||
r=ui64_to_f32(v1);
|
||||
return r.v;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t unbox_s(uint64_t v){
|
||||
constexpr uint64_t mask = std::numeric_limits<uint64_t>::max() & ~((uint64_t)std::numeric_limits<uint32_t>::max());
|
||||
if((v & mask) != mask)
|
||||
return 0x7fc00000;
|
||||
else
|
||||
return v & std::numeric_limits<uint32_t>::max();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4916
-4664
File diff suppressed because it is too large
Load Diff
+1773
-1843
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+31
-31
@@ -1,34 +1,34 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017, 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.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
* 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 "util/ities.h"
|
||||
#include <util/logging.h>
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*******************************************************************************
|
||||
* 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 "util/ities.h"
|
||||
#include <util/logging.h>
|
||||
|
||||
#include <elfio/elfio.hpp>
|
||||
#include <iss/arch/rv64gc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <ihex.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
using namespace iss::arch;
|
||||
|
||||
constexpr std::array<const char*, 66> iss::arch::traits<iss::arch::rv64gc>::reg_names;
|
||||
constexpr std::array<const char*, 66> iss::arch::traits<iss::arch::rv64gc>::reg_aliases;
|
||||
constexpr std::array<const uint32_t, 72> iss::arch::traits<iss::arch::rv64gc>::reg_bit_widths;
|
||||
constexpr std::array<const uint32_t, 73> iss::arch::traits<iss::arch::rv64gc>::reg_byte_offsets;
|
||||
|
||||
rv64gc::rv64gc() {
|
||||
reg.icount = 0;
|
||||
}
|
||||
|
||||
rv64gc::~rv64gc() = default;
|
||||
|
||||
void rv64gc::reset(uint64_t address) {
|
||||
for(size_t i=0; i<traits<rv64gc>::NUM_REGS; ++i) set_reg(i, std::vector<uint8_t>(sizeof(traits<rv64gc>::reg_t),0));
|
||||
reg.PC=address;
|
||||
reg.NEXT_PC=reg.PC;
|
||||
reg.trap_state=0;
|
||||
reg.machine_state=0x0;
|
||||
reg.icount=0;
|
||||
}
|
||||
|
||||
uint8_t *rv64gc::get_regs_base_ptr() {
|
||||
return reinterpret_cast<uint8_t*>(®);
|
||||
}
|
||||
|
||||
rv64gc::phys_addr_t rv64gc::virt2phys(const iss::addr_t &pc) {
|
||||
return phys_addr_t(pc); // change logical address to physical address
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*******************************************************************************
|
||||
* 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 "util/ities.h"
|
||||
#include <util/logging.h>
|
||||
|
||||
#include <elfio/elfio.hpp>
|
||||
#include <iss/arch/rv64i.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <ihex.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
using namespace iss::arch;
|
||||
|
||||
constexpr std::array<const char*, 33> iss::arch::traits<iss::arch::rv64i>::reg_names;
|
||||
constexpr std::array<const char*, 33> iss::arch::traits<iss::arch::rv64i>::reg_aliases;
|
||||
constexpr std::array<const uint32_t, 39> iss::arch::traits<iss::arch::rv64i>::reg_bit_widths;
|
||||
constexpr std::array<const uint32_t, 40> iss::arch::traits<iss::arch::rv64i>::reg_byte_offsets;
|
||||
|
||||
rv64i::rv64i() {
|
||||
reg.icount = 0;
|
||||
}
|
||||
|
||||
rv64i::~rv64i() = default;
|
||||
|
||||
void rv64i::reset(uint64_t address) {
|
||||
for(size_t i=0; i<traits<rv64i>::NUM_REGS; ++i) set_reg(i, std::vector<uint8_t>(sizeof(traits<rv64i>::reg_t),0));
|
||||
reg.PC=address;
|
||||
reg.NEXT_PC=reg.PC;
|
||||
reg.trap_state=0;
|
||||
reg.machine_state=0x0;
|
||||
reg.icount=0;
|
||||
}
|
||||
|
||||
uint8_t *rv64i::get_regs_base_ptr() {
|
||||
return reinterpret_cast<uint8_t*>(®);
|
||||
}
|
||||
|
||||
rv64i::phys_addr_t rv64i::virt2phys(const iss::addr_t &pc) {
|
||||
return phys_addr_t(pc); // change logical address to physical address
|
||||
}
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017, 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.
|
||||
//
|
||||
// Created on: Tue Sep 05 18:57:24 CEST 2017
|
||||
// * rv64ia.cpp Author: <CoreDSL Generator>
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "util/ities.h"
|
||||
#include <util/logging.h>
|
||||
|
||||
#include <elfio/elfio.hpp>
|
||||
#include <iss/arch/rv64ia.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <ihex.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
using namespace iss::arch;
|
||||
|
||||
constexpr std::array<const char*, 33> iss::arch::traits<iss::arch::rv64ia>::reg_names;
|
||||
constexpr std::array<const char*, 33> iss::arch::traits<iss::arch::rv64ia>::reg_aliases;
|
||||
constexpr std::array<const uint32_t, 39> iss::arch::traits<iss::arch::rv64ia>::reg_bit_widths;
|
||||
constexpr std::array<const uint32_t, 40> iss::arch::traits<iss::arch::rv64ia>::reg_byte_offsets;
|
||||
|
||||
rv64ia::rv64ia() { reg.icount = 0; reg.machine_state = 0x3;}
|
||||
|
||||
rv64ia::~rv64ia(){}
|
||||
|
||||
void rv64ia::reset(uint64_t address) {
|
||||
for (size_t i = 0; i < traits<rv64ia>::NUM_REGS; ++i)
|
||||
set_reg(i, std::vector<uint8_t>(sizeof(traits<rv64ia>::reg_t), 0));
|
||||
reg.PC = address;
|
||||
reg.NEXT_PC = reg.PC;
|
||||
reg.trap_state = 0;
|
||||
reg.machine_state = 0x3;
|
||||
reg.icount=0;
|
||||
}
|
||||
|
||||
uint8_t *rv64ia::get_regs_base_ptr() { return reinterpret_cast<uint8_t *>(®); }
|
||||
|
||||
rv64ia::phys_addr_t rv64ia::virt2phys(const iss::addr_t &pc) {
|
||||
return phys_addr_t(pc); // change logical address to physical address
|
||||
}
|
||||
+7
-2
@@ -38,7 +38,8 @@
|
||||
#include <iss/arch/riscv_hart_msu_vp.h>
|
||||
#include <iss/arch/rv32imac.h>
|
||||
#include <iss/arch/rv32gc.h>
|
||||
#include <iss/arch/rv64ia.h>
|
||||
#include <iss/arch/rv64gc.h>
|
||||
#include <iss/arch/rv64i.h>
|
||||
#include <iss/llvm/jit_helper.h>
|
||||
#include <iss/log_categories.h>
|
||||
#include <iss/plugin/cycle_estimate.h>
|
||||
@@ -107,7 +108,11 @@ int main(int argc, char *argv[]) {
|
||||
std::unique_ptr<iss::arch_if> cpu{nullptr};
|
||||
std::string isa_opt(clim["isa"].as<std::string>());
|
||||
if (isa_opt=="rv64ia") {
|
||||
iss::arch::rv64ia* lcpu = new iss::arch::riscv_hart_msu_vp<iss::arch::rv64ia>();
|
||||
iss::arch::rv64i* lcpu = new iss::arch::riscv_hart_msu_vp<iss::arch::rv64i>();
|
||||
vm = iss::create(lcpu, clim["gdb-port"].as<unsigned>());
|
||||
cpu.reset(lcpu);
|
||||
} else if (isa_opt=="rv64gc") {
|
||||
iss::arch::rv64gc* lcpu = new iss::arch::riscv_hart_msu_vp<iss::arch::rv64gc>();
|
||||
vm = iss::create(lcpu, clim["gdb-port"].as<unsigned>());
|
||||
cpu.reset(lcpu);
|
||||
} else if (isa_opt=="rv32imac") {
|
||||
|
||||
Reference in New Issue
Block a user