Import of kelvin-sim using copybara.
Included changes:
- 791543651 Migrate to string_view accessors by Shodan Team <no-reply@google.com>
- 791439340 Add a DPI wrapper of kelvin_v2 sim. by Shodan Team <no-reply@google.com>
- 775102978 Fix 1 ClangTidyReadability finding: by Shodan Team <no-reply@google.com>
- 741099598 LSC: Add load statements for C++ rules by Shodan Team <no-reply@google.com>
- 740168451 Used header <cstdint> is not included directly by Shodan Team <no-reply@google.com>
PiperOrigin-RevId: 791543651
Change-Id: Ia88827fab81a9d75516964c7553adb8603344c8d
diff --git a/WORKSPACE b/WORKSPACE
index 5abe502..8fc3a69 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,24 +1,55 @@
# Setup bazel repository.
workspace(name = "kelvin_sim")
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
# MPACT-RiscV repo
http_archive(
name = "com_google_mpact-riscv",
- integrity = "sha256-1UtiuOMLKJK5f1mXiWGfb4Lc1n1kWmSQNNZb80XiLY4=",
- strip_prefix = "mpact-riscv-3ed17ec6c5d9cf5fa35ea7100bfa9ae7799fa0d6",
- url = "https://github.com/google/mpact-riscv/archive/3ed17ec6c5d9cf5fa35ea7100bfa9ae7799fa0d6.tar.gz",
+ sha256 = "4e24df1e0b41f1ba04c8f72b1abd3d82b71e4517fa2fcd54c103134f535c0db6",
+ strip_prefix = "mpact-riscv-92597b9bc9f07f7dedc0d380af70dbc3cf595339",
+ url = "https://github.com/google/mpact-riscv/archive/92597b9bc9f07f7dedc0d380af70dbc3cf595339.tar.gz",
+)
+
+# Download only the single svdpi.h file.
+http_file(
+ name = "svdpi_h_file",
+ downloaded_file_path = "svdpi.h",
+ sha256 = "2528c8e529b66dd8e795c8a0fee326166cc51f7dee8fc6a0c6c930534fc780a6",
+ urls = ["https://raw.githubusercontent.com/verilator/verilator/v5.028/include/vltstd/svdpi.h"],
)
load("@com_google_mpact-riscv//:repos.bzl", "mpact_riscv_repos")
+
mpact_riscv_repos()
-load("@com_google_mpact-sim//:repos.bzl", "mpact_sim_repos")
-mpact_sim_repos()
+load("@com_google_mpact-riscv//:dep_repos.bzl", "mpact_riscv_dep_repos")
-load("@com_google_mpact-sim//:deps.bzl", "mpact_sim_deps")
-mpact_sim_deps()
+mpact_riscv_dep_repos()
-load("@com_google_mpact-sim//:protobuf_deps.bzl", "mpact_sim_protobuf_deps")
-mpact_sim_protobuf_deps()
+load("@com_google_mpact-riscv//:deps.bzl", "mpact_riscv_deps")
+
+mpact_riscv_deps()
+
+http_archive(
+ name = "rules_python",
+ sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b",
+ strip_prefix = "rules_python-0.26.0",
+ url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz",
+)
+
+load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
+
+py_repositories()
+
+python_register_toolchains(
+ name = "python3",
+ python_version = "3.9",
+)
+
+http_file(
+ name = "cc_static_library_external",
+ downloaded_file_path = "cc_static_libarary.bzl",
+ sha256 = "1287ce9f7e5fe31ad1b5937781531e4ab3f4656edabf650cca9ca720ceb31806",
+ urls = ["https://raw.githubusercontent.com/project-oak/oak/fcceea755f0274d3a0eb7c0461b30af3dc28e40a/cc/build_defs.bzl"],
+)
diff --git a/sim/BUILD b/sim/BUILD
index 7acb134..c2c915e 100644
--- a/sim/BUILD
+++ b/sim/BUILD
@@ -15,6 +15,8 @@
# Build rules for Kelvin simulator code.
load("@com_google_mpact-sim//mpact/sim/decoder:mpact_sim_isa.bzl", "mpact_bin_fmt_decoder", "mpact_isa_decoder")
+
+
package(default_visibility = ["//visibility:public"])
cc_library(
diff --git a/sim/cosim/BUILD b/sim/cosim/BUILD
new file mode 100644
index 0000000..cf69fca
--- /dev/null
+++ b/sim/cosim/BUILD
@@ -0,0 +1,66 @@
+# Copyright 2025 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This BUILD file defines the co-simulation library that bridges the
+# UVM testbench with the MPACT-Sim model.
+
+
+
+load("@cc_static_library_external//file:cc_static_libarary.bzl", "cc_static_library")
+
+package(
+ default_visibility = ["//visibility:public"],
+)
+
+cc_library(
+ name = "kelvin_cosim_lib",
+ srcs = [
+ "kelvin_cosim_dpi_wrapper.cc",
+ ],
+ hdrs = [
+ "kelvin_cosim_dpi.h",
+ "@svdpi_h_file//file",
+ ],
+ visibility = ["//visibility:public"],
+ deps = [
+ "@com_google_absl//absl/log",
+ "@com_google_absl//absl/log:check",
+ "@com_google_absl//absl/strings",
+ "@com_google_mpact-riscv//riscv:riscv32g_vec_decoder",
+ "@com_google_mpact-riscv//riscv:riscv32gv_isa",
+ "@com_google_mpact-riscv//riscv:riscv_fp_state",
+ "@com_google_mpact-riscv//riscv:riscv_state",
+ "@com_google_mpact-riscv//riscv:riscv_top",
+ "@com_google_mpact-sim//mpact/sim/generic:core",
+ "@com_google_mpact-sim//mpact/sim/util/memory",
+ ],
+ alwayslink = True,
+)
+
+# This rule generates the shared library that is loaded and used by an external UVM testbench to
+# instantiate and control kelvin sim
+cc_binary(
+ name = "cosim_kelvin",
+ linkshared = True,
+ deps = [
+ ":kelvin_cosim_lib",
+ ],
+)
+
+cc_static_library(
+ name = "kelvin_cosim_lib_static",
+ deps = [
+ ":kelvin_cosim_lib",
+ ],
+)
diff --git a/sim/cosim/kelvin_cosim_dpi.h b/sim/cosim/kelvin_cosim_dpi.h
new file mode 100644
index 0000000..5e1c4db
--- /dev/null
+++ b/sim/cosim/kelvin_cosim_dpi.h
@@ -0,0 +1,75 @@
+// Copyright 2025 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Defines the DPI-C interface for cosimulation.
+//
+// These C-style functions allow a SystemVerilog testbench to control an
+// MPACT-based golden reference model, running it in lock-step with a
+// design under test (DUT).
+//
+// Note: This interface is designed for a single simulator instance and is not
+// thread-safe.
+
+#ifndef LEARNING_BRAIN_RESEARCH_KELVIN_SIM_COSIM_KELVIN_COSIM_DPI_H_
+#define LEARNING_BRAIN_RESEARCH_KELVIN_SIM_COSIM_KELVIN_COSIM_DPI_H_
+
+#include <cstdint>
+
+#include "external/svdpi_h_file/file/svdpi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Initialize the MPACT simulator. This function must be called before any
+// other MPACT functions.
+// Return 0 on success, non-zero on failure.
+int mpact_init();
+
+// Reset the MPACT simulator's architectural state.
+// Return 0 on success, non-zero on failure.
+int mpact_reset();
+
+// Step the MPACT simulator by executing a single provided instruction.
+// The instruction is provided as a SystemVerilog datatype - svLogicVecVal*.
+// Return 0 on success, non-zero on failure.
+int mpact_step(const svLogicVecVal* instruction);
+
+// Check if the MPACT simulator has reached a halted state. Some tests may
+// require the simulator to be halted before checking the results.
+// Currently unimplemented and always returns false.
+bool mpact_is_halted();
+
+// Return the current value of the Program Counter (PC).
+// On error, returns 0 and logs an error.
+uint32_t mpact_get_pc();
+
+// Return the value of the specified GPR. GPRs are selected by their index,
+// where 0 is x0, 1 is x1, and so on.
+// On error, returns 0 and logs an error.
+uint32_t mpact_get_gpr(uint32_t index);
+
+// Return the value of the specified CSR. CSRs are selected by their address.
+// On error, returns 0 and logs an error.
+uint32_t mpact_get_csr(uint32_t address);
+
+// Finalize and clean up MPACT simulator resources.
+// Return 0 on success, non-zero on failure.
+int mpact_fini();
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // LEARNING_BRAIN_RESEARCH_KELVIN_SIM_COSIM_KELVIN_COSIM_DPI_H_
diff --git a/sim/cosim/kelvin_cosim_dpi_wrapper.cc b/sim/cosim/kelvin_cosim_dpi_wrapper.cc
new file mode 100644
index 0000000..3a5d7c3
--- /dev/null
+++ b/sim/cosim/kelvin_cosim_dpi_wrapper.cc
@@ -0,0 +1,224 @@
+// Copyright 2025 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <memory>
+#include <string>
+
+#include "absl/log/check.h"
+#include "absl/log/log.h"
+#include "absl/strings/str_cat.h"
+#include "riscv/riscv32g_vec_decoder.h"
+#include "riscv/riscv_csr.h"
+#include "riscv/riscv_fp_state.h"
+#include "riscv/riscv_register.h"
+#include "riscv/riscv_register_aliases.h"
+#include "riscv/riscv_state.h"
+#include "riscv/riscv_top.h"
+#include "riscv/riscv_vector_state.h"
+#include "mpact/sim/generic/decoder_interface.h"
+#include "mpact/sim/util/memory/flat_demand_memory.h"
+#include "mpact/sim/util/memory/memory_interface.h"
+#include "external/svdpi_h_file/file/svdpi.h"
+
+// Include the DPI-C contract header.
+#include "sim/cosim/kelvin_cosim_dpi.h"
+
+constexpr int kKelvinVectorByteLength = 16;
+constexpr uint32_t kKelvinStartAddress = 0;
+
+namespace {
+using ::mpact::sim::generic::DecoderInterface;
+using ::mpact::sim::riscv::kXRegisterAliases;
+using ::mpact::sim::riscv::RiscV32GVecDecoder;
+using ::mpact::sim::riscv::RiscVFPState;
+using ::mpact::sim::riscv::RiscVState;
+using ::mpact::sim::riscv::RiscVTop;
+using ::mpact::sim::riscv::RiscVVectorState;
+using ::mpact::sim::riscv::RiscVXlen;
+using ::mpact::sim::riscv::RV32Register;
+using ::mpact::sim::riscv::RVFpRegister;
+using ::mpact::sim::util::FlatDemandMemory;
+using ::mpact::sim::util::MemoryInterface;
+
+class MpactHandle {
+ public:
+ MpactHandle()
+ : memory_(std::make_unique<FlatDemandMemory>()),
+ rv_state_(CreateRVState(memory_.get())),
+ rv_fp_state_(CreateFPState(rv_state_.get())),
+ rvv_state_(CreateVectorState(rv_state_.get())),
+ rv_decoder_(CreateDecoder(rv_state_.get(), memory_.get())),
+ rv_top_(CreateRiscVTop(rv_state_.get(), rv_decoder_.get())) {
+ absl::Status pc_write = rv_top_->WriteRegister("pc", kKelvinStartAddress);
+ CHECK_OK(pc_write) << "Error writing to pc.";
+ }
+
+ uint32_t get_pc() {
+ absl::StatusOr<uint64_t> read_reg_status = rv_top_->ReadRegister("pc");
+ CHECK_OK(read_reg_status);
+ if (!read_reg_status.ok()) {
+ LOG(ERROR) << "[DPI] Failed to read pc.";
+ return 0;
+ }
+ return static_cast<uint32_t>(read_reg_status.value());
+ }
+
+ RiscVTop* rv_top() { return rv_top_.get(); }
+
+ RiscVState* rv_state() { return rv_state_.get(); }
+
+ private:
+ std::unique_ptr<RiscVState> CreateRVState(MemoryInterface* memory) {
+ auto rv_state =
+ std::make_unique<RiscVState>("RiscV32GV", RiscVXlen::RV32, memory);
+ // Make sure the architectural and abi register aliases are added.
+ std::string reg_name;
+ for (int i = 0; i < 32; i++) {
+ reg_name = absl::StrCat(RiscVState::kXregPrefix, i);
+ (void)rv_state->AddRegister<RV32Register>(reg_name);
+ (void)rv_state->AddRegisterAlias<RV32Register>(reg_name,
+ kXRegisterAliases[i]);
+ }
+ return rv_state;
+ }
+
+ std::unique_ptr<RiscVFPState> CreateFPState(RiscVState* rv_state) {
+ return std::make_unique<RiscVFPState>(rv_state->csr_set(), rv_state);
+ }
+
+ std::unique_ptr<RiscVVectorState> CreateVectorState(RiscVState* rv_state) {
+ return std::make_unique<RiscVVectorState>(rv_state,
+ kKelvinVectorByteLength);
+ }
+
+ std::unique_ptr<DecoderInterface> CreateDecoder(RiscVState* rv_state,
+ MemoryInterface* memory) {
+ return std::make_unique<RiscV32GVecDecoder>(rv_state, memory);
+ }
+
+ std::unique_ptr<RiscVTop> CreateRiscVTop(RiscVState* rv_state,
+ DecoderInterface* decoder) {
+ return std::make_unique<RiscVTop>("KelvinPlaceholder", rv_state, decoder);
+ }
+
+ const std::unique_ptr<MemoryInterface> memory_;
+ const std::unique_ptr<RiscVState> rv_state_;
+ const std::unique_ptr<RiscVFPState> rv_fp_state_;
+ const std::unique_ptr<RiscVVectorState> rvv_state_;
+ const std::unique_ptr<DecoderInterface> rv_decoder_;
+ const std::unique_ptr<RiscVTop> rv_top_;
+};
+
+MpactHandle* g_mpact_handle = nullptr;
+} // namespace
+
+int mpact_init() {
+ if (g_mpact_handle != nullptr) {
+ LOG(ERROR) << "[DPI] mpact_init: g_mpact_handle is not null. "
+ << "mpact_fini() must be called first.";
+ return -1;
+ }
+ g_mpact_handle = new MpactHandle();
+ return 0;
+}
+
+int mpact_reset() {
+ if (g_mpact_handle != nullptr) {
+ mpact_fini();
+ }
+ return mpact_init();
+}
+
+int mpact_step(const svLogicVecVal* instruction) {
+ if (g_mpact_handle == nullptr) {
+ LOG(ERROR) << "[DPI] mpact_step: g_mpact_handle is null.";
+ return -1;
+ }
+ uint32_t inst_word = instruction->aval;
+ if (!g_mpact_handle->rv_top()
+ ->WriteMemory(g_mpact_handle->get_pc(), &inst_word,
+ sizeof(inst_word))
+ .ok()) {
+ LOG(ERROR) << "[DPI] mpact_step: Failed to write instruction to memory.";
+ return 1;
+ }
+
+ if (!g_mpact_handle->rv_top()->Step(1).ok()) {
+ LOG(ERROR) << "[DPI] mpact_step: Failed to step the simulator.";
+ return 2;
+ }
+ return 0;
+}
+
+bool mpact_is_halted() {
+ if (g_mpact_handle == nullptr) {
+ LOG(ERROR) << "[DPI] mpact_is_halted: g_mpact_handle is null.";
+ return false;
+ }
+ LOG(ERROR) << "[DPI] mpact_is_halted: Unimplemented.";
+ return false;
+}
+
+uint32_t mpact_get_pc() {
+ if (g_mpact_handle == nullptr) {
+ LOG(ERROR) << "[DPI] mpact_get_pc: g_mpact_handle is null.";
+ return 0;
+ }
+ return g_mpact_handle->get_pc();
+}
+
+uint32_t mpact_get_gpr(uint32_t index) {
+ if (g_mpact_handle == nullptr) {
+ LOG(ERROR) << "[DPI] mpact_get_gpr: g_mpact_handle is null.";
+ return 0;
+ }
+ std::string reg_name =
+ absl::StrCat(mpact::sim::riscv::RiscVState::kXregPrefix, index);
+ mpact::sim::riscv::RiscVTop* rv_top = g_mpact_handle->rv_top();
+ absl::StatusOr<uint64_t> read_reg_status = rv_top->ReadRegister(reg_name);
+ if (!read_reg_status.ok()) {
+ LOG(ERROR) << "[DPI] mpact_get_gpr: Failed to read register: " << reg_name;
+ return 0;
+ }
+ return static_cast<uint32_t>(read_reg_status.value());
+}
+
+uint32_t mpact_get_csr(uint32_t address) {
+ if (g_mpact_handle == nullptr) {
+ LOG(ERROR) << "[DPI] mpact_get_csr: g_mpact_handle is null.";
+ return 0;
+ }
+ uint64_t csr_index = static_cast<uint64_t>(address);
+
+ absl::StatusOr<mpact::sim::riscv::RiscVCsrInterface*> get_csr_status =
+ g_mpact_handle->rv_state()->csr_set()->GetCsr(csr_index);
+
+ if (!get_csr_status.ok()) {
+ LOG(ERROR) << "[DPI] mpact_get_csr: Failed to get CSR: " << address;
+ return 0;
+ }
+ mpact::sim::riscv::RiscVCsrInterface* csr = get_csr_status.value();
+ return csr->AsUint32();
+}
+
+int mpact_fini() {
+ if (g_mpact_handle == nullptr) {
+ LOG(ERROR) << "[DPI] mpact_fini: g_mpact_handle is null.";
+ return -1;
+ }
+ delete g_mpact_handle;
+ g_mpact_handle = nullptr;
+ return 0;
+}
diff --git a/sim/decoder.cc b/sim/decoder.cc
index 030b21a..62b6f0c 100644
--- a/sim/decoder.cc
+++ b/sim/decoder.cc
@@ -14,6 +14,8 @@
#include "sim/decoder.h"
+#include <cstdint>
+
#include "sim/kelvin_decoder.h"
#include "sim/kelvin_encoding.h"
#include "sim/kelvin_enums.h"
@@ -28,8 +30,8 @@
using ::mpact::sim::generic::operator*; // NOLINT: is used below (clang error).
-KelvinDecoder::KelvinDecoder(KelvinState *state,
- mpact::sim::util::MemoryInterface *memory)
+KelvinDecoder::KelvinDecoder(KelvinState* state,
+ mpact::sim::util::MemoryInterface* memory)
: state_(state), memory_(memory) {
// Get a handle to the internal error in the program error controller.
decode_error_ = state->program_error_controller()->GetProgramError(
@@ -54,14 +56,14 @@
delete kelvin_encoding_;
}
-mpact::sim::generic::Instruction *KelvinDecoder::DecodeInstruction(
+mpact::sim::generic::Instruction* KelvinDecoder::DecodeInstruction(
uint64_t address) {
// First check that the address is aligned properly. If not, create and return
// an empty instruction object and raise an exception.
if (address & 0x1) {
- auto *inst = new mpact::sim::generic::Instruction(address, state_);
+ auto* inst = new mpact::sim::generic::Instruction(address, state_);
inst->set_semantic_function(
- [](mpact::sim::generic::Instruction *inst) { /* empty */ });
+ [](mpact::sim::generic::Instruction* inst) { /* empty */ });
inst->set_size(1);
inst->SetDisassemblyString("Misaligned instruction address");
inst->set_opcode(static_cast<int>(isa32::OpcodeEnum::kNone));
@@ -77,12 +79,12 @@
state_->Trap(/*is_interrupt*/ false, address,
*mpact::sim::riscv::ExceptionCode::kInstructionAccessFault,
address, nullptr);
- auto *inst = new mpact::sim::generic::Instruction(address, state_);
+ auto* inst = new mpact::sim::generic::Instruction(address, state_);
inst->set_size(0);
inst->SetDisassemblyString("Instruction access fault");
inst->set_opcode(static_cast<int>(isa32::OpcodeEnum::kNone));
inst->set_semantic_function(
- [](mpact::sim::generic::Instruction *inst) { /* empty */ });
+ [](mpact::sim::generic::Instruction* inst) { /* empty */ });
return inst;
}
@@ -93,7 +95,7 @@
// Call the isa decoder to obtain a new instruction object for the instruction
// word that was parsed above.
- auto *instruction = kelvin_isa_->Decode(address, kelvin_encoding_);
+ auto* instruction = kelvin_isa_->Decode(address, kelvin_encoding_);
return instruction;
}
} // namespace kelvin::sim
diff --git a/sim/decoder.h b/sim/decoder.h
index 731169f..3ec5187 100644
--- a/sim/decoder.h
+++ b/sim/decoder.h
@@ -39,7 +39,7 @@
class KelvinIsaFactory : public isa32::KelvinInstructionSetFactory {
public:
std::unique_ptr<isa32::KelvinSlot> CreateKelvinSlot(
- mpact::sim::generic::ArchState *state) override {
+ mpact::sim::generic::ArchState* state) override {
return std::make_unique<isa32::KelvinSlot>(state);
}
};
@@ -51,14 +51,14 @@
using SlotEnum = isa32::SlotEnum;
using OpcodeEnum = isa32::OpcodeEnum;
- KelvinDecoder(KelvinState *state, mpact::sim::util::MemoryInterface *memory);
+ KelvinDecoder(KelvinState* state, mpact::sim::util::MemoryInterface* memory);
KelvinDecoder() = delete;
~KelvinDecoder() override;
// This will always return a valid instruction that can be executed. In the
// case of a decode error, the semantic function in the instruction object
// instance will raise an internal simulator error when executed.
- mpact::sim::generic::Instruction *DecodeInstruction(
+ mpact::sim::generic::Instruction* DecodeInstruction(
uint64_t address) override;
// Return the number of opcodes supported by this decoder.
@@ -66,21 +66,21 @@
return static_cast<int>(OpcodeEnum::kPastMaxValue);
}
// Return the name of the opcode at the given index.
- const char *GetOpcodeName(int index) const override {
+ const char* GetOpcodeName(int index) const override {
return isa32::kOpcodeNames[index];
}
// Getter.
- isa32::KelvinEncoding *kelvin_encoding() const { return kelvin_encoding_; }
+ isa32::KelvinEncoding* kelvin_encoding() const { return kelvin_encoding_; }
private:
- KelvinState *state_;
- mpact::sim::util::MemoryInterface *memory_;
+ KelvinState* state_;
+ mpact::sim::util::MemoryInterface* memory_;
std::unique_ptr<mpact::sim::generic::ProgramError> decode_error_;
- mpact::sim::generic::DataBuffer *inst_db_;
- isa32::KelvinEncoding *kelvin_encoding_;
- KelvinIsaFactory *kelvin_isa_factory_;
- isa32::KelvinInstructionSet *kelvin_isa_;
+ mpact::sim::generic::DataBuffer* inst_db_;
+ isa32::KelvinEncoding* kelvin_encoding_;
+ KelvinIsaFactory* kelvin_isa_factory_;
+ isa32::KelvinInstructionSet* kelvin_isa_;
};
} // namespace kelvin::sim
diff --git a/sim/kelvin_action_point_memory_interface.cc b/sim/kelvin_action_point_memory_interface.cc
index d754a78..8acae7e 100644
--- a/sim/kelvin_action_point_memory_interface.cc
+++ b/sim/kelvin_action_point_memory_interface.cc
@@ -23,7 +23,7 @@
namespace kelvin::sim {
KelvinActionPointMemoryInterface::KelvinActionPointMemoryInterface(
- MemoryInterface *memory, InvalidateFcn invalidate_fcn)
+ MemoryInterface* memory, InvalidateFcn invalidate_fcn)
: memory_(memory), invalidate_fcn_(std::move(invalidate_fcn)) {
// Allocate two data buffers (32 and 16 bit) once, so we don't have to
// do it every time we access breakpoint instructions.
@@ -32,7 +32,7 @@
KelvinActionPointMemoryInterface::~KelvinActionPointMemoryInterface() {
if (db4_ != nullptr) db4_->DecRef();
- for (auto &[unused, inst_info_ptr] : instruction_map_) {
+ for (auto& [unused, inst_info_ptr] : instruction_map_) {
delete inst_info_ptr;
}
instruction_map_.clear();
@@ -65,7 +65,7 @@
return absl::InvalidArgumentError(absl::StrCat(
"Invalid instruction size: ", size, " at ", absl::Hex(address)));
}
- auto *inst_info = new InstructionInfo;
+ auto* inst_info = new InstructionInfo;
inst_info->og_instruction_word = instruction_word;
inst_info->size = size;
it = instruction_map_.insert(std::make_pair(address, inst_info)).first;
diff --git a/sim/kelvin_action_point_memory_interface.h b/sim/kelvin_action_point_memory_interface.h
index ea88e52..b48f3cf 100644
--- a/sim/kelvin_action_point_memory_interface.h
+++ b/sim/kelvin_action_point_memory_interface.h
@@ -45,7 +45,7 @@
// The constructor takes a pointer to the memory interface through which
// instructions can be read and written,and a function to invalidate the
// decoding of an instruction.
- KelvinActionPointMemoryInterface(MemoryInterface *memory,
+ KelvinActionPointMemoryInterface(MemoryInterface* memory,
InvalidateFcn invalidate_fcn);
~KelvinActionPointMemoryInterface() override;
@@ -69,11 +69,11 @@
// Data buffer factory and two data buffer pointers to use for reading and
// writing instructions.
DataBufferFactory db_factory_;
- DataBuffer *db4_ = nullptr;
+ DataBuffer* db4_ = nullptr;
// Maps from address to information about the instruction.
- absl::flat_hash_map<uint64_t, InstructionInfo *> instruction_map_;
+ absl::flat_hash_map<uint64_t, InstructionInfo*> instruction_map_;
// Interface to program memory.
- MemoryInterface *memory_;
+ MemoryInterface* memory_;
// Function to be called to invalidate any stored decoding of an instruction.
InvalidateFcn invalidate_fcn_;
};
diff --git a/sim/kelvin_encoding.cc b/sim/kelvin_encoding.cc
index b5026c3..fcda936 100644
--- a/sim/kelvin_encoding.cc
+++ b/sim/kelvin_encoding.cc
@@ -39,8 +39,8 @@
template <typename RegType>
inline void GetVRegGroup(
- KelvinState *state, int reg_num, bool strip_mine, int widen_factor,
- std::vector<mpact::sim::generic::RegisterBase *> *vreg_group) {
+ KelvinState* state, int reg_num, bool strip_mine, int widen_factor,
+ std::vector<mpact::sim::generic::RegisterBase*>* vreg_group) {
auto regs_count = (strip_mine ? 4 : 1) * widen_factor;
for (int i = 0; i < regs_count; ++i) {
auto vreg_name =
@@ -50,78 +50,78 @@
}
template <typename RegType>
-inline SourceOperandInterface *GetVectorRegisterSourceOp(KelvinState *state,
+inline SourceOperandInterface* GetVectorRegisterSourceOp(KelvinState* state,
int reg_num,
bool strip_mine,
int widen_factor) {
- std::vector<mpact::sim::generic::RegisterBase *> vreg_group;
+ std::vector<mpact::sim::generic::RegisterBase*> vreg_group;
GetVRegGroup<RegType>(state, reg_num, strip_mine, widen_factor, &vreg_group);
- auto *v_src_op = new mpact::sim::riscv::RV32VectorSourceOperand(
- absl::Span<mpact::sim::generic::RegisterBase *>(vreg_group),
+ auto* v_src_op = new mpact::sim::riscv::RV32VectorSourceOperand(
+ absl::Span<mpact::sim::generic::RegisterBase*>(vreg_group),
absl::StrCat(mpact::sim::riscv::RiscVState::kVregPrefix, reg_num));
return v_src_op;
}
template <typename RegType>
-inline DestinationOperandInterface *GetVectorRegisterDestinationOp(
- KelvinState *state, int reg_num, bool strip_mine, bool widening,
+inline DestinationOperandInterface* GetVectorRegisterDestinationOp(
+ KelvinState* state, int reg_num, bool strip_mine, bool widening,
int latency) {
- std::vector<mpact::sim::generic::RegisterBase *> vreg_group;
+ std::vector<mpact::sim::generic::RegisterBase*> vreg_group;
GetVRegGroup<RegType>(state, reg_num, strip_mine, widening ? 2 : 1,
&vreg_group);
- auto *v_dst_op = new mpact::sim::riscv::RV32VectorDestinationOperand(
- absl::Span<mpact::sim::generic::RegisterBase *>(vreg_group), latency,
+ auto* v_dst_op = new mpact::sim::riscv::RV32VectorDestinationOperand(
+ absl::Span<mpact::sim::generic::RegisterBase*>(vreg_group), latency,
absl::StrCat(mpact::sim::riscv::RiscVState::kVregPrefix, reg_num));
return v_dst_op;
}
// Generic helper functions to create register operands.
template <typename RegType>
-inline DestinationOperandInterface *GetRegisterDestinationOp(KelvinState *state,
+inline DestinationOperandInterface* GetRegisterDestinationOp(KelvinState* state,
std::string name,
int latency) {
- auto *reg = state->GetRegister<RegType>(name).first;
+ auto* reg = state->GetRegister<RegType>(name).first;
return reg->CreateDestinationOperand(latency);
}
template <typename RegType>
-inline DestinationOperandInterface *GetRegisterDestinationOp(
- KelvinState *state, std::string name, int latency, std::string op_name) {
- auto *reg = state->GetRegister<RegType>(name).first;
+inline DestinationOperandInterface* GetRegisterDestinationOp(
+ KelvinState* state, std::string name, int latency, std::string op_name) {
+ auto* reg = state->GetRegister<RegType>(name).first;
return reg->CreateDestinationOperand(latency, op_name);
}
template <typename T>
-inline DestinationOperandInterface *GetCSRSetBitsDestinationOp(
- KelvinState *state, std::string name, int latency, std::string op_name) {
+inline DestinationOperandInterface* GetCSRSetBitsDestinationOp(
+ KelvinState* state, std::string name, int latency, std::string op_name) {
auto result = state->csr_set()->GetCsr(name);
if (!result.ok()) {
LOG(ERROR) << "No such CSR '" << name << "'";
return nullptr;
}
- auto *csr = result.value();
- auto *op = csr->CreateSetDestinationOperand(latency, op_name);
+ auto* csr = result.value();
+ auto* op = csr->CreateSetDestinationOperand(latency, op_name);
return op;
}
template <typename RegType>
-inline SourceOperandInterface *GetRegisterSourceOp(KelvinState *state,
+inline SourceOperandInterface* GetRegisterSourceOp(KelvinState* state,
std::string name) {
- auto *reg = state->GetRegister<RegType>(name).first;
- auto *op = reg->CreateSourceOperand();
+ auto* reg = state->GetRegister<RegType>(name).first;
+ auto* op = reg->CreateSourceOperand();
return op;
}
template <typename RegType>
-inline SourceOperandInterface *GetRegisterSourceOp(KelvinState *state,
+inline SourceOperandInterface* GetRegisterSourceOp(KelvinState* state,
std::string name,
std::string op_name) {
- auto *reg = state->GetRegister<RegType>(name).first;
- auto *op = reg->CreateSourceOperand(op_name);
+ auto* reg = state->GetRegister<RegType>(name).first;
+ auto* op = reg->CreateSourceOperand(op_name);
return op;
}
-KelvinEncoding::KelvinEncoding(KelvinState *state) : state_(state) {
+KelvinEncoding::KelvinEncoding(KelvinState* state) : state_(state) {
InitializeSourceOperandGetters();
InitializeDestinationOperandGetters();
resource_pool_ = new mpact::sim::generic::SimpleResourcePool("Kelvin", 128);
@@ -148,7 +148,7 @@
if (!res.ok()) {
return new mpact::sim::generic::ImmediateOperand<uint32_t>(csr_indx);
}
- auto *csr = res.value();
+ auto* csr = res.value();
return new mpact::sim::generic::ImmediateOperand<uint32_t>(csr_indx,
csr->name());
}));
@@ -179,7 +179,7 @@
}));
source_op_getters_.insert(std::make_pair(
static_cast<int>(SourceOpEnum::kRs1),
- [this]() -> SourceOperandInterface * {
+ [this]() -> SourceOperandInterface* {
int num = encoding::r_type::ExtractRs1(inst_word_);
if (num == 0)
return new mpact::sim::generic::IntLiteralOperand<0>(
@@ -191,7 +191,7 @@
}));
source_op_getters_.insert(std::make_pair(
static_cast<int>(SourceOpEnum::kRs2),
- [this]() -> SourceOperandInterface * {
+ [this]() -> SourceOperandInterface* {
int num = encoding::r_type::ExtractRs2(inst_word_);
if (num == 0)
return new mpact::sim::generic::IntLiteralOperand<0>(
@@ -213,7 +213,7 @@
}));
source_op_getters_.emplace(
static_cast<int>(SourceOpEnum::kVs1),
- [this]() -> SourceOperandInterface * {
+ [this]() -> SourceOperandInterface* {
auto reg_num = encoding::kelvin_v2_args_type::ExtractVs1(inst_word_);
bool strip_mine = encoding::kelvin_v2_args_type::ExtractM(inst_word_);
auto form = encoding::kelvin_v2_args_type::ExtractForm(inst_word_);
@@ -245,7 +245,7 @@
});
source_op_getters_.emplace(
static_cast<int>(SourceOpEnum::kVs2),
- [this]() -> SourceOperandInterface * {
+ [this]() -> SourceOperandInterface* {
auto reg_num = encoding::kelvin_v2_args_type::ExtractVs2(inst_word_);
bool strip_mine = encoding::kelvin_v2_args_type::ExtractM(inst_word_);
auto form = encoding::kelvin_v2_args_type::ExtractForm(inst_word_);
@@ -269,8 +269,7 @@
source_op_getters_.emplace(
// `vst` and `vstq` use `vd` field as the source for the vector store.
// convolution instructions also use `vd` as one of the sources.
- static_cast<int>(SourceOpEnum::kVd),
- [this]() -> SourceOperandInterface * {
+ static_cast<int>(SourceOpEnum::kVd), [this]() -> SourceOperandInterface* {
auto reg_num = encoding::kelvin_v2_args_type::ExtractVd(inst_word_);
bool strip_mine = encoding::kelvin_v2_args_type::ExtractM(inst_word_);
return GetVectorRegisterSourceOp<mpact::sim::riscv::RVVectorRegister>(
@@ -279,7 +278,7 @@
source_op_getters_.emplace(
// Used by convolution instructions.
static_cast<int>(SourceOpEnum::kVs3),
- [this]() -> SourceOperandInterface * {
+ [this]() -> SourceOperandInterface* {
auto reg_num = encoding::kelvin_v3_args_type::ExtractVs3(inst_word_);
int widen_factor = opcode_ == OpcodeEnum::kAconvVxv ? 8 : 4;
return GetVectorRegisterSourceOp<mpact::sim::riscv::RVVectorRegister>(
@@ -303,7 +302,7 @@
}));
dest_op_getters_.insert(std::make_pair(
static_cast<int>(DestOpEnum::kRd),
- [this](int latency) -> DestinationOperandInterface * {
+ [this](int latency) -> DestinationOperandInterface* {
int num = encoding::r_type::ExtractRd(inst_word_);
if (num == 0) {
return GetRegisterDestinationOp<mpact::sim::riscv::RV32Register>(
@@ -316,7 +315,7 @@
}));
dest_op_getters_.emplace(
static_cast<int>(DestOpEnum::kVd),
- [this](int latency) -> DestinationOperandInterface * {
+ [this](int latency) -> DestinationOperandInterface* {
auto reg_num = encoding::kelvin_v2_args_type::ExtractVd(inst_word_);
bool strip_mine = encoding::kelvin_v2_args_type::ExtractM(inst_word_);
if (opcode_ == OpcodeEnum::kVcget || opcode_ == OpcodeEnum::kAdwinit ||
@@ -332,7 +331,7 @@
});
dest_op_getters_.insert(std::make_pair(
static_cast<int>(DestOpEnum::kVs1),
- [this](int latency) -> DestinationOperandInterface * {
+ [this](int latency) -> DestinationOperandInterface* {
auto reg_num = encoding::kelvin_v2_args_type::ExtractVs1(inst_word_);
// Only vld.*p/vst.*p instructions are writing post incremented address
// to "vs1" register. And it has to be a scalar register in that case.
@@ -366,13 +365,13 @@
decode_functions.push_back(encoding::DecodeRiscVZbbInst32);
decode_functions.push_back(encoding::DecodeRiscVZbbInst32Only);
decode_functions.push_back(encoding::DecodeRiscVZbbImmInst32);
- for (auto &function : decode_functions) {
+ for (auto& function : decode_functions) {
opcode_ = function(inst_word_);
if (opcode_ != OpcodeEnum::kNone) break;
}
}
-DestinationOperandInterface *KelvinEncoding::GetDestination(SlotEnum, int,
+DestinationOperandInterface* KelvinEncoding::GetDestination(SlotEnum, int,
OpcodeEnum opcode,
DestOpEnum dest_op,
int, int latency) {
@@ -387,7 +386,7 @@
return (iter->second)(latency);
}
-SourceOperandInterface *KelvinEncoding::GetSource(SlotEnum, int,
+SourceOperandInterface* KelvinEncoding::GetSource(SlotEnum, int,
OpcodeEnum opcode,
SourceOpEnum source_op,
int source_no) {
diff --git a/sim/kelvin_encoding.h b/sim/kelvin_encoding.h
index 51cfeae..fd67560 100644
--- a/sim/kelvin_encoding.h
+++ b/sim/kelvin_encoding.h
@@ -36,7 +36,7 @@
// instructions according to the operand fields in the encoding.
class KelvinEncoding : public KelvinEncodingBase {
public:
- explicit KelvinEncoding(KelvinState *state);
+ explicit KelvinEncoding(KelvinState* state);
~KelvinEncoding() override;
// Parses an instruction and determines the opcode.
@@ -46,7 +46,7 @@
OpcodeEnum GetOpcode(SlotEnum, int) override { return opcode_; }
// There is no predicate, so return nullptr.
- PredicateOperandInterface *GetPredicate(SlotEnum, int, OpcodeEnum,
+ PredicateOperandInterface* GetPredicate(SlotEnum, int, OpcodeEnum,
PredOpEnum) override {
return nullptr;
}
@@ -58,12 +58,12 @@
// where the resource itself is a register bank, and the argument specifies
// which register (or more precisely) which encoding "field" specifies the
// register number.
- ResourceOperandInterface *GetSimpleResourceOperand(
- SlotEnum, int, OpcodeEnum, SimpleResourceVector &resource_vec,
+ ResourceOperandInterface* GetSimpleResourceOperand(
+ SlotEnum, int, OpcodeEnum, SimpleResourceVector& resource_vec,
int end) override {
return nullptr;
}
- ResourceOperandInterface *GetComplexResourceOperand(
+ ResourceOperandInterface* GetComplexResourceOperand(
SlotEnum, int, OpcodeEnum, ComplexResourceEnum resource, int begin,
int end) override {
return nullptr;
@@ -71,12 +71,12 @@
// The following method returns a source operand that corresponds to the
// particular operand field.
- SourceOperandInterface *GetSource(SlotEnum, int, OpcodeEnum, SourceOpEnum op,
+ SourceOperandInterface* GetSource(SlotEnum, int, OpcodeEnum, SourceOpEnum op,
int source_no) override;
// The following method returns a destination operand that corresponds to the
// particular operand field.
- DestinationOperandInterface *GetDestination(SlotEnum, int, OpcodeEnum,
+ DestinationOperandInterface* GetDestination(SlotEnum, int, OpcodeEnum,
DestOpEnum op, int,
int latency) override;
@@ -88,20 +88,20 @@
}
// Getter.
- mpact::sim::generic::SimpleResourcePool *resource_pool() const {
+ mpact::sim::generic::SimpleResourcePool* resource_pool() const {
return resource_pool_;
}
protected:
using SourceOpGetterMap =
- absl::flat_hash_map<int, absl::AnyInvocable<SourceOperandInterface *()>>;
+ absl::flat_hash_map<int, absl::AnyInvocable<SourceOperandInterface*()>>;
using DestOpGetterMap = absl::flat_hash_map<
- int, absl::AnyInvocable<DestinationOperandInterface *(int)>>;
+ int, absl::AnyInvocable<DestinationOperandInterface*(int)>>;
- SourceOpGetterMap &source_op_getters() { return source_op_getters_; }
- DestOpGetterMap &dest_op_getters() { return dest_op_getters_; }
+ SourceOpGetterMap& source_op_getters() { return source_op_getters_; }
+ DestOpGetterMap& dest_op_getters() { return dest_op_getters_; }
- KelvinState *state() const { return state_; }
+ KelvinState* state() const { return state_; }
OpcodeEnum opcode() const { return opcode_; }
uint32_t inst_word() const { return inst_word_; }
@@ -116,10 +116,10 @@
SourceOpGetterMap source_op_getters_;
DestOpGetterMap dest_op_getters_;
- KelvinState *state_;
+ KelvinState* state_;
uint32_t inst_word_;
OpcodeEnum opcode_;
- mpact::sim::generic::SimpleResourcePool *resource_pool_ = nullptr;
+ mpact::sim::generic::SimpleResourcePool* resource_pool_ = nullptr;
};
} // namespace kelvin::sim::isa32
diff --git a/sim/kelvin_instructions.cc b/sim/kelvin_instructions.cc
index 39b59fb..f9b9aba 100644
--- a/sim/kelvin_instructions.cc
+++ b/sim/kelvin_instructions.cc
@@ -26,17 +26,17 @@
using ::mpact::sim::generic::operator*; // NOLINT: is used below (clang error).
-void KelvinIllegalInstruction(mpact::sim::generic::Instruction *inst) {
- auto *state = static_cast<KelvinState *>(inst->state());
+void KelvinIllegalInstruction(mpact::sim::generic::Instruction* inst) {
+ auto* state = static_cast<KelvinState*>(inst->state());
state->Trap(/*is_interrupt*/ false, /*trap_value*/ 0,
*mpact::sim::riscv::ExceptionCode::kIllegalInstruction,
/*epc*/ inst->address(), inst);
}
-void KelvinNopInstruction(mpact::sim::generic::Instruction *inst) {}
+void KelvinNopInstruction(mpact::sim::generic::Instruction* inst) {}
-void KelvinIMpause(const mpact::sim::generic::Instruction *inst) {
- auto *state = static_cast<KelvinState *>(inst->state());
+void KelvinIMpause(const mpact::sim::generic::Instruction* inst) {
+ auto* state = static_cast<KelvinState*>(inst->state());
state->MPause(inst);
}
@@ -49,17 +49,17 @@
// A helper function to load a string from the memory address by detecting the
// '\0' terminator
-void KelvinStringLoadHelper(const mpact::sim::generic::Instruction *inst,
- std::string *out_string) {
- auto *state = static_cast<KelvinState *>(inst->state());
+void KelvinStringLoadHelper(const mpact::sim::generic::Instruction* inst,
+ std::string* out_string) {
+ auto* state = static_cast<KelvinState*>(inst->state());
auto addr = mpact::sim::generic::GetInstructionSource<uint32_t>(inst, 0, 0);
uint32_t data;
- auto *db = state->db_factory()->Allocate<uint32_t>(1);
+ auto* db = state->db_factory()->Allocate<uint32_t>(1);
do {
state->LoadMemory(inst, addr, db, nullptr, nullptr);
data = db->Get<uint32_t>(0);
*out_string +=
- std::string(reinterpret_cast<char *>(&data), sizeof(uint32_t));
+ std::string(reinterpret_cast<char*>(&data), sizeof(uint32_t));
addr += 4;
} while (!WordHasZero(data) && addr < state->max_physical_address());
// Trim the string properly.
@@ -69,8 +69,8 @@
// Handle FLOG, SLOG, CLOG, and KLOG instructions
void KelvinLogInstruction(int log_mode,
- mpact::sim::generic::Instruction *inst) {
- auto *state = static_cast<KelvinState *>(inst->state());
+ mpact::sim::generic::Instruction* inst) {
+ auto* state = static_cast<KelvinState*>(inst->state());
switch (log_mode) {
case 0: { // Format log op to set the format of the printout and print it.
std::string format_string;
@@ -89,11 +89,11 @@
case 2: { // Character log op to load a group of char[4] as an argument.
auto data =
mpact::sim::generic::GetInstructionSource<uint32_t>(inst, 0, 0);
- auto *clog_string = state->clog_string();
+ auto* clog_string = state->clog_string();
// CLOG can break a long character array as multiple CLOG calls, and they
// need to be combined as a single string argument.
*clog_string +=
- std::string(reinterpret_cast<char *>(&data), sizeof(uint32_t));
+ std::string(reinterpret_cast<char*>(&data), sizeof(uint32_t));
if (WordHasZero(data)) {
// Trim the string properly.
clog_string->resize(clog_string->find('\0'));
@@ -115,12 +115,12 @@
// Handle Store instructions for mmap_uncached addresses
template <typename T>
-void KelvinIStore(Instruction *inst) {
+void KelvinIStore(Instruction* inst) {
uint32_t base = mpact::sim::generic::GetInstructionSource<uint32_t>(inst, 0);
int32_t offset = mpact::sim::generic::GetInstructionSource<int32_t>(inst, 1);
uint32_t address = base + offset;
T value = mpact::sim::generic::GetInstructionSource<T>(inst, 2);
- auto *state = static_cast<KelvinState *>(inst->state());
+ auto* state = static_cast<KelvinState*>(inst->state());
// Check and exclude the cache invalidation bit. However, the semihost tests
// use the memory space greater than the kelvin HW configuration and do not
// comply to the magic bit setting. Exclude the check and mask for those
@@ -129,14 +129,14 @@
kKelvinMaxMemoryAddress) { // exclude semihost tests
address &= kMemMask;
}
- auto *db = state->db_factory()->Allocate(sizeof(T));
+ auto* db = state->db_factory()->Allocate(sizeof(T));
db->Set<T>(0, value);
state->StoreMemory(inst, address, db);
db->DecRef();
}
-template void KelvinIStore<uint32_t>(mpact::sim::generic::Instruction *inst);
-template void KelvinIStore<uint16_t>(mpact::sim::generic::Instruction *inst);
-template void KelvinIStore<uint8_t>(mpact::sim::generic::Instruction *inst);
+template void KelvinIStore<uint32_t>(mpact::sim::generic::Instruction* inst);
+template void KelvinIStore<uint16_t>(mpact::sim::generic::Instruction* inst);
+template void KelvinIStore<uint8_t>(mpact::sim::generic::Instruction* inst);
} // namespace kelvin::sim
diff --git a/sim/kelvin_instructions.h b/sim/kelvin_instructions.h
index 700e2e7..6e7d058 100644
--- a/sim/kelvin_instructions.h
+++ b/sim/kelvin_instructions.h
@@ -26,16 +26,16 @@
namespace kelvin::sim {
-void KelvinIllegalInstruction(mpact::sim::generic::Instruction *inst);
+void KelvinIllegalInstruction(mpact::sim::generic::Instruction* inst);
-void KelvinNopInstruction(mpact::sim::generic::Instruction *inst);
+void KelvinNopInstruction(mpact::sim::generic::Instruction* inst);
-void KelvinIMpause(const mpact::sim::generic::Instruction *inst);
+void KelvinIMpause(const mpact::sim::generic::Instruction* inst);
-void KelvinLogInstruction(int log_mode, mpact::sim::generic::Instruction *inst);
+void KelvinLogInstruction(int log_mode, mpact::sim::generic::Instruction* inst);
template <typename T>
-void KelvinIStore(mpact::sim::generic::Instruction *inst);
+void KelvinIStore(mpact::sim::generic::Instruction* inst);
} // namespace kelvin::sim
diff --git a/sim/kelvin_sim.cc b/sim/kelvin_sim.cc
index ca5717a..97a67c1 100644
--- a/sim/kelvin_sim.cc
+++ b/sim/kelvin_sim.cc
@@ -50,7 +50,7 @@
"Optionally set the entry point of the program.");
// Static pointer to the top instance. Used by the control-C handler.
-static kelvin::sim::KelvinTop *top = nullptr;
+static kelvin::sim::KelvinTop* top = nullptr;
// Control-c handler to interrupt any running simulation.
static void sim_sigint_handler(int arg) {
@@ -65,8 +65,8 @@
// Custom debug command to print all the scalar register values.
static bool PrintRegisters(
absl::string_view input,
- const mpact::sim::riscv::DebugCommandShell::CoreAccess &core_access,
- std::string &output) {
+ const mpact::sim::riscv::DebugCommandShell::CoreAccess& core_access,
+ std::string& output) {
LazyRE2 xreg_info_re{R"(\s*reg\s+info\s*)"};
if (!RE2::FullMatch(input, *xreg_info_re)) {
return false;
@@ -90,8 +90,8 @@
// Custom debug command to print all the assigned vector register values.
static bool PrintVectorRegisters(
absl::string_view input,
- const mpact::sim::riscv::DebugCommandShell::CoreAccess &core_access,
- std::string &output) {
+ const mpact::sim::riscv::DebugCommandShell::CoreAccess& core_access,
+ std::string& output) {
LazyRE2 vreg_info_re{R"(\s*vreg\s+info\s*)"};
if (!RE2::FullMatch(input, *vreg_info_re)) {
return false;
@@ -104,7 +104,7 @@
// Skip the register if error occurs.
continue;
}
- auto *db = result.value();
+ auto* db = result.value();
if (db == nullptr) {
// Skip the register if the data buffer is not available.
continue;
@@ -124,19 +124,19 @@
}
// Use ELF file's magic word to determine if the input file is an ELF file.
-static bool IsElfFile(std::string &file_name) {
+static bool IsElfFile(std::string& file_name) {
std::ifstream image_file;
image_file.open(file_name, std::ios::in | std::ios::binary);
if (image_file.good()) {
uint32_t magic_word;
- image_file.read(reinterpret_cast<char *>(&magic_word), sizeof(magic_word));
+ image_file.read(reinterpret_cast<char*>(&magic_word), sizeof(magic_word));
image_file.close();
return magic_word == 0x464c457f; // little endian ELF magic word.
}
return false;
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
absl::InitializeLog();
absl::SetProgramUsageMessage("Kelvin MPACT-Sim based CLI tool");
auto out_args = absl::ParseCommandLine(argc, argv);
diff --git a/sim/kelvin_state.cc b/sim/kelvin_state.cc
index 36b06b6..1a7d150 100644
--- a/sim/kelvin_state.cc
+++ b/sim/kelvin_state.cc
@@ -43,8 +43,8 @@
KelvinState::KelvinState(
absl::string_view id, mpact::sim::riscv::RiscVXlen xlen,
- mpact::sim::util::MemoryInterface *memory,
- mpact::sim::util::AtomicMemoryOpInterface *atomic_memory)
+ mpact::sim::util::MemoryInterface* memory,
+ mpact::sim::util::AtomicMemoryOpInterface* atomic_memory)
: mpact::sim::riscv::RiscVState(id, xlen, memory, atomic_memory),
kisa_("kisa", static_cast<RiscVCsrEnum>(KelvinCsrEnum::kKIsa), this) {
auto res = csr_set()->GetCsr("minstret");
@@ -65,21 +65,21 @@
LOG(FATAL) << "Failed to register kisa";
}
- absl::StatusOr<RiscVCsrInterface *> result = csr_set()->GetCsr("misa");
+ absl::StatusOr<RiscVCsrInterface*> result = csr_set()->GetCsr("misa");
if (!result.ok()) {
LOG(FATAL) << "Failed to get misa";
}
- auto *misa = *result;
+ auto* misa = *result;
misa->Set(kKelvinMisaVal);
}
KelvinState::KelvinState(absl::string_view id,
mpact::sim::riscv::RiscVXlen xlen,
- mpact::sim::util::MemoryInterface *memory)
+ mpact::sim::util::MemoryInterface* memory)
: KelvinState(id, xlen, memory, nullptr) {}
-void KelvinState::MPause(const Instruction *inst) {
- for (auto &handler : on_mpause_) {
+void KelvinState::MPause(const Instruction* inst) {
+ for (auto& handler : on_mpause_) {
bool res = handler(inst);
if (res) return;
}
@@ -90,7 +90,7 @@
// Print the logging message based on log_args_.
void KelvinState::PrintLog(absl::string_view format_string) {
- char *print_ptr = const_cast<char *>(format_string.data());
+ char* print_ptr = const_cast<char*>(format_string.data());
std::string log_string = "";
while (*print_ptr) {
if (*print_ptr == '%') {
diff --git a/sim/kelvin_state.h b/sim/kelvin_state.h
index c9fe51d..1e3631d 100644
--- a/sim/kelvin_state.h
+++ b/sim/kelvin_state.h
@@ -61,38 +61,38 @@
class KelvinState : public mpact::sim::riscv::RiscVState {
public:
KelvinState(absl::string_view id, mpact::sim::riscv::RiscVXlen xlen,
- mpact::sim::util::MemoryInterface *memory,
- mpact::sim::util::AtomicMemoryOpInterface *atomic_memory);
+ mpact::sim::util::MemoryInterface* memory,
+ mpact::sim::util::AtomicMemoryOpInterface* atomic_memory);
KelvinState(absl::string_view id, mpact::sim::riscv::RiscVXlen xlen,
- mpact::sim::util::MemoryInterface *memory);
+ mpact::sim::util::MemoryInterface* memory);
~KelvinState() override = default;
// Deleted Constructors and operators.
- KelvinState(const KelvinState &) = delete;
- KelvinState(KelvinState &&) = delete;
- KelvinState &operator=(const KelvinState &) = delete;
- KelvinState &operator=(KelvinState &&) = delete;
+ KelvinState(const KelvinState&) = delete;
+ KelvinState(KelvinState&&) = delete;
+ KelvinState& operator=(const KelvinState&) = delete;
+ KelvinState& operator=(KelvinState&&) = delete;
void set_vector_length(uint32_t length) { vector_length_ = length; }
uint32_t vector_length() const { return vector_length_; }
- AccArrayType *acc_vec(int index) { return &(acc_register_[index]); }
+ AccArrayType* acc_vec(int index) { return &(acc_register_[index]); }
AccArrayTemplate<AccArrayType> acc_register() const { return acc_register_; }
- uint32_t *dw_acc_vec(int i) { return &depthwise_acc_register_[i]; }
- DwAccArray &dw_acc_register() { return depthwise_acc_register_; }
- const DwAccArray &dw_acc_register() const { return depthwise_acc_register_; }
+ uint32_t* dw_acc_vec(int i) { return &depthwise_acc_register_[i]; }
+ DwAccArray& dw_acc_register() { return depthwise_acc_register_; }
+ const DwAccArray& dw_acc_register() const { return depthwise_acc_register_; }
void SetLogArgs(std::any data) { log_args_.emplace_back(std::move(data)); }
- std::string *clog_string() { return &clog_string_; }
+ std::string* clog_string() { return &clog_string_; }
void PrintLog(absl::string_view format_string);
// Extra Kelvin terminating state.
- void MPause(const Instruction *inst);
+ void MPause(const Instruction* inst);
// Add terminating state handler.
- void AddMpauseHandler(absl::AnyInvocable<bool(const Instruction *)> handler) {
+ void AddMpauseHandler(absl::AnyInvocable<bool(const Instruction*)> handler) {
on_mpause_.emplace_back(std::move(handler));
}
@@ -103,7 +103,7 @@
std::vector<std::any> log_args_;
std::string clog_string_;
// Extra state handlers
- std::vector<absl::AnyInvocable<bool(const Instruction *)>> on_mpause_;
+ std::vector<absl::AnyInvocable<bool(const Instruction*)>> on_mpause_;
// Convolution accumulation register, set to be uint32[VLENW][VLENW].
AccArrayTemplate<AccArrayType> acc_register_;
@@ -115,8 +115,8 @@
mpact::sim::riscv::RiscV32SimpleCsr kisa_;
// minstret CSR.
- mpact::sim::riscv::RiscVCsrInterface *minstret_;
- mpact::sim::riscv::RiscVCsrInterface *minstreth_;
+ mpact::sim::riscv::RiscVCsrInterface* minstret_;
+ mpact::sim::riscv::RiscVCsrInterface* minstreth_;
};
} // namespace kelvin::sim
diff --git a/sim/kelvin_top.cc b/sim/kelvin_top.cc
index 6cf7eba..fa313ea 100644
--- a/sim/kelvin_top.cc
+++ b/sim/kelvin_top.cc
@@ -78,13 +78,13 @@
constexpr char kKelvinName[] = "Kelvin";
// Local helper function used to execute instructions.
-static inline bool ExecuteInstruction(mpact::sim::util::Instruction *inst) {
- for (auto *resource : inst->ResourceHold()) {
+static inline bool ExecuteInstruction(mpact::sim::util::Instruction* inst) {
+ for (auto* resource : inst->ResourceHold()) {
if (!resource->IsFree()) {
return false;
}
}
- for (auto *resource : inst->ResourceAcquire()) {
+ for (auto* resource : inst->ResourceAcquire()) {
resource->Acquire();
}
inst->Execute(nullptr);
@@ -102,7 +102,7 @@
KelvinTop::KelvinTop(std::string name, uint64_t memory_block_size_bytes,
uint64_t memory_size_bytes,
- uint8_t **memory_block_ptr_list)
+ uint8_t** memory_block_ptr_list)
: Component(std::move(name)),
counter_num_instructions_{"num_instructions", 0},
counter_num_cycles_{"num_cycles", 0} {
@@ -176,7 +176,7 @@
mpact::sim::riscv::RiscVArmSemihost::BitWidth::kWord32, memory_, memory_);
// Set the software breakpoint callback.
state_->AddEbreakHandler(
- [this](const mpact::sim::generic::Instruction *inst) -> bool {
+ [this](const mpact::sim::generic::Instruction* inst) -> bool {
if (inst != nullptr) {
if (absl::GetFlag(FLAGS_use_semihost) &&
semihost_->IsSemihostingCall(inst)) {
@@ -195,7 +195,7 @@
});
state_->AddMpauseHandler(
- [this](const mpact::sim::generic::Instruction *inst) -> bool {
+ [this](const mpact::sim::generic::Instruction* inst) -> bool {
if (inst != nullptr) {
std::cout << "Program exits properly" << '\n';
RequestHalt(HaltReason::kUserRequest, inst);
@@ -207,7 +207,7 @@
// Set trap callbacks.
state_->set_on_trap([this](bool is_interrupt, uint64_t trap_value,
uint64_t exception_code, uint64_t epc,
- const Instruction *inst) -> bool {
+ const Instruction* inst) -> bool {
auto code = static_cast<mpact::sim::riscv::ExceptionCode>(exception_code);
bool result = false;
switch (code) {
@@ -237,24 +237,24 @@
// Connect counters to instret(h) and mcycle(h) CSRs.
auto csr_res = state_->csr_set()->GetCsr("minstret");
// Minstret/minstreth.
- auto *minstret = reinterpret_cast<RiscVCounterCsr<uint32_t, KelvinState> *>(
+ auto* minstret = reinterpret_cast<RiscVCounterCsr<uint32_t, KelvinState>*>(
csr_res.value());
minstret->set_counter(&counter_num_instructions_);
csr_res = state_->csr_set()->GetCsr("minstreth");
CHECK_OK(csr_res.status()) << "Failed to get minstret CSR";
- auto *minstreth =
- reinterpret_cast<RiscVCounterCsrHigh<KelvinState> *>(csr_res.value());
+ auto* minstreth =
+ reinterpret_cast<RiscVCounterCsrHigh<KelvinState>*>(csr_res.value());
minstreth->set_counter(&counter_num_instructions_);
// Mcycle/mcycleh.
csr_res = state_->csr_set()->GetCsr("mcycle");
CHECK_OK(csr_res.status()) << "Failed to get mcycle CSR";
- auto *mcycle = reinterpret_cast<RiscVCounterCsr<uint32_t, KelvinState> *>(
+ auto* mcycle = reinterpret_cast<RiscVCounterCsr<uint32_t, KelvinState>*>(
csr_res.value());
mcycle->set_counter(&counter_num_cycles_);
csr_res = state_->csr_set()->GetCsr("mcycleh");
CHECK_OK(csr_res.status()) << "Failed to get mcycleh CSR";
- auto *mcycleh =
- reinterpret_cast<RiscVCounterCsrHigh<KelvinState> *>(csr_res.value());
+ auto* mcycleh =
+ reinterpret_cast<RiscVCounterCsrHigh<KelvinState>*>(csr_res.value());
mcycleh->set_counter(&counter_num_cycles_);
semihost_->set_exit_callback(
@@ -344,7 +344,7 @@
uint64_t next_seq_pc;
while (!halted_ && (count < num)) {
pc = next_pc;
- auto *inst = decode_cache_->GetDecodedInstruction(pc);
+ auto* inst = decode_cache_->GetDecodedInstruction(pc);
next_seq_pc = pc + inst->size();
// Set the PC destination operand to next_seq_pc. Any branch that is
// executed will overwrite this.
@@ -424,7 +424,7 @@
std::fstream trace_file;
proto::TraceData trace_data;
- auto *inst_db = db_factory_.Allocate<uint32_t>(1);
+ auto* inst_db = db_factory_.Allocate<uint32_t>(1);
if (absl::GetFlag(FLAGS_trace)) {
std::string trace_path = absl::GetFlag(FLAGS_trace_path);
std::string trace_dir =
@@ -442,7 +442,7 @@
while (!halted_) {
pc = next_pc;
- auto *inst = decode_cache_->GetDecodedInstruction(pc);
+ auto* inst = decode_cache_->GetDecodedInstruction(pc);
next_seq_pc = pc + inst->size();
// Set the PC destination operand to next_seq_pc. Any branch that is
// executed will overwrite this.
@@ -454,7 +454,7 @@
// Set trace entry {address, instruction}
memory_->Load(pc, inst_db, nullptr, nullptr);
auto inst_word = inst_db->Get<uint32_t>(0);
- proto::TraceEntry *trace_entry = trace_data.add_entry();
+ proto::TraceEntry* trace_entry = trace_data.add_entry();
trace_entry->set_address(pc);
trace_entry->set_opcode(inst_word);
if (absl::GetFlag(FLAGS_trace_disasm)) {
@@ -528,7 +528,7 @@
return halt_reason_;
}
-absl::StatusOr<uint64_t> KelvinTop::ReadRegister(const std::string &name) {
+absl::StatusOr<uint64_t> KelvinTop::ReadRegister(const std::string& name) {
// The registers aren't protected by a mutex, so let's not read them while
// the simulator is running.
if (run_status_ != RunStatus::kHalted) {
@@ -543,11 +543,11 @@
return absl::NotFoundError(
absl::StrCat("Register '", name, "' not found"));
}
- auto *csr = *result;
+ auto* csr = *result;
return csr->GetUint32();
}
- auto *db = (iter->second)->data_buffer();
+ auto* db = (iter->second)->data_buffer();
uint64_t value;
switch (db->size<uint8_t>()) {
case 1:
@@ -568,7 +568,7 @@
return value;
}
-absl::Status KelvinTop::WriteRegister(const std::string &name, uint64_t value) {
+absl::Status KelvinTop::WriteRegister(const std::string& name, uint64_t value) {
// The registers aren't protected by a mutex, so let's not write them while
// the simulator is running.
if (run_status_ != RunStatus::kHalted) {
@@ -582,7 +582,7 @@
return absl::NotFoundError(
absl::StrCat("Register '", name, "' not found"));
}
- auto *csr = *result;
+ auto* csr = *result;
csr->Set(static_cast<uint32_t>(value));
return absl::OkStatus();
}
@@ -593,7 +593,7 @@
halt_reason_ = *HaltReason::kNone;
}
- auto *db = (iter->second)->data_buffer();
+ auto* db = (iter->second)->data_buffer();
switch (db->size<uint8_t>()) {
case 1:
db->Set<uint8_t>(0, static_cast<uint8_t>(value));
@@ -613,8 +613,8 @@
return absl::OkStatus();
}
-absl::StatusOr<DataBuffer *> KelvinTop::GetRegisterDataBuffer(
- const std::string &name) {
+absl::StatusOr<DataBuffer*> KelvinTop::GetRegisterDataBuffer(
+ const std::string& name) {
// The registers aren't protected by a mutex, so let's not access them while
// the simulator is running.
if (run_status_ != RunStatus::kHalted) {
@@ -628,7 +628,7 @@
return iter->second->data_buffer();
}
-absl::StatusOr<size_t> KelvinTop::ReadMemory(uint64_t address, void *buffer,
+absl::StatusOr<size_t> KelvinTop::ReadMemory(uint64_t address, void* buffer,
size_t length) {
if (run_status_ != RunStatus::kHalted) {
return absl::FailedPreconditionError("ReadMemory: Core must be halted");
@@ -638,7 +638,7 @@
}
length =
std::min<size_t>(length, state_->max_physical_address() - address + 1);
- auto *db = db_factory_.Allocate(length);
+ auto* db = db_factory_.Allocate(length);
// Load bypassing any watch points/semihosting.
state_->memory()->Load(address, db, nullptr, nullptr);
std::memcpy(buffer, db->raw_ptr(), length);
@@ -647,7 +647,7 @@
}
absl::StatusOr<size_t> KelvinTop::WriteMemory(uint64_t address,
- const void *buffer,
+ const void* buffer,
size_t length) {
if (run_status_ != RunStatus::kHalted) {
return absl::FailedPreconditionError("WriteMemory: Core must be halted");
@@ -657,7 +657,7 @@
}
length =
std::min<size_t>(length, state_->max_physical_address() - address + 1);
- auto *db = db_factory_.Allocate(length);
+ auto* db = db_factory_.Allocate(length);
std::memcpy(db->raw_ptr(), buffer, length);
// Store bypassing any watch points/semihosting.
state_->memory()->Store(address, db);
@@ -708,7 +708,7 @@
return absl::OkStatus();
}
-absl::StatusOr<mpact::sim::generic::Instruction *> KelvinTop::GetInstruction(
+absl::StatusOr<mpact::sim::generic::Instruction*> KelvinTop::GetInstruction(
uint64_t address) {
auto inst = decode_cache_->GetDecodedInstruction(address);
return inst;
@@ -720,7 +720,7 @@
return absl::FailedPreconditionError("GetDissasembly: Core must be halted");
}
- mpact::sim::generic::Instruction *inst = nullptr;
+ mpact::sim::generic::Instruction* inst = nullptr;
// If requesting the disassembly for an instruction at a breakpoint, return
// that of the original instruction instead.
// If requesting the disassembly for an instruction at an action point, return
@@ -743,7 +743,7 @@
return disasm;
}
-absl::Status KelvinTop::LoadImage(const std::string &image_path,
+absl::Status KelvinTop::LoadImage(const std::string& image_path,
uint64_t start_address) {
std::ifstream image_file;
constexpr size_t kBufferSize = 4096;
@@ -776,7 +776,7 @@
}
void KelvinTop::RequestHalt(HaltReasonValueType halt_reason,
- const mpact::sim::generic::Instruction *inst) {
+ const mpact::sim::generic::Instruction* inst) {
// First set the halt_reason_, then the halt flag.
halt_reason_ = halt_reason;
halted_ = true;
@@ -789,7 +789,7 @@
}
void KelvinTop::RequestHalt(HaltReason halt_reason,
- const mpact::sim::generic::Instruction *inst) {
+ const mpact::sim::generic::Instruction* inst) {
RequestHalt(*halt_reason, inst);
}
diff --git a/sim/kelvin_top.h b/sim/kelvin_top.h
index 8721e08..015be6c 100644
--- a/sim/kelvin_top.h
+++ b/sim/kelvin_top.h
@@ -70,7 +70,7 @@
explicit KelvinTop(std::string name);
KelvinTop(std::string name, uint64_t memory_block_size_bytes,
- uint64_t memory_size_bytes, uint8_t **memory_block_ptr_list);
+ uint64_t memory_size_bytes, uint8_t** memory_block_ptr_list);
~KelvinTop() override;
@@ -86,15 +86,15 @@
absl::StatusOr<HaltReasonValueType> GetLastHaltReason() override;
// Register access by register name.
- absl::StatusOr<uint64_t> ReadRegister(const std::string &name) override;
- absl::Status WriteRegister(const std::string &name, uint64_t value) override;
- absl::StatusOr<DataBuffer *> GetRegisterDataBuffer(
- const std::string &name) override;
+ absl::StatusOr<uint64_t> ReadRegister(const std::string& name) override;
+ absl::Status WriteRegister(const std::string& name, uint64_t value) override;
+ absl::StatusOr<DataBuffer*> GetRegisterDataBuffer(
+ const std::string& name) override;
// Read and Write memory methods bypass any semihosting.
- absl::StatusOr<size_t> ReadMemory(uint64_t address, void *buf,
+ absl::StatusOr<size_t> ReadMemory(uint64_t address, void* buf,
size_t length) override;
- absl::StatusOr<size_t> WriteMemory(uint64_t address, const void *buf,
+ absl::StatusOr<size_t> WriteMemory(uint64_t address, const void* buf,
size_t length) override;
bool HasBreakpoint(uint64_t address) override;
@@ -103,22 +103,22 @@
absl::Status ClearAllSwBreakpoints() override;
// Return the instruction object for the instruction at the given address.
- absl::StatusOr<mpact::sim::generic::Instruction *> GetInstruction(
+ absl::StatusOr<mpact::sim::generic::Instruction*> GetInstruction(
uint64_t address) override;
// Return the string representation for the instruction at the given address.
absl::StatusOr<std::string> GetDisassembly(uint64_t address) override;
// Called when a halt is requested.
void RequestHalt(HaltReasonValueType halt_reason,
- const mpact::sim::generic::Instruction *inst);
+ const mpact::sim::generic::Instruction* inst);
void RequestHalt(HaltReason halt_reason,
- const mpact::sim::generic::Instruction *inst);
+ const mpact::sim::generic::Instruction* inst);
// Load a binary image of the SW program.
- absl::Status LoadImage(const std::string &image_path, uint64_t start_address);
+ absl::Status LoadImage(const std::string& image_path, uint64_t start_address);
// Accessors.
- sim::KelvinState *state() const { return state_; }
- mpact::sim::util::MemoryInterface *memory() const { return memory_; }
+ sim::KelvinState* state() const { return state_; }
+ mpact::sim::util::MemoryInterface* memory() const { return memory_; }
// Cycle helper function
uint64_t GetCycleCount() const { return counter_num_cycles_.GetValue(); }
@@ -142,27 +142,27 @@
static_cast<HaltReasonValueType>(HaltReason::kNone);
// Halting flag. This is set to true when execution must halt.
bool halted_ = false;
- absl::Notification *run_halted_;
+ absl::Notification* run_halted_;
// The local Kelvin state.
- sim::KelvinState *state_;
- mpact::sim::riscv::RiscVFPState *fp_state_;
+ sim::KelvinState* state_;
+ mpact::sim::riscv::RiscVFPState* fp_state_;
// Memory interface used by action point manager.
- KelvinActionPointMemoryInterface *kelvin_ap_memory_interface_ = nullptr;
+ KelvinActionPointMemoryInterface* kelvin_ap_memory_interface_ = nullptr;
// Action point manager.
- ActionPointManagerBase *ap_manager_ = nullptr;
+ ActionPointManagerBase* ap_manager_ = nullptr;
// Breakpoint manager.
- BreakpointManager *bp_manager_ = nullptr;
+ BreakpointManager* bp_manager_ = nullptr;
// Flat to indicate that the current instruction is a break/action point that
// needs to be stepped over.
bool need_to_step_over_ = false;
// The pc register instance.
- mpact::sim::generic::RegisterBase *pc_;
+ mpact::sim::generic::RegisterBase* pc_;
// Kelvin decoder decoder instance.
- mpact::sim::generic::DecoderInterface *kelvin_decoder_ = nullptr;
+ mpact::sim::generic::DecoderInterface* kelvin_decoder_ = nullptr;
// Decode cache, memory and memory watcher.
- mpact::sim::generic::DecodeCache *decode_cache_ = nullptr;
- mpact::sim::util::MemoryInterface *memory_ = nullptr;
- mpact::sim::util::MemoryWatcher *watcher_ = nullptr;
+ mpact::sim::generic::DecodeCache* decode_cache_ = nullptr;
+ mpact::sim::util::MemoryInterface* memory_ = nullptr;
+ mpact::sim::util::MemoryWatcher* watcher_ = nullptr;
// Counter for the number of instructions simulated.
mpact::sim::generic::SimpleCounter<uint64_t>
counter_opcode_[static_cast<int>(sim::isa32::OpcodeEnum::kPastMaxValue)];
@@ -170,7 +170,7 @@
mpact::sim::generic::SimpleCounter<uint64_t> counter_num_cycles_;
absl::flat_hash_map<uint32_t, std::string> register_id_map_;
// Setup arm semihosting.
- mpact::sim::riscv::RiscVArmSemihost *semihost_ = nullptr;
+ mpact::sim::riscv::RiscVArmSemihost* semihost_ = nullptr;
};
} // namespace kelvin::sim
diff --git a/sim/kelvin_vector_convolution_instructions.cc b/sim/kelvin_vector_convolution_instructions.cc
index 46c1621..6a3c443 100644
--- a/sim/kelvin_vector_convolution_instructions.cc
+++ b/sim/kelvin_vector_convolution_instructions.cc
@@ -44,8 +44,8 @@
// vs3 (wide) is the starting register of group of up-to 8 vector
// registers. xs2 stores the convolution command.
// `vd` is not used in the op.
-void KelvinVConv(Instruction *inst) {
- auto state = static_cast<KelvinState *>(inst->state());
+void KelvinVConv(Instruction* inst) {
+ auto state = static_cast<KelvinState*>(inst->state());
vconv_cmd_t conv_cmd;
auto reg_data = GetInstructionSource<uint32_t>(inst, 1, 0);
@@ -72,8 +72,8 @@
}
// Read the narrow source.
- auto vs1 = static_cast<RV32VectorSourceOperand *>(inst->Source(0));
- auto vs3 = static_cast<RV32VectorSourceOperand *>(inst->Source(2));
+ auto vs1 = static_cast<RV32VectorSourceOperand*>(inst->Source(0));
+ auto vs3 = static_cast<RV32VectorSourceOperand*>(inst->Source(2));
AccArrayTemplate<std::array<uint8_t, kVectorLenInByte>> vec_narrow;
for (int vec_idx = 0; vec_idx < vec_narrow.size(); ++vec_idx) {
auto source_span = vs1->GetRegister(vec_idx)->data_buffer()->Get<uint8_t>();
@@ -135,8 +135,8 @@
// vs3 (wide) is the starting register of group of 3 vector registers.
// xs2 stores the convolution command.
// `vd` is used if |write_acc| is set to true.
-void KelvinVDwconv(bool write_acc, Instruction *inst) {
- KelvinState *state = static_cast<KelvinState *>(inst->state());
+void KelvinVDwconv(bool write_acc, Instruction* inst) {
+ KelvinState* state = static_cast<KelvinState*>(inst->state());
uint32_t reg_data = GetInstructionSource<uint32_t>(inst, 1, 0);
vdwconv_u8_t dwconv_cmd;
memcpy(&dwconv_cmd, ®_data, sizeof(dwconv_cmd));
@@ -177,7 +177,7 @@
break;
}
- auto vs1 = static_cast<RV32VectorSourceOperand *>(inst->Source(0));
+ auto vs1 = static_cast<RV32VectorSourceOperand*>(inst->Source(0));
absl::Span<uint32_t> vs10_span =
vs1->GetRegister(vs1_idx[0])->data_buffer()->Get<uint32_t>();
absl::Span<uint32_t> vs11_span =
@@ -213,12 +213,12 @@
/*epc=*/inst->address(), inst);
}
- auto vs3 = static_cast<RV32VectorSourceOperand *>(inst->Source(2));
- int32_t *acc = reinterpret_cast<int32_t *>(state->dw_acc_vec(0));
+ auto vs3 = static_cast<RV32VectorSourceOperand*>(inst->Source(2));
+ int32_t* acc = reinterpret_cast<int32_t*>(state->dw_acc_vec(0));
for (int r = 0; r < kDwRegisterProducts; r++) {
absl::Span<uint8_t> a_span = absl::Span<uint8_t>(
- reinterpret_cast<uint8_t *>(a_data + (r * kVectorLenInWord)),
+ reinterpret_cast<uint8_t*>(a_data + (r * kVectorLenInWord)),
kVectorLenInByte);
absl::Span<uint8_t> b_span =
vs3->GetRegister(r)->data_buffer()->Get<uint8_t>();
@@ -242,9 +242,9 @@
return;
}
- auto vd = static_cast<RV32VectorDestinationOperand *>(inst->Destination(0));
+ auto vd = static_cast<RV32VectorDestinationOperand*>(inst->Destination(0));
for (int i = 0; i < 4; i++) {
- DataBuffer *dest_db = vd->AllocateDataBuffer(i);
+ DataBuffer* dest_db = vd->AllocateDataBuffer(i);
absl::Span<uint32_t> dest_span = dest_db->Get<uint32_t>();
for (int j = 0; j < kVectorLenInWord; j++) {
dest_span[j] = acc[i * kVectorLenInWord + j];
diff --git a/sim/kelvin_vector_convolution_instructions.h b/sim/kelvin_vector_convolution_instructions.h
index b2d6861..6a0c7d5 100644
--- a/sim/kelvin_vector_convolution_instructions.h
+++ b/sim/kelvin_vector_convolution_instructions.h
@@ -48,9 +48,9 @@
uint32_t sdata2 : 1; // 31
} vdwconv_u8_t;
-void KelvinVConv(Instruction *inst);
+void KelvinVConv(Instruction* inst);
-void KelvinVDwconv(bool write_acc, Instruction *inst);
+void KelvinVDwconv(bool write_acc, Instruction* inst);
} // namespace kelvin::sim
diff --git a/sim/kelvin_vector_instructions.cc b/sim/kelvin_vector_instructions.cc
index 41f9fd9..5f0d6bb 100644
--- a/sim/kelvin_vector_instructions.cc
+++ b/sim/kelvin_vector_instructions.cc
@@ -47,10 +47,10 @@
}
template <typename Vd, typename Vs1, typename Vs2>
-Vs1 CommonBinaryOpGetArg1(const Instruction *inst, bool scalar, int num_ops,
+Vs1 CommonBinaryOpGetArg1(const Instruction* inst, bool scalar, int num_ops,
int op_index, int dst_element_index,
int dst_reg_index) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
auto elts_per_register = vector_size_in_bytes / sizeof(Vs1);
auto src_element_index = op_index * elts_per_register +
@@ -66,10 +66,10 @@
}
template <typename Vd, typename Vs1, typename Vs2>
-Vs2 CommonBinaryOpGetArg2(const Instruction *inst, bool scalar, int num_ops,
+Vs2 CommonBinaryOpGetArg2(const Instruction* inst, bool scalar, int num_ops,
int op_index, int dst_element_index,
int dst_reg_index) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
auto elts_per_register = vector_size_in_bytes / sizeof(Vs2);
auto src_element_index = op_index * elts_per_register +
@@ -80,18 +80,18 @@
template <typename T, typename Vd, typename Vs1, typename Vs2>
using SourceArgGetter =
- std::function<T(const Instruction *inst, bool scalar, int num_ops,
+ std::function<T(const Instruction* inst, bool scalar, int num_ops,
int op_index, int dst_element_index, int dst_reg_index)>;
template <bool halftype = false, bool widen_dst = false, typename Vd,
typename Vs1, typename Vs2, typename... VDArgs>
-void KelvinBinaryVectorOp(const Instruction *inst, bool scalar, bool strip_mine,
+void KelvinBinaryVectorOp(const Instruction* inst, bool scalar, bool strip_mine,
std::function<Vd(VDArgs..., Vs1, Vs2)> op,
SourceArgGetter<Vs1, Vd, Vs1, Vs2> arg1_getter =
CommonBinaryOpGetArg1<Vd, Vs1, Vs2>,
SourceArgGetter<Vs2, Vd, Vs1, Vs2> arg2_getter =
CommonBinaryOpGetArg2<Vd, Vs1, Vs2>) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
auto elts_per_dest_register = vector_size_in_bytes / sizeof(Vd);
@@ -103,10 +103,10 @@
constexpr size_t dest_regs_per_op = is_widen_op ? 2 : 1;
// Special case for VADD3 op which is adding dest value to vs1 + vs2.
constexpr bool is_reading_dest = sizeof...(VDArgs) == 1;
- auto vd = static_cast<RV32VectorDestinationOperand *>(inst->Destination(0));
+ auto vd = static_cast<RV32VectorDestinationOperand*>(inst->Destination(0));
for (int op_index = 0; op_index < num_ops; ++op_index) {
- DataBuffer *dest_db[dest_regs_per_op];
+ DataBuffer* dest_db[dest_regs_per_op];
absl::Span<Vd> dest_span[dest_regs_per_op];
for (int i = 0; i < dest_regs_per_op; ++i) {
@@ -136,20 +136,20 @@
}
template <typename Vd, typename Vs>
-void KelvinUnaryVectorOp(const Instruction *inst, bool strip_mine,
+void KelvinUnaryVectorOp(const Instruction* inst, bool strip_mine,
std::function<Vd(Vs)> op,
SourceArgGetter<Vs, Vd, Vs, Vs> arg_getter =
CommonBinaryOpGetArg1<Vd, Vs, Vs>) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
auto elts_per_dest_register = vector_size_in_bytes / sizeof(Vd);
// For kelvin, stripmining issues 4 contiguous vector ops.
auto num_ops = strip_mine ? 4 : 1;
- auto vd = static_cast<RV32VectorDestinationOperand *>(inst->Destination(0));
+ auto vd = static_cast<RV32VectorDestinationOperand*>(inst->Destination(0));
for (int op_index = 0; op_index < num_ops; ++op_index) {
- DataBuffer *dest_db = vd->AllocateDataBuffer(op_index);
+ DataBuffer* dest_db = vd->AllocateDataBuffer(op_index);
absl::Span<Vd> dest_span = dest_db->template Get<Vd>();
for (int dst_element_index = 0; dst_element_index < elts_per_dest_register;
@@ -164,7 +164,7 @@
}
template <typename T>
-void KelvinVAdd(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVAdd(bool scalar, bool strip_mine, Instruction* inst) {
// Return vs1 + vs2.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T {
@@ -176,12 +176,12 @@
return static_cast<T>(uvs1 + uvs2);
}));
}
-template void KelvinVAdd<int8_t>(bool, bool, Instruction *);
-template void KelvinVAdd<int16_t>(bool, bool, Instruction *);
-template void KelvinVAdd<int32_t>(bool, bool, Instruction *);
+template void KelvinVAdd<int8_t>(bool, bool, Instruction*);
+template void KelvinVAdd<int16_t>(bool, bool, Instruction*);
+template void KelvinVAdd<int32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVSub(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVSub(bool scalar, bool strip_mine, Instruction* inst) {
// Return vs1 - vs2.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T {
@@ -193,12 +193,12 @@
return static_cast<T>(uvs1 - uvs2);
}));
}
-template void KelvinVSub<int8_t>(bool, bool, Instruction *);
-template void KelvinVSub<int16_t>(bool, bool, Instruction *);
-template void KelvinVSub<int32_t>(bool, bool, Instruction *);
+template void KelvinVSub<int8_t>(bool, bool, Instruction*);
+template void KelvinVSub<int16_t>(bool, bool, Instruction*);
+template void KelvinVSub<int32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVRSub(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVRSub(bool scalar, bool strip_mine, Instruction* inst) {
// Return vs2 - vs1.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T {
@@ -210,90 +210,90 @@
return static_cast<T>(uvs2 - uvs1);
}));
}
-template void KelvinVRSub<int8_t>(bool, bool, Instruction *);
-template void KelvinVRSub<int16_t>(bool, bool, Instruction *);
-template void KelvinVRSub<int32_t>(bool, bool, Instruction *);
+template void KelvinVRSub<int8_t>(bool, bool, Instruction*);
+template void KelvinVRSub<int16_t>(bool, bool, Instruction*);
+template void KelvinVRSub<int32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVEq(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVEq(bool scalar, bool strip_mine, Instruction* inst) {
// Return 1 if vs1 and vs2 are equal, else returns 0.
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1 == vs2; }));
}
-template void KelvinVEq<int8_t>(bool, bool, Instruction *);
-template void KelvinVEq<int16_t>(bool, bool, Instruction *);
-template void KelvinVEq<int32_t>(bool, bool, Instruction *);
+template void KelvinVEq<int8_t>(bool, bool, Instruction*);
+template void KelvinVEq<int16_t>(bool, bool, Instruction*);
+template void KelvinVEq<int32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVNe(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVNe(bool scalar, bool strip_mine, Instruction* inst) {
// Return 1 if vs1 and vs2 are not equal, else return 0.
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1 != vs2; }));
}
-template void KelvinVNe<int8_t>(bool, bool, Instruction *);
-template void KelvinVNe<int16_t>(bool, bool, Instruction *);
-template void KelvinVNe<int32_t>(bool, bool, Instruction *);
+template void KelvinVNe<int8_t>(bool, bool, Instruction*);
+template void KelvinVNe<int16_t>(bool, bool, Instruction*);
+template void KelvinVNe<int32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVLt(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVLt(bool scalar, bool strip_mine, Instruction* inst) {
// Returns 1 if vs1 < vs2, else return 0.
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1 < vs2; }));
}
-template void KelvinVLt<int8_t>(bool, bool, Instruction *);
-template void KelvinVLt<int16_t>(bool, bool, Instruction *);
-template void KelvinVLt<int32_t>(bool, bool, Instruction *);
-template void KelvinVLt<uint8_t>(bool, bool, Instruction *);
-template void KelvinVLt<uint16_t>(bool, bool, Instruction *);
-template void KelvinVLt<uint32_t>(bool, bool, Instruction *);
+template void KelvinVLt<int8_t>(bool, bool, Instruction*);
+template void KelvinVLt<int16_t>(bool, bool, Instruction*);
+template void KelvinVLt<int32_t>(bool, bool, Instruction*);
+template void KelvinVLt<uint8_t>(bool, bool, Instruction*);
+template void KelvinVLt<uint16_t>(bool, bool, Instruction*);
+template void KelvinVLt<uint32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVLe(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVLe(bool scalar, bool strip_mine, Instruction* inst) {
// Returns 1 if vs1 <= vs2, else return 0.
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1 <= vs2; }));
}
-template void KelvinVLe<int8_t>(bool, bool, Instruction *);
-template void KelvinVLe<int16_t>(bool, bool, Instruction *);
-template void KelvinVLe<int32_t>(bool, bool, Instruction *);
-template void KelvinVLe<uint8_t>(bool, bool, Instruction *);
-template void KelvinVLe<uint16_t>(bool, bool, Instruction *);
-template void KelvinVLe<uint32_t>(bool, bool, Instruction *);
+template void KelvinVLe<int8_t>(bool, bool, Instruction*);
+template void KelvinVLe<int16_t>(bool, bool, Instruction*);
+template void KelvinVLe<int32_t>(bool, bool, Instruction*);
+template void KelvinVLe<uint8_t>(bool, bool, Instruction*);
+template void KelvinVLe<uint16_t>(bool, bool, Instruction*);
+template void KelvinVLe<uint32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVGt(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVGt(bool scalar, bool strip_mine, Instruction* inst) {
// Returns 1 if vs1 > vs2, else return 0.
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1 > vs2; }));
}
-template void KelvinVGt<int8_t>(bool, bool, Instruction *);
-template void KelvinVGt<int16_t>(bool, bool, Instruction *);
-template void KelvinVGt<int32_t>(bool, bool, Instruction *);
-template void KelvinVGt<uint8_t>(bool, bool, Instruction *);
-template void KelvinVGt<uint16_t>(bool, bool, Instruction *);
-template void KelvinVGt<uint32_t>(bool, bool, Instruction *);
+template void KelvinVGt<int8_t>(bool, bool, Instruction*);
+template void KelvinVGt<int16_t>(bool, bool, Instruction*);
+template void KelvinVGt<int32_t>(bool, bool, Instruction*);
+template void KelvinVGt<uint8_t>(bool, bool, Instruction*);
+template void KelvinVGt<uint16_t>(bool, bool, Instruction*);
+template void KelvinVGt<uint32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVGe(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVGe(bool scalar, bool strip_mine, Instruction* inst) {
// Returns 1 if vs1 >= vs2, else return 0.
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1 >= vs2; }));
}
-template void KelvinVGe<int8_t>(bool, bool, Instruction *);
-template void KelvinVGe<int16_t>(bool, bool, Instruction *);
-template void KelvinVGe<int32_t>(bool, bool, Instruction *);
-template void KelvinVGe<uint8_t>(bool, bool, Instruction *);
-template void KelvinVGe<uint16_t>(bool, bool, Instruction *);
-template void KelvinVGe<uint32_t>(bool, bool, Instruction *);
+template void KelvinVGe<int8_t>(bool, bool, Instruction*);
+template void KelvinVGe<int16_t>(bool, bool, Instruction*);
+template void KelvinVGe<int32_t>(bool, bool, Instruction*);
+template void KelvinVGe<uint8_t>(bool, bool, Instruction*);
+template void KelvinVGe<uint16_t>(bool, bool, Instruction*);
+template void KelvinVGe<uint32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVAbsd(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVAbsd(bool scalar, bool strip_mine, Instruction* inst) {
// Returns the absolute difference between vs1 and vs2.
// Note: for signed(INTx_MAX - INTx_MIN) the result will be UINTx_MAX.
KelvinBinaryVectorOp<false /* halftype */, false /* widen_dst */,
@@ -309,45 +309,45 @@
return vs1 > vs2 ? uvs1 - uvs2 : uvs2 - uvs1;
}));
}
-template void KelvinVAbsd<int8_t>(bool, bool, Instruction *);
-template void KelvinVAbsd<int16_t>(bool, bool, Instruction *);
-template void KelvinVAbsd<int32_t>(bool, bool, Instruction *);
-template void KelvinVAbsd<uint8_t>(bool, bool, Instruction *);
-template void KelvinVAbsd<uint16_t>(bool, bool, Instruction *);
-template void KelvinVAbsd<uint32_t>(bool, bool, Instruction *);
+template void KelvinVAbsd<int8_t>(bool, bool, Instruction*);
+template void KelvinVAbsd<int16_t>(bool, bool, Instruction*);
+template void KelvinVAbsd<int32_t>(bool, bool, Instruction*);
+template void KelvinVAbsd<uint8_t>(bool, bool, Instruction*);
+template void KelvinVAbsd<uint16_t>(bool, bool, Instruction*);
+template void KelvinVAbsd<uint32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVMax(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVMax(bool scalar, bool strip_mine, Instruction* inst) {
// Return the max of vs1 and vs2.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T {
return std::max(vs1, vs2);
}));
}
-template void KelvinVMax<int8_t>(bool, bool, Instruction *);
-template void KelvinVMax<int16_t>(bool, bool, Instruction *);
-template void KelvinVMax<int32_t>(bool, bool, Instruction *);
-template void KelvinVMax<uint8_t>(bool, bool, Instruction *);
-template void KelvinVMax<uint16_t>(bool, bool, Instruction *);
-template void KelvinVMax<uint32_t>(bool, bool, Instruction *);
+template void KelvinVMax<int8_t>(bool, bool, Instruction*);
+template void KelvinVMax<int16_t>(bool, bool, Instruction*);
+template void KelvinVMax<int32_t>(bool, bool, Instruction*);
+template void KelvinVMax<uint8_t>(bool, bool, Instruction*);
+template void KelvinVMax<uint16_t>(bool, bool, Instruction*);
+template void KelvinVMax<uint32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVMin(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVMin(bool scalar, bool strip_mine, Instruction* inst) {
// Return the min of vs1 and vs2.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T {
return std::min(vs1, vs2);
}));
}
-template void KelvinVMin<int8_t>(bool, bool, Instruction *);
-template void KelvinVMin<int16_t>(bool, bool, Instruction *);
-template void KelvinVMin<int32_t>(bool, bool, Instruction *);
-template void KelvinVMin<uint8_t>(bool, bool, Instruction *);
-template void KelvinVMin<uint16_t>(bool, bool, Instruction *);
-template void KelvinVMin<uint32_t>(bool, bool, Instruction *);
+template void KelvinVMin<int8_t>(bool, bool, Instruction*);
+template void KelvinVMin<int16_t>(bool, bool, Instruction*);
+template void KelvinVMin<int32_t>(bool, bool, Instruction*);
+template void KelvinVMin<uint8_t>(bool, bool, Instruction*);
+template void KelvinVMin<uint16_t>(bool, bool, Instruction*);
+template void KelvinVMin<uint32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVAdd3(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVAdd3(bool scalar, bool strip_mine, Instruction* inst) {
// Return the summation of vd, vs1, and vs2.
KelvinBinaryVectorOp<false /* halftype */, false /* widen_dst */, T, T, T, T>(
inst, scalar, strip_mine,
@@ -359,9 +359,9 @@
return static_cast<T>(uvd + uvs1 + uvs2);
}));
}
-template void KelvinVAdd3<int8_t>(bool, bool, Instruction *);
-template void KelvinVAdd3<int16_t>(bool, bool, Instruction *);
-template void KelvinVAdd3<int32_t>(bool, bool, Instruction *);
+template void KelvinVAdd3<int8_t>(bool, bool, Instruction*);
+template void KelvinVAdd3<int16_t>(bool, bool, Instruction*);
+template void KelvinVAdd3<int32_t>(bool, bool, Instruction*);
// Helper function for Vadds (saturated signed addition).
// Uses unsigned arithmetic for the addition to avoid signed overflow, which,
@@ -381,14 +381,14 @@
}
template <typename T>
-void KelvinVAdds(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVAdds(bool scalar, bool strip_mine, Instruction* inst) {
// Return saturated sum of vs1 and vs2.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>(VAddsHelper<T>));
}
-template void KelvinVAdds<int8_t>(bool, bool, Instruction *);
-template void KelvinVAdds<int16_t>(bool, bool, Instruction *);
-template void KelvinVAdds<int32_t>(bool, bool, Instruction *);
+template void KelvinVAdds<int8_t>(bool, bool, Instruction*);
+template void KelvinVAdds<int16_t>(bool, bool, Instruction*);
+template void KelvinVAdds<int32_t>(bool, bool, Instruction*);
// Helper function for Vaddsu (saturated unsigned addition).
template <typename T>
@@ -401,14 +401,14 @@
}
template <typename T>
-void KelvinVAddsu(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVAddsu(bool scalar, bool strip_mine, Instruction* inst) {
// Return saturated sum of unsigned vs1 and vs2.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>(VAddsuHelper<T>));
}
-template void KelvinVAddsu<uint8_t>(bool, bool, Instruction *);
-template void KelvinVAddsu<uint16_t>(bool, bool, Instruction *);
-template void KelvinVAddsu<uint32_t>(bool, bool, Instruction *);
+template void KelvinVAddsu<uint8_t>(bool, bool, Instruction*);
+template void KelvinVAddsu<uint16_t>(bool, bool, Instruction*);
+template void KelvinVAddsu<uint32_t>(bool, bool, Instruction*);
// Helper function for Vsubs (saturated signed subtraction).
template <typename T>
@@ -426,55 +426,55 @@
}
template <typename T>
-void KelvinVSubs(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVSubs(bool scalar, bool strip_mine, Instruction* inst) {
// Return saturated sub of vs1 and vs2.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>(VSubsHelper<T>));
}
-template void KelvinVSubs<int8_t>(bool, bool, Instruction *);
-template void KelvinVSubs<int16_t>(bool, bool, Instruction *);
-template void KelvinVSubs<int32_t>(bool, bool, Instruction *);
+template void KelvinVSubs<int8_t>(bool, bool, Instruction*);
+template void KelvinVSubs<int16_t>(bool, bool, Instruction*);
+template void KelvinVSubs<int32_t>(bool, bool, Instruction*);
template <typename T>
-void KelvinVSubsu(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVSubsu(bool scalar, bool strip_mine, Instruction* inst) {
// Return saturated sub of unsigned vs1 and vs2.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T {
return vs1 < vs2 ? 0 : vs1 - vs2;
}));
}
-template void KelvinVSubsu<uint8_t>(bool, bool, Instruction *);
-template void KelvinVSubsu<uint16_t>(bool, bool, Instruction *);
-template void KelvinVSubsu<uint32_t>(bool, bool, Instruction *);
+template void KelvinVSubsu<uint8_t>(bool, bool, Instruction*);
+template void KelvinVSubsu<uint16_t>(bool, bool, Instruction*);
+template void KelvinVSubsu<uint32_t>(bool, bool, Instruction*);
template <typename Td, typename Ts>
-void KelvinVAddw(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVAddw(bool scalar, bool strip_mine, Instruction* inst) {
// Adds operands with widening.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<Td(Ts, Ts)>([](Ts vs1, Ts vs2) -> Td {
return static_cast<Td>(vs1) + static_cast<Td>(vs2);
}));
}
-template void KelvinVAddw<int16_t, int8_t>(bool, bool, Instruction *);
-template void KelvinVAddw<int32_t, int16_t>(bool, bool, Instruction *);
-template void KelvinVAddw<uint16_t, uint8_t>(bool, bool, Instruction *);
-template void KelvinVAddw<uint32_t, uint16_t>(bool, bool, Instruction *);
+template void KelvinVAddw<int16_t, int8_t>(bool, bool, Instruction*);
+template void KelvinVAddw<int32_t, int16_t>(bool, bool, Instruction*);
+template void KelvinVAddw<uint16_t, uint8_t>(bool, bool, Instruction*);
+template void KelvinVAddw<uint32_t, uint16_t>(bool, bool, Instruction*);
template <typename Td, typename Ts>
-void KelvinVSubw(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVSubw(bool scalar, bool strip_mine, Instruction* inst) {
// Subtracts operands with widening.
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<Td(Ts, Ts)>([](Ts vs1, Ts vs2) -> Td {
return static_cast<Td>(vs1) - static_cast<Td>(vs2);
}));
}
-template void KelvinVSubw<int16_t, int8_t>(bool, bool, Instruction *);
-template void KelvinVSubw<int32_t, int16_t>(bool, bool, Instruction *);
-template void KelvinVSubw<uint16_t, uint8_t>(bool, bool, Instruction *);
-template void KelvinVSubw<uint32_t, uint16_t>(bool, bool, Instruction *);
+template void KelvinVSubw<int16_t, int8_t>(bool, bool, Instruction*);
+template void KelvinVSubw<int32_t, int16_t>(bool, bool, Instruction*);
+template void KelvinVSubw<uint16_t, uint8_t>(bool, bool, Instruction*);
+template void KelvinVSubw<uint32_t, uint16_t>(bool, bool, Instruction*);
template <typename Td, typename Ts2>
-void KelvinVAcc(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVAcc(bool scalar, bool strip_mine, Instruction* inst) {
// Accumulates operands with widening.
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
@@ -483,16 +483,16 @@
return static_cast<Td>(static_cast<UTd>(vs1) + static_cast<UTd>(vs2));
}));
}
-template void KelvinVAcc<int16_t, int8_t>(bool, bool, Instruction *);
-template void KelvinVAcc<int32_t, int16_t>(bool, bool, Instruction *);
-template void KelvinVAcc<uint16_t, uint8_t>(bool, bool, Instruction *);
-template void KelvinVAcc<uint32_t, uint16_t>(bool, bool, Instruction *);
+template void KelvinVAcc<int16_t, int8_t>(bool, bool, Instruction*);
+template void KelvinVAcc<int32_t, int16_t>(bool, bool, Instruction*);
+template void KelvinVAcc<uint16_t, uint8_t>(bool, bool, Instruction*);
+template void KelvinVAcc<uint32_t, uint16_t>(bool, bool, Instruction*);
template <typename Vd, typename Vs1, typename Vs2>
-Vs1 PackedBinaryOpGetArg1(const Instruction *inst, bool scalar, int num_ops,
+Vs1 PackedBinaryOpGetArg1(const Instruction* inst, bool scalar, int num_ops,
int op_index, int dst_element_index,
int dst_reg_index) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
auto elts_per_register = vector_size_in_bytes / sizeof(Vs1);
auto src_element_index = op_index * elts_per_register +
@@ -501,10 +501,10 @@
}
template <typename Vd, typename Vs1, typename Vs2>
-Vs2 PackedBinaryOpGetArg2(const Instruction *inst, bool scalar, int num_ops,
+Vs2 PackedBinaryOpGetArg2(const Instruction* inst, bool scalar, int num_ops,
int op_index, int dst_element_index,
int dst_reg_index) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
auto elts_per_register = vector_size_in_bytes / sizeof(Vs2);
auto src_element_index = op_index * elts_per_register +
@@ -513,7 +513,7 @@
}
template <typename Td, typename Ts>
-void KelvinVPadd(bool strip_mine, Instruction *inst) {
+void KelvinVPadd(bool strip_mine, Instruction* inst) {
// Adds lane pairs.
KelvinBinaryVectorOp<true /* halftype */, false /* widen_dst */, Td, Ts, Ts>(
inst, false /* scalar */, strip_mine,
@@ -523,13 +523,13 @@
SourceArgGetter<Ts, Td, Ts, Ts>(PackedBinaryOpGetArg1<Td, Ts, Ts>),
SourceArgGetter<Ts, Td, Ts, Ts>(PackedBinaryOpGetArg2<Td, Ts, Ts>));
}
-template void KelvinVPadd<int16_t, int8_t>(bool, Instruction *);
-template void KelvinVPadd<int32_t, int16_t>(bool, Instruction *);
-template void KelvinVPadd<uint16_t, uint8_t>(bool, Instruction *);
-template void KelvinVPadd<uint32_t, uint16_t>(bool, Instruction *);
+template void KelvinVPadd<int16_t, int8_t>(bool, Instruction*);
+template void KelvinVPadd<int32_t, int16_t>(bool, Instruction*);
+template void KelvinVPadd<uint16_t, uint8_t>(bool, Instruction*);
+template void KelvinVPadd<uint32_t, uint16_t>(bool, Instruction*);
template <typename Td, typename Ts>
-void KelvinVPsub(bool strip_mine, Instruction *inst) {
+void KelvinVPsub(bool strip_mine, Instruction* inst) {
// Subtracts lane pairs.
KelvinBinaryVectorOp<true /* halftype */, false /* widen_dst */, Td, Ts, Ts>(
inst, false /* scalar */, strip_mine,
@@ -539,10 +539,10 @@
SourceArgGetter<Ts, Td, Ts, Ts>(PackedBinaryOpGetArg1<Td, Ts, Ts>),
SourceArgGetter<Ts, Td, Ts, Ts>(PackedBinaryOpGetArg2<Td, Ts, Ts>));
}
-template void KelvinVPsub<int16_t, int8_t>(bool, Instruction *);
-template void KelvinVPsub<int32_t, int16_t>(bool, Instruction *);
-template void KelvinVPsub<uint16_t, uint8_t>(bool, Instruction *);
-template void KelvinVPsub<uint32_t, uint16_t>(bool, Instruction *);
+template void KelvinVPsub<int16_t, int8_t>(bool, Instruction*);
+template void KelvinVPsub<int32_t, int16_t>(bool, Instruction*);
+template void KelvinVPsub<uint16_t, uint8_t>(bool, Instruction*);
+template void KelvinVPsub<uint32_t, uint16_t>(bool, Instruction*);
// Halving addition with optional rounding bit.
template <typename T>
@@ -553,17 +553,17 @@
}
template <typename T>
-void KelvinVHadd(bool scalar, bool strip_mine, bool round, Instruction *inst) {
+void KelvinVHadd(bool scalar, bool strip_mine, bool round, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>(absl::bind_front(&KelvinVHaddHelper<T>, round)));
}
-template void KelvinVHadd<int8_t>(bool, bool, bool, Instruction *);
-template void KelvinVHadd<int16_t>(bool, bool, bool, Instruction *);
-template void KelvinVHadd<int32_t>(bool, bool, bool, Instruction *);
-template void KelvinVHadd<uint8_t>(bool, bool, bool, Instruction *);
-template void KelvinVHadd<uint16_t>(bool, bool, bool, Instruction *);
-template void KelvinVHadd<uint32_t>(bool, bool, bool, Instruction *);
+template void KelvinVHadd<int8_t>(bool, bool, bool, Instruction*);
+template void KelvinVHadd<int16_t>(bool, bool, bool, Instruction*);
+template void KelvinVHadd<int32_t>(bool, bool, bool, Instruction*);
+template void KelvinVHadd<uint8_t>(bool, bool, bool, Instruction*);
+template void KelvinVHadd<uint16_t>(bool, bool, bool, Instruction*);
+template void KelvinVHadd<uint32_t>(bool, bool, bool, Instruction*);
// Halving subtraction with optional rounding bit.
template <typename T>
@@ -574,54 +574,54 @@
}
template <typename T>
-void KelvinVHsub(bool scalar, bool strip_mine, bool round, Instruction *inst) {
+void KelvinVHsub(bool scalar, bool strip_mine, bool round, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>(absl::bind_front(&KelvinVHsubHelper<T>, round)));
}
-template void KelvinVHsub<int8_t>(bool, bool, bool, Instruction *);
-template void KelvinVHsub<int16_t>(bool, bool, bool, Instruction *);
-template void KelvinVHsub<int32_t>(bool, bool, bool, Instruction *);
-template void KelvinVHsub<uint8_t>(bool, bool, bool, Instruction *);
-template void KelvinVHsub<uint16_t>(bool, bool, bool, Instruction *);
-template void KelvinVHsub<uint32_t>(bool, bool, bool, Instruction *);
+template void KelvinVHsub<int8_t>(bool, bool, bool, Instruction*);
+template void KelvinVHsub<int16_t>(bool, bool, bool, Instruction*);
+template void KelvinVHsub<int32_t>(bool, bool, bool, Instruction*);
+template void KelvinVHsub<uint8_t>(bool, bool, bool, Instruction*);
+template void KelvinVHsub<uint16_t>(bool, bool, bool, Instruction*);
+template void KelvinVHsub<uint32_t>(bool, bool, bool, Instruction*);
// Bitwise and.
template <typename T>
-void KelvinVAnd(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVAnd(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1 & vs2; }));
}
-template void KelvinVAnd<uint8_t>(bool, bool, Instruction *);
-template void KelvinVAnd<uint16_t>(bool, bool, Instruction *);
-template void KelvinVAnd<uint32_t>(bool, bool, Instruction *);
+template void KelvinVAnd<uint8_t>(bool, bool, Instruction*);
+template void KelvinVAnd<uint16_t>(bool, bool, Instruction*);
+template void KelvinVAnd<uint32_t>(bool, bool, Instruction*);
// Bitwise or.
template <typename T>
-void KelvinVOr(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVOr(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1 | vs2; }));
}
-template void KelvinVOr<uint8_t>(bool, bool, Instruction *);
-template void KelvinVOr<uint16_t>(bool, bool, Instruction *);
-template void KelvinVOr<uint32_t>(bool, bool, Instruction *);
+template void KelvinVOr<uint8_t>(bool, bool, Instruction*);
+template void KelvinVOr<uint16_t>(bool, bool, Instruction*);
+template void KelvinVOr<uint32_t>(bool, bool, Instruction*);
// Bitwise xor.
template <typename T>
-void KelvinVXor(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVXor(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1 ^ vs2; }));
}
-template void KelvinVXor<uint8_t>(bool, bool, Instruction *);
-template void KelvinVXor<uint16_t>(bool, bool, Instruction *);
-template void KelvinVXor<uint32_t>(bool, bool, Instruction *);
+template void KelvinVXor<uint8_t>(bool, bool, Instruction*);
+template void KelvinVXor<uint16_t>(bool, bool, Instruction*);
+template void KelvinVXor<uint32_t>(bool, bool, Instruction*);
// Generalized reverse using bit ladder.
template <typename T>
-void KelvinVRev(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVRev(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine, std::function<T(T, T)>([](T vs1, T vs2) -> T {
T r = vs1;
@@ -636,13 +636,13 @@
return r;
}));
}
-template void KelvinVRev<uint8_t>(bool, bool, Instruction *);
-template void KelvinVRev<uint16_t>(bool, bool, Instruction *);
-template void KelvinVRev<uint32_t>(bool, bool, Instruction *);
+template void KelvinVRev<uint8_t>(bool, bool, Instruction*);
+template void KelvinVRev<uint16_t>(bool, bool, Instruction*);
+template void KelvinVRev<uint32_t>(bool, bool, Instruction*);
// Cyclic rotation right using a bit ladder.
template <typename T>
-void KelvinVRor(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVRor(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T {
T r = vs1;
@@ -654,13 +654,13 @@
return r;
}));
}
-template void KelvinVRor<uint8_t>(bool, bool, Instruction *);
-template void KelvinVRor<uint16_t>(bool, bool, Instruction *);
-template void KelvinVRor<uint32_t>(bool, bool, Instruction *);
+template void KelvinVRor<uint8_t>(bool, bool, Instruction*);
+template void KelvinVRor<uint16_t>(bool, bool, Instruction*);
+template void KelvinVRor<uint32_t>(bool, bool, Instruction*);
// Returns Arg1 as either vs1 or vs2 based on dst_reg_index.
template <typename Vd, typename Vs1, typename Vs2>
-Vs1 VMvpOpGetArg1(const Instruction *inst, bool scalar, int num_ops,
+Vs1 VMvpOpGetArg1(const Instruction* inst, bool scalar, int num_ops,
int op_index, int dst_element_index, int dst_reg_index) {
return dst_reg_index == 0
? CommonBinaryOpGetArg1<Vd, Vs1, Vs2>(
@@ -671,7 +671,7 @@
// Copies a pair of registers.
template <typename T>
-void KelvinVMvp(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVMvp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp<false /* halftype */, true /* widen_dst */, T, T, T>(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1; }),
@@ -680,48 +680,48 @@
// getter expects extra source registers for widening ops.
SourceArgGetter<T, T, T, T>(VMvpOpGetArg1<T, T, T>));
}
-template void KelvinVMvp<uint8_t>(bool, bool, Instruction *);
-template void KelvinVMvp<uint16_t>(bool, bool, Instruction *);
-template void KelvinVMvp<uint32_t>(bool, bool, Instruction *);
+template void KelvinVMvp<uint8_t>(bool, bool, Instruction*);
+template void KelvinVMvp<uint16_t>(bool, bool, Instruction*);
+template void KelvinVMvp<uint32_t>(bool, bool, Instruction*);
// Logical shift left.
template <typename T>
-void KelvinVSll(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVSll(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T {
size_t shift = vs2 & (sizeof(T) * 8 - 1);
return vs1 << shift;
}));
}
-template void KelvinVSll<uint8_t>(bool, bool, Instruction *);
-template void KelvinVSll<uint16_t>(bool, bool, Instruction *);
-template void KelvinVSll<uint32_t>(bool, bool, Instruction *);
+template void KelvinVSll<uint8_t>(bool, bool, Instruction*);
+template void KelvinVSll<uint16_t>(bool, bool, Instruction*);
+template void KelvinVSll<uint32_t>(bool, bool, Instruction*);
// Arithmetic shift right.
template <typename T>
-void KelvinVSra(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVSra(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T {
size_t shift = vs2 & (sizeof(T) * 8 - 1);
return vs1 >> shift;
}));
}
-template void KelvinVSra<int8_t>(bool, bool, Instruction *);
-template void KelvinVSra<int16_t>(bool, bool, Instruction *);
-template void KelvinVSra<int32_t>(bool, bool, Instruction *);
+template void KelvinVSra<int8_t>(bool, bool, Instruction*);
+template void KelvinVSra<int16_t>(bool, bool, Instruction*);
+template void KelvinVSra<int32_t>(bool, bool, Instruction*);
// Logical shift right.
template <typename T>
-void KelvinVSrl(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVSrl(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T {
size_t shift = vs2 & (sizeof(T) * 8 - 1);
return vs1 >> shift;
}));
}
-template void KelvinVSrl<uint8_t>(bool, bool, Instruction *);
-template void KelvinVSrl<uint16_t>(bool, bool, Instruction *);
-template void KelvinVSrl<uint32_t>(bool, bool, Instruction *);
+template void KelvinVSrl<uint8_t>(bool, bool, Instruction*);
+template void KelvinVSrl<uint16_t>(bool, bool, Instruction*);
+template void KelvinVSrl<uint32_t>(bool, bool, Instruction*);
// Logical and arithmetic left/right shift with saturating shift amount and
// result.
@@ -785,75 +785,75 @@
}
template <typename T>
-void KelvinVShift(bool round, bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVShift(bool round, bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>(absl::bind_front(&KelvinVShiftHelper<T>, round)));
}
-template void KelvinVShift<int8_t>(bool, bool, bool, Instruction *);
-template void KelvinVShift<int16_t>(bool, bool, bool, Instruction *);
-template void KelvinVShift<int32_t>(bool, bool, bool, Instruction *);
-template void KelvinVShift<uint8_t>(bool, bool, bool, Instruction *);
-template void KelvinVShift<uint16_t>(bool, bool, bool, Instruction *);
-template void KelvinVShift<uint32_t>(bool, bool, bool, Instruction *);
+template void KelvinVShift<int8_t>(bool, bool, bool, Instruction*);
+template void KelvinVShift<int16_t>(bool, bool, bool, Instruction*);
+template void KelvinVShift<int32_t>(bool, bool, bool, Instruction*);
+template void KelvinVShift<uint8_t>(bool, bool, bool, Instruction*);
+template void KelvinVShift<uint16_t>(bool, bool, bool, Instruction*);
+template void KelvinVShift<uint32_t>(bool, bool, bool, Instruction*);
// Bitwise not.
template <typename T>
-void KelvinVNot(bool strip_mine, Instruction *inst) {
+void KelvinVNot(bool strip_mine, Instruction* inst) {
KelvinUnaryVectorOp(inst, strip_mine,
std::function<T(T)>([](T vs) -> T { return ~vs; }));
}
-template void KelvinVNot<int32_t>(bool, Instruction *);
+template void KelvinVNot<int32_t>(bool, Instruction*);
// Count the leading bits.
template <typename T>
-void KelvinVClb(bool strip_mine, Instruction *inst) {
+void KelvinVClb(bool strip_mine, Instruction* inst) {
KelvinUnaryVectorOp(inst, strip_mine, std::function<T(T)>([](T vs) -> T {
return (vs & (1u << (sizeof(T) * 8 - 1)))
? absl::countl_one(vs)
: absl::countl_zero(vs);
}));
}
-template void KelvinVClb<uint8_t>(bool, Instruction *);
-template void KelvinVClb<uint16_t>(bool, Instruction *);
-template void KelvinVClb<uint32_t>(bool, Instruction *);
+template void KelvinVClb<uint8_t>(bool, Instruction*);
+template void KelvinVClb<uint16_t>(bool, Instruction*);
+template void KelvinVClb<uint32_t>(bool, Instruction*);
// Count the leading zeros.
template <typename T>
-void KelvinVClz(bool strip_mine, Instruction *inst) {
+void KelvinVClz(bool strip_mine, Instruction* inst) {
KelvinUnaryVectorOp(inst, strip_mine, std::function<T(T)>([](T vs) -> T {
return absl::countl_zero(vs);
}));
}
-template void KelvinVClz<uint8_t>(bool, Instruction *);
-template void KelvinVClz<uint16_t>(bool, Instruction *);
-template void KelvinVClz<uint32_t>(bool, Instruction *);
+template void KelvinVClz<uint8_t>(bool, Instruction*);
+template void KelvinVClz<uint16_t>(bool, Instruction*);
+template void KelvinVClz<uint32_t>(bool, Instruction*);
// Count the set bits.
template <typename T>
-void KelvinVCpop(bool strip_mine, Instruction *inst) {
+void KelvinVCpop(bool strip_mine, Instruction* inst) {
KelvinUnaryVectorOp(inst, strip_mine, std::function<T(T)>([](T vs) -> T {
return absl::popcount(vs);
}));
}
-template void KelvinVCpop<uint8_t>(bool, Instruction *);
-template void KelvinVCpop<uint16_t>(bool, Instruction *);
-template void KelvinVCpop<uint32_t>(bool, Instruction *);
+template void KelvinVCpop<uint8_t>(bool, Instruction*);
+template void KelvinVCpop<uint16_t>(bool, Instruction*);
+template void KelvinVCpop<uint32_t>(bool, Instruction*);
// Move a register.
template <typename T>
-void KelvinVMv(bool strip_mine, Instruction *inst) {
+void KelvinVMv(bool strip_mine, Instruction* inst) {
KelvinUnaryVectorOp(inst, strip_mine,
std::function<T(T)>([](T vs) -> T { return vs; }));
}
-template void KelvinVMv<int32_t>(bool, Instruction *);
+template void KelvinVMv<int32_t>(bool, Instruction*);
// Alternates Vs1 register used for odd/even destination indices.
template <typename Vd, typename Vs1, typename Vs2>
-Vs1 VSransOpGetArg1(const Instruction *inst, bool scalar, int num_ops,
+Vs1 VSransOpGetArg1(const Instruction* inst, bool scalar, int num_ops,
int op_index, int dst_element_index, int dst_reg_index) {
static_assert(2 * sizeof(Vd) == sizeof(Vs1) || 4 * sizeof(Vd) == sizeof(Vs1));
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
auto elts_per_register = vector_size_in_bytes / sizeof(Vs1);
auto src_element_index = op_index * elts_per_register +
@@ -893,23 +893,23 @@
}
template <typename Td, typename Ts>
-void KelvinVSrans(bool round, bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVSrans(bool round, bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<Td(Ts, Td)>(
absl::bind_front(&KelvinVSransHelper<Td, Ts>, round)),
SourceArgGetter<Ts, Td, Ts, Td>(VSransOpGetArg1<Td, Ts, Td>));
}
-template void KelvinVSrans<int8_t, int16_t>(bool, bool, bool, Instruction *);
-template void KelvinVSrans<int16_t, int32_t>(bool, bool, bool, Instruction *);
-template void KelvinVSrans<uint8_t, uint16_t>(bool, bool, bool, Instruction *);
-template void KelvinVSrans<uint16_t, uint32_t>(bool, bool, bool, Instruction *);
-template void KelvinVSrans<int8_t, int32_t>(bool, bool, bool, Instruction *);
-template void KelvinVSrans<uint8_t, uint32_t>(bool, bool, bool, Instruction *);
+template void KelvinVSrans<int8_t, int16_t>(bool, bool, bool, Instruction*);
+template void KelvinVSrans<int16_t, int32_t>(bool, bool, bool, Instruction*);
+template void KelvinVSrans<uint8_t, uint16_t>(bool, bool, bool, Instruction*);
+template void KelvinVSrans<uint16_t, uint32_t>(bool, bool, bool, Instruction*);
+template void KelvinVSrans<int8_t, int32_t>(bool, bool, bool, Instruction*);
+template void KelvinVSrans<uint8_t, uint32_t>(bool, bool, bool, Instruction*);
// Multiplication of vector elements.
template <typename T>
-void KelvinVMul(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVMul(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine, std::function<T(T, T)>([](T vs1, T vs2) -> T {
using WT = typename mpact::sim::generic::WideType<T>::type;
@@ -917,13 +917,13 @@
return static_cast<T>(static_cast<WT>(vs1) * static_cast<WT>(vs2));
}));
}
-template void KelvinVMul<int8_t>(bool, bool, Instruction *);
-template void KelvinVMul<int16_t>(bool, bool, Instruction *);
-template void KelvinVMul<int32_t>(bool, bool, Instruction *);
+template void KelvinVMul<int8_t>(bool, bool, Instruction*);
+template void KelvinVMul<int16_t>(bool, bool, Instruction*);
+template void KelvinVMul<int32_t>(bool, bool, Instruction*);
// Multiplication of vector elements with saturation.
template <typename T>
-void KelvinVMuls(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVMuls(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine, std::function<T(T, T)>([](T vs1, T vs2) -> T {
using WT = typename mpact::sim::generic::WideType<T>::type;
@@ -940,25 +940,25 @@
return result;
}));
}
-template void KelvinVMuls<int8_t>(bool, bool, Instruction *);
-template void KelvinVMuls<int16_t>(bool, bool, Instruction *);
-template void KelvinVMuls<int32_t>(bool, bool, Instruction *);
-template void KelvinVMuls<uint8_t>(bool, bool, Instruction *);
-template void KelvinVMuls<uint16_t>(bool, bool, Instruction *);
-template void KelvinVMuls<uint32_t>(bool, bool, Instruction *);
+template void KelvinVMuls<int8_t>(bool, bool, Instruction*);
+template void KelvinVMuls<int16_t>(bool, bool, Instruction*);
+template void KelvinVMuls<int32_t>(bool, bool, Instruction*);
+template void KelvinVMuls<uint8_t>(bool, bool, Instruction*);
+template void KelvinVMuls<uint16_t>(bool, bool, Instruction*);
+template void KelvinVMuls<uint32_t>(bool, bool, Instruction*);
// Multiplication of vector elements with widening.
template <typename Td, typename Ts>
-void KelvinVMulw(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVMulw(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<Td(Ts, Ts)>([](Ts vs1, Ts vs2) -> Td {
return static_cast<Td>(vs1) * static_cast<Td>(vs2);
}));
}
-template void KelvinVMulw<int16_t, int8_t>(bool, bool, Instruction *);
-template void KelvinVMulw<int32_t, int16_t>(bool, bool, Instruction *);
-template void KelvinVMulw<uint16_t, uint8_t>(bool, bool, Instruction *);
-template void KelvinVMulw<uint32_t, uint16_t>(bool, bool, Instruction *);
+template void KelvinVMulw<int16_t, int8_t>(bool, bool, Instruction*);
+template void KelvinVMulw<int32_t, int16_t>(bool, bool, Instruction*);
+template void KelvinVMulw<uint16_t, uint8_t>(bool, bool, Instruction*);
+template void KelvinVMulw<uint32_t, uint16_t>(bool, bool, Instruction*);
// Multiplication of vector elements with widening and optional rounding.
// Returns high half.
@@ -973,17 +973,17 @@
}
template <typename T>
-void KelvinVMulh(bool scalar, bool strip_mine, bool round, Instruction *inst) {
+void KelvinVMulh(bool scalar, bool strip_mine, bool round, Instruction* inst) {
KelvinBinaryVectorOp(
inst, scalar, strip_mine,
std::function<T(T, T)>(absl::bind_front(&KelvinVMulhHelper<T>, round)));
}
-template void KelvinVMulh<int8_t>(bool, bool, bool, Instruction *);
-template void KelvinVMulh<int16_t>(bool, bool, bool, Instruction *);
-template void KelvinVMulh<int32_t>(bool, bool, bool, Instruction *);
-template void KelvinVMulh<uint8_t>(bool, bool, bool, Instruction *);
-template void KelvinVMulh<uint16_t>(bool, bool, bool, Instruction *);
-template void KelvinVMulh<uint32_t>(bool, bool, bool, Instruction *);
+template void KelvinVMulh<int8_t>(bool, bool, bool, Instruction*);
+template void KelvinVMulh<int16_t>(bool, bool, bool, Instruction*);
+template void KelvinVMulh<int32_t>(bool, bool, bool, Instruction*);
+template void KelvinVMulh<uint8_t>(bool, bool, bool, Instruction*);
+template void KelvinVMulh<uint16_t>(bool, bool, bool, Instruction*);
+template void KelvinVMulh<uint32_t>(bool, bool, bool, Instruction*);
// Saturating signed doubling multiply returning high half with optional
// rounding.
@@ -1008,18 +1008,18 @@
}
template <typename T>
void KelvinVDmulh(bool scalar, bool strip_mine, bool round, bool round_neg,
- Instruction *inst) {
+ Instruction* inst) {
KelvinBinaryVectorOp(inst, scalar, strip_mine,
std::function<T(T, T)>(absl::bind_front(
&KelvinVDmulhHelper<T>, round, round_neg)));
}
-template void KelvinVDmulh<int8_t>(bool, bool, bool, bool, Instruction *);
-template void KelvinVDmulh<int16_t>(bool, bool, bool, bool, Instruction *);
-template void KelvinVDmulh<int32_t>(bool, bool, bool, bool, Instruction *);
+template void KelvinVDmulh<int8_t>(bool, bool, bool, bool, Instruction*);
+template void KelvinVDmulh<int16_t>(bool, bool, bool, bool, Instruction*);
+template void KelvinVDmulh<int32_t>(bool, bool, bool, bool, Instruction*);
// Multiply accumulate.
template <typename T>
-void KelvinVMacc(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVMacc(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp<false /* halftype */, false /* widen_dst */, T, T, T, T>(
inst, scalar, strip_mine,
std::function<T(T, T, T)>([](T vd, T vs1, T vs2) -> T {
@@ -1028,13 +1028,13 @@
static_cast<WT>(vs1) * static_cast<WT>(vs2);
}));
}
-template void KelvinVMacc<int8_t>(bool, bool, Instruction *);
-template void KelvinVMacc<int16_t>(bool, bool, Instruction *);
-template void KelvinVMacc<int32_t>(bool, bool, Instruction *);
+template void KelvinVMacc<int8_t>(bool, bool, Instruction*);
+template void KelvinVMacc<int16_t>(bool, bool, Instruction*);
+template void KelvinVMacc<int32_t>(bool, bool, Instruction*);
// Multiply add.
template <typename T>
-void KelvinVMadd(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVMadd(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp<false /* halftype */, false /* widen_dst */, T, T, T, T>(
inst, scalar, strip_mine,
std::function<T(T, T, T)>([](T vd, T vs1, T vs2) -> T {
@@ -1043,17 +1043,17 @@
static_cast<WT>(vd) * static_cast<WT>(vs2);
}));
}
-template void KelvinVMadd<int8_t>(bool, bool, Instruction *);
-template void KelvinVMadd<int16_t>(bool, bool, Instruction *);
-template void KelvinVMadd<int32_t>(bool, bool, Instruction *);
+template void KelvinVMadd<int8_t>(bool, bool, Instruction*);
+template void KelvinVMadd<int16_t>(bool, bool, Instruction*);
+template void KelvinVMadd<int32_t>(bool, bool, Instruction*);
// Computes slide index for next register and takes result from either vs1 or
// vs2.
template <typename T>
-T VSlidenOpGetArg1(bool horizontal, int index, const Instruction *inst,
+T VSlidenOpGetArg1(bool horizontal, int index, const Instruction* inst,
bool scalar, int num_ops, int op_index,
int dst_element_index, int dst_reg_index) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
auto elts_per_register = vector_size_in_bytes / sizeof(T);
@@ -1097,37 +1097,37 @@
// Slide next register vertically by index.
template <typename T>
-void KelvinVSlidevn(int index, bool strip_mine, Instruction *inst) {
+void KelvinVSlidevn(int index, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(
inst, false /* scalar */, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1; }),
SourceArgGetter<T, T, T, T>(absl::bind_front(
VSlidenOpGetArg1<T>, false /* horizontal */, index)));
}
-template void KelvinVSlidevn<int8_t>(int, bool, Instruction *);
-template void KelvinVSlidevn<int16_t>(int, bool, Instruction *);
-template void KelvinVSlidevn<int32_t>(int, bool, Instruction *);
+template void KelvinVSlidevn<int8_t>(int, bool, Instruction*);
+template void KelvinVSlidevn<int16_t>(int, bool, Instruction*);
+template void KelvinVSlidevn<int32_t>(int, bool, Instruction*);
// Slide next register horizontally by index.
template <typename T>
-void KelvinVSlidehn(int index, Instruction *inst) {
+void KelvinVSlidehn(int index, Instruction* inst) {
KelvinBinaryVectorOp(
inst, false /* scalar */, true /* strip_mine */,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1; }),
SourceArgGetter<T, T, T, T>(
absl::bind_front(VSlidenOpGetArg1<T>, true /* horizontal */, index)));
}
-template void KelvinVSlidehn<int8_t>(int, Instruction *);
-template void KelvinVSlidehn<int16_t>(int, Instruction *);
-template void KelvinVSlidehn<int32_t>(int, Instruction *);
+template void KelvinVSlidehn<int8_t>(int, Instruction*);
+template void KelvinVSlidehn<int16_t>(int, Instruction*);
+template void KelvinVSlidehn<int32_t>(int, Instruction*);
// Computes slide index for previous register and takes result from either vs1
// or vs2.
template <typename T>
-T VSlidepOpGetArg1(bool horizontal, int index, const Instruction *inst,
+T VSlidepOpGetArg1(bool horizontal, int index, const Instruction* inst,
bool scalar, int num_ops, int op_index,
int dst_element_index, int dst_reg_index) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
auto elts_per_register = vector_size_in_bytes / sizeof(T);
@@ -1171,50 +1171,50 @@
// Slide previous register vertically by index.
template <typename T>
-void KelvinVSlidevp(int index, bool strip_mine, Instruction *inst) {
+void KelvinVSlidevp(int index, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp(
inst, false /* scalar */, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1; }),
SourceArgGetter<T, T, T, T>(absl::bind_front(
VSlidepOpGetArg1<T>, false /* horizontal */, index)));
}
-template void KelvinVSlidevp<int8_t>(int, bool, Instruction *);
-template void KelvinVSlidevp<int16_t>(int, bool, Instruction *);
-template void KelvinVSlidevp<int32_t>(int, bool, Instruction *);
+template void KelvinVSlidevp<int8_t>(int, bool, Instruction*);
+template void KelvinVSlidevp<int16_t>(int, bool, Instruction*);
+template void KelvinVSlidevp<int32_t>(int, bool, Instruction*);
// Slide previous register horizontally by index.
template <typename T>
-void KelvinVSlidehp(int index, Instruction *inst) {
+void KelvinVSlidehp(int index, Instruction* inst) {
KelvinBinaryVectorOp(
inst, false /* scalar */, true /* strip_mine */,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1; }),
SourceArgGetter<T, T, T, T>(
absl::bind_front(VSlidepOpGetArg1<T>, true /* horizontal */, index)));
}
-template void KelvinVSlidehp<int8_t>(int, Instruction *);
-template void KelvinVSlidehp<int16_t>(int, Instruction *);
-template void KelvinVSlidehp<int32_t>(int, Instruction *);
+template void KelvinVSlidehp<int8_t>(int, Instruction*);
+template void KelvinVSlidehp<int16_t>(int, Instruction*);
+template void KelvinVSlidehp<int32_t>(int, Instruction*);
template <typename T>
-void KelvinVSel(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVSel(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVSel(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVSel(bool scalar, bool strip_mine, Instruction* inst) {
// Select lanes from two operands with vector selection boolean.
KelvinBinaryVectorOp<false /* halftype */, false /* widen_dst */, T, T, T, T>(
inst, scalar, strip_mine,
std::function<T(T, T, T)>(
[](T vd, T vs1, T vs2) -> T { return vs1 & 1 ? vd : vs2; }));
}
-template void KelvinVSel<int8_t>(bool, bool, Instruction *);
-template void KelvinVSel<int16_t>(bool, bool, Instruction *);
-template void KelvinVSel<int32_t>(bool, bool, Instruction *);
+template void KelvinVSel<int8_t>(bool, bool, Instruction*);
+template void KelvinVSel<int16_t>(bool, bool, Instruction*);
+template void KelvinVSel<int32_t>(bool, bool, Instruction*);
// Returns even elements of concatenated registers.
template <typename T>
-T VEvnOpGetArg1(const Instruction *inst, bool scalar, int num_ops, int op_index,
+T VEvnOpGetArg1(const Instruction* inst, bool scalar, int num_ops, int op_index,
int dst_element_index, int dst_reg_index) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
const int elts_per_register = vector_size_in_bytes / sizeof(T);
@@ -1231,22 +1231,22 @@
}
template <typename T>
-void KelvinVEvn(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVEvn(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp<false /* halftype */, false /* widen_dst */, T, T, T>(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1; }),
SourceArgGetter<T, T, T, T>(VEvnOpGetArg1<T>),
SourceArgGetter<T, T, T, T>(VEvnOpGetArg1<T>));
}
-template void KelvinVEvn<int8_t>(bool, bool, Instruction *);
-template void KelvinVEvn<int16_t>(bool, bool, Instruction *);
-template void KelvinVEvn<int32_t>(bool, bool, Instruction *);
+template void KelvinVEvn<int8_t>(bool, bool, Instruction*);
+template void KelvinVEvn<int16_t>(bool, bool, Instruction*);
+template void KelvinVEvn<int32_t>(bool, bool, Instruction*);
// Returns odd elements of concatenated registers.
template <typename T>
-T VOddOpGetArg1(const Instruction *inst, bool scalar, int num_ops, int op_index,
+T VOddOpGetArg1(const Instruction* inst, bool scalar, int num_ops, int op_index,
int dst_element_index, int dst_reg_index) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
const int elts_per_register = vector_size_in_bytes / sizeof(T);
@@ -1263,20 +1263,20 @@
}
template <typename T>
-void KelvinVOdd(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVOdd(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp<false /* halftype */, false /* widen_dst */, T, T, T>(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1; }),
SourceArgGetter<T, T, T, T>(VOddOpGetArg1<T>),
SourceArgGetter<T, T, T, T>(VOddOpGetArg1<T>));
}
-template void KelvinVOdd<int8_t>(bool, bool, Instruction *);
-template void KelvinVOdd<int16_t>(bool, bool, Instruction *);
-template void KelvinVOdd<int32_t>(bool, bool, Instruction *);
+template void KelvinVOdd<int8_t>(bool, bool, Instruction*);
+template void KelvinVOdd<int16_t>(bool, bool, Instruction*);
+template void KelvinVOdd<int32_t>(bool, bool, Instruction*);
// Returns evn/odd elements of concatenated registers based on dst_reg_index.
template <typename T>
-T VEvnoddOpGetArg1(const Instruction *inst, bool scalar, int num_ops,
+T VEvnoddOpGetArg1(const Instruction* inst, bool scalar, int num_ops,
int op_index, int dst_element_index, int dst_reg_index) {
return dst_reg_index == 0
? VEvnOpGetArg1<T>(inst, scalar, num_ops, op_index,
@@ -1286,23 +1286,23 @@
}
template <typename T>
-void KelvinVEvnodd(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVEvnodd(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp<false /* halftype */, true /* widen_dst */, T, T, T>(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1; }),
SourceArgGetter<T, T, T, T>(VEvnoddOpGetArg1<T>),
SourceArgGetter<T, T, T, T>(VEvnoddOpGetArg1<T>));
}
-template void KelvinVEvnodd<int8_t>(bool, bool, Instruction *);
-template void KelvinVEvnodd<int16_t>(bool, bool, Instruction *);
-template void KelvinVEvnodd<int32_t>(bool, bool, Instruction *);
+template void KelvinVEvnodd<int8_t>(bool, bool, Instruction*);
+template void KelvinVEvnodd<int16_t>(bool, bool, Instruction*);
+template void KelvinVEvnodd<int32_t>(bool, bool, Instruction*);
// Interleave even/odd lanes of two operands.
// Returns even elements of concatenated registers.
template <typename T>
-T VZipOpGetArg1(const Instruction *inst, bool scalar, int num_ops, int op_index,
+T VZipOpGetArg1(const Instruction* inst, bool scalar, int num_ops, int op_index,
int dst_element_index, int dst_reg_index) {
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
const int elts_per_register = vector_size_in_bytes / sizeof(T);
const int half_elts_per_register = elts_per_register / 2;
@@ -1321,14 +1321,14 @@
}
template <typename T>
-void KelvinVZip(bool scalar, bool strip_mine, Instruction *inst) {
+void KelvinVZip(bool scalar, bool strip_mine, Instruction* inst) {
KelvinBinaryVectorOp<false /* halftype */, true /* widen_dst */, T, T, T>(
inst, scalar, strip_mine,
std::function<T(T, T)>([](T vs1, T vs2) -> T { return vs1; }),
SourceArgGetter<T, T, T, T>(VZipOpGetArg1<T>),
SourceArgGetter<T, T, T, T>(VZipOpGetArg1<T>));
}
-template void KelvinVZip<int8_t>(bool, bool, Instruction *);
-template void KelvinVZip<int16_t>(bool, bool, Instruction *);
-template void KelvinVZip<int32_t>(bool, bool, Instruction *);
+template void KelvinVZip<int8_t>(bool, bool, Instruction*);
+template void KelvinVZip<int16_t>(bool, bool, Instruction*);
+template void KelvinVZip<int32_t>(bool, bool, Instruction*);
} // namespace kelvin::sim
diff --git a/sim/kelvin_vector_instructions.h b/sim/kelvin_vector_instructions.h
index 30a6a1e..a8d18d7 100644
--- a/sim/kelvin_vector_instructions.h
+++ b/sim/kelvin_vector_instructions.h
@@ -25,173 +25,173 @@
// Vector 2-arg .vv, .vx arithmetic operations.
template <typename T>
-void KelvinVAdd(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVAdd(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVSub(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVSub(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVRSub(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVRSub(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVEq(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVEq(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVNe(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVNe(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVLt(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVLt(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVLe(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVLe(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVGt(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVGt(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVGe(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVGe(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVAbsd(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVAbsd(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVMax(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVMax(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVMin(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVMin(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVAdd3(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVAdd3(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVAdds(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVAdds(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVAddsu(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVAddsu(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVSubs(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVSubs(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVSubsu(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVSubsu(bool scalar, bool strip_mine, Instruction* inst);
template <typename Td, typename Ts>
-void KelvinVAddw(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVAddw(bool scalar, bool strip_mine, Instruction* inst);
template <typename Td, typename Ts>
-void KelvinVSubw(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVSubw(bool scalar, bool strip_mine, Instruction* inst);
template <typename Td, typename Ts2>
-void KelvinVAcc(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVAcc(bool scalar, bool strip_mine, Instruction* inst);
template <typename Td, typename Ts>
-void KelvinVPadd(bool strip_mine, Instruction *inst);
+void KelvinVPadd(bool strip_mine, Instruction* inst);
template <typename Td, typename Ts>
-void KelvinVPsub(bool strip_mine, Instruction *inst);
+void KelvinVPsub(bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVHadd(bool scalar, bool strip_mine, bool round, Instruction *inst);
+void KelvinVHadd(bool scalar, bool strip_mine, bool round, Instruction* inst);
template <typename T>
-void KelvinVHsub(bool scalar, bool strip_mine, bool round, Instruction *inst);
+void KelvinVHsub(bool scalar, bool strip_mine, bool round, Instruction* inst);
template <typename T>
-void KelvinVAnd(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVAnd(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVOr(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVOr(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVXor(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVXor(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVRev(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVRev(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVRor(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVRor(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVMvp(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVMvp(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVSll(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVSll(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVSra(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVSra(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVSrl(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVSrl(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVShift(bool round, bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVShift(bool round, bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVNot(bool strip_mine, Instruction *inst);
+void KelvinVNot(bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVClb(bool strip_mine, Instruction *inst);
+void KelvinVClb(bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVClz(bool strip_mine, Instruction *inst);
+void KelvinVClz(bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVCpop(bool strip_mine, Instruction *inst);
+void KelvinVCpop(bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVMv(bool strip_mine, Instruction *inst);
+void KelvinVMv(bool strip_mine, Instruction* inst);
template <typename Td, typename Ts>
-void KelvinVSrans(bool round, bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVSrans(bool round, bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVMul(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVMul(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVMuls(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVMuls(bool scalar, bool strip_mine, Instruction* inst);
template <typename Td, typename Ts>
-void KelvinVMulw(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVMulw(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVMulh(bool scalar, bool strip_mine, bool round, Instruction *inst);
+void KelvinVMulh(bool scalar, bool strip_mine, bool round, Instruction* inst);
template <typename T>
void KelvinVDmulh(bool scalar, bool strip_mine, bool round, bool round_neg,
- Instruction *inst);
+ Instruction* inst);
template <typename T>
-void KelvinVMacc(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVMacc(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVMadd(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVMadd(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVSlidevn(int index, bool strip_mine, Instruction *inst);
+void KelvinVSlidevn(int index, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVSlidehn(int index, Instruction *inst);
+void KelvinVSlidehn(int index, Instruction* inst);
template <typename T>
-void KelvinVSlidevp(int index, bool strip_mine, Instruction *inst);
+void KelvinVSlidevp(int index, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVSlidehp(int index, Instruction *inst);
+void KelvinVSlidehp(int index, Instruction* inst);
template <typename T>
-void KelvinVSel(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVSel(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVEvn(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVEvn(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVOdd(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVOdd(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVEvnodd(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVEvnodd(bool scalar, bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVZip(bool scalar, bool strip_mine, Instruction *inst);
+void KelvinVZip(bool scalar, bool strip_mine, Instruction* inst);
} // namespace kelvin::sim
#endif // SIM_KELVIN_VECTOR_INSTRUCTIONS_H_
diff --git a/sim/kelvin_vector_memory_instructions.cc b/sim/kelvin_vector_memory_instructions.cc
index c63b943..a13a259 100644
--- a/sim/kelvin_vector_memory_instructions.cc
+++ b/sim/kelvin_vector_memory_instructions.cc
@@ -37,8 +37,8 @@
// register post-increment.
template <typename T>
void KelvinVLd(bool has_length, bool has_stride, bool strip_mine,
- Instruction *inst) {
- auto state = static_cast<KelvinState *>(inst->state());
+ Instruction* inst) {
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
const uint32_t elts_per_register = vector_size_in_bytes / sizeof(T);
@@ -65,11 +65,11 @@
stride_elts = stride_arg;
}
- auto *db_factory = inst->state()->db_factory();
- auto *address_db = db_factory->Allocate<uint64_t>(elts_to_load);
- auto *mask_db = db_factory->Allocate<bool>(elts_to_load);
+ auto* db_factory = inst->state()->db_factory();
+ auto* address_db = db_factory->Allocate<uint64_t>(elts_to_load);
+ auto* mask_db = db_factory->Allocate<bool>(elts_to_load);
// Allocate the value data buffer that the loaded data is returned in.
- auto *value_db = db_factory->Allocate<T>(elts_to_load);
+ auto* value_db = db_factory->Allocate<T>(elts_to_load);
auto addresses = address_db->Get<uint64_t>();
auto masks = mask_db->Get<bool>();
@@ -84,7 +84,7 @@
elts_left -= count;
base += stride_elts * sizeof(T);
}
- auto *context = new LoadContext(value_db);
+ auto* context = new LoadContext(value_db);
value_db->set_latency(0);
state->LoadMemory(inst, address_db, mask_db, sizeof(T), value_db,
inst->child(), context);
@@ -96,9 +96,8 @@
const bool post_increment = inst->DestinationsSize() == 1;
if (post_increment) {
- auto *reg =
- static_cast<
- mpact::sim::generic::RegisterDestinationOperand<uint32_t> *>(
+ auto* reg =
+ static_cast<mpact::sim::generic::RegisterDestinationOperand<uint32_t>*>(
inst->Destination(0))
->GetRegister();
@@ -120,24 +119,24 @@
reg->data_buffer()->template Set<uint32_t>(0, addr);
}
}
-template void KelvinVLd<int8_t>(bool, bool, bool, Instruction *);
-template void KelvinVLd<int16_t>(bool, bool, bool, Instruction *);
-template void KelvinVLd<int32_t>(bool, bool, bool, Instruction *);
+template void KelvinVLd<int8_t>(bool, bool, bool, Instruction*);
+template void KelvinVLd<int16_t>(bool, bool, bool, Instruction*);
+template void KelvinVLd<int32_t>(bool, bool, bool, Instruction*);
// VLd child instruction which writes data loaded to destination register(s).
template <typename T>
-void KelvinVLdRegWrite(bool strip_mine, Instruction *inst) {
- auto state = static_cast<KelvinState *>(inst->state());
+void KelvinVLdRegWrite(bool strip_mine, Instruction* inst) {
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
const uint32_t elts_per_register = vector_size_in_bytes / sizeof(T);
const auto num_ops = strip_mine ? 4 : 1;
- auto *context = static_cast<LoadContext *>(inst->context());
+ auto* context = static_cast<LoadContext*>(inst->context());
auto values = context->value_db->template Get<T>();
- auto vd = static_cast<RV32VectorDestinationOperand *>(inst->Destination(0));
+ auto vd = static_cast<RV32VectorDestinationOperand*>(inst->Destination(0));
for (int op_index = 0; op_index < num_ops; ++op_index) {
- DataBuffer *dest_db = vd->AllocateDataBuffer(op_index);
+ DataBuffer* dest_db = vd->AllocateDataBuffer(op_index);
absl::Span<T> dest_span = dest_db->template Get<T>();
for (int dst_element_index = 0; dst_element_index < elts_per_register;
@@ -152,9 +151,9 @@
dest_db->Submit();
}
}
-template void KelvinVLdRegWrite<int8_t>(bool, Instruction *);
-template void KelvinVLdRegWrite<int16_t>(bool, Instruction *);
-template void KelvinVLdRegWrite<int32_t>(bool, Instruction *);
+template void KelvinVLdRegWrite<int8_t>(bool, Instruction*);
+template void KelvinVLdRegWrite<int16_t>(bool, Instruction*);
+template void KelvinVLdRegWrite<int32_t>(bool, Instruction*);
// Vector store instruction with the optional data length, stride and address
// register post-increment.
@@ -162,8 +161,8 @@
// register with xs2 stride.
template <typename T>
void VectorStoreHelper(bool has_length, bool has_stride, bool strip_mine,
- bool is_quad, Instruction *inst) {
- auto state = static_cast<KelvinState *>(inst->state());
+ bool is_quad, Instruction* inst) {
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
const uint32_t elts_per_register = vector_size_in_bytes / sizeof(T);
@@ -173,7 +172,7 @@
kKelvinMaxMemoryAddress) { // exclude semihost tests
mem_addr &= kMemMask;
}
- auto vs = static_cast<RV32VectorSourceOperand *>(inst->Source(0));
+ auto vs = static_cast<RV32VectorSourceOperand*>(inst->Source(0));
auto base_addr = mem_addr;
@@ -190,9 +189,9 @@
}
// Allocate the store memory
- auto *value_db = state->db_factory()->Allocate(elts_to_store * sizeof(T));
- auto *address_db = state->db_factory()->Allocate<uint64_t>(elts_to_store);
- auto *mask_db = state->db_factory()->Allocate<bool>(elts_to_store);
+ auto* value_db = state->db_factory()->Allocate(elts_to_store * sizeof(T));
+ auto* address_db = state->db_factory()->Allocate<uint64_t>(elts_to_store);
+ auto* mask_db = state->db_factory()->Allocate<bool>(elts_to_store);
auto addresses = address_db->Get<uint64_t>();
auto value = value_db->Get<T>();
auto mask = mask_db->Get<bool>();
@@ -228,9 +227,8 @@
const bool post_increment = inst->DestinationsSize() == 1;
if (post_increment) {
- auto *reg =
- static_cast<
- mpact::sim::generic::RegisterDestinationOperand<uint32_t> *>(
+ auto* reg =
+ static_cast<mpact::sim::generic::RegisterDestinationOperand<uint32_t>*>(
inst->Destination(0))
->GetRegister();
if (elts_to_store > 0) {
@@ -254,30 +252,30 @@
template <typename T>
void KelvinVSt(bool has_length, bool has_stride, bool strip_mine,
- Instruction *inst) {
+ Instruction* inst) {
VectorStoreHelper<T>(has_length, has_stride, strip_mine, /*is_quad=*/false,
inst);
}
-template void KelvinVSt<int8_t>(bool, bool, bool, Instruction *);
-template void KelvinVSt<int16_t>(bool, bool, bool, Instruction *);
-template void KelvinVSt<int32_t>(bool, bool, bool, Instruction *);
+template void KelvinVSt<int8_t>(bool, bool, bool, Instruction*);
+template void KelvinVSt<int16_t>(bool, bool, bool, Instruction*);
+template void KelvinVSt<int32_t>(bool, bool, bool, Instruction*);
// Duplicate a scalar value into a vector register.
template <typename T>
-void KelvinVDup(bool strip_mine, Instruction *inst) {
- auto *state = static_cast<KelvinState *>(inst->state());
+void KelvinVDup(bool strip_mine, Instruction* inst) {
+ auto* state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
const uint32_t elts_per_register = vector_size_in_bytes / sizeof(T);
const auto num_ops = strip_mine ? 4 : 1;
// Gets destination register and scalar value.
- auto *vd = static_cast<RV32VectorDestinationOperand *>(inst->Destination(0));
+ auto* vd = static_cast<RV32VectorDestinationOperand*>(inst->Destination(0));
auto value = GetInstructionSource<T>(inst, 0);
// Fill destination buffer and write to register.
for (int op_index = 0; op_index < num_ops; ++op_index) {
- DataBuffer *dest_db = vd->AllocateDataBuffer(op_index);
+ DataBuffer* dest_db = vd->AllocateDataBuffer(op_index);
absl::Span<T> dest_span = dest_db->template Get<T>();
for (int dst_element_index = 0; dst_element_index < elts_per_register;
++dst_element_index) {
@@ -287,30 +285,30 @@
}
}
-template void KelvinVDup<int8_t>(bool, Instruction *);
-template void KelvinVDup<int16_t>(bool, Instruction *);
-template void KelvinVDup<int32_t>(bool, Instruction *);
+template void KelvinVDup<int8_t>(bool, Instruction*);
+template void KelvinVDup<int16_t>(bool, Instruction*);
+template void KelvinVDup<int32_t>(bool, Instruction*);
template <typename T>
-void KelvinVStQ(bool strip_mine, Instruction *inst) {
+void KelvinVStQ(bool strip_mine, Instruction* inst) {
VectorStoreHelper<T>(/*has_length=*/false, /*has_stride=*/true, strip_mine,
/*is_quad=*/true, inst);
}
-template void KelvinVStQ<int8_t>(bool, Instruction *);
-template void KelvinVStQ<int16_t>(bool, Instruction *);
-template void KelvinVStQ<int32_t>(bool, Instruction *);
+template void KelvinVStQ<int8_t>(bool, Instruction*);
+template void KelvinVStQ<int16_t>(bool, Instruction*);
+template void KelvinVStQ<int32_t>(bool, Instruction*);
// Return the supported vl length. It starts with the maximum value based on
// vector_length and then is capped to the minimum by the additional inputs.
template <typename T>
void KelvinGetVl(bool strip_mine, bool is_rs1, bool is_rs2,
- const mpact::sim::generic::Instruction *inst) {
- auto *dest_reg =
- static_cast<mpact::sim::generic::RegisterDestinationOperand<uint32_t> *>(
+ const mpact::sim::generic::Instruction* inst) {
+ auto* dest_reg =
+ static_cast<mpact::sim::generic::RegisterDestinationOperand<uint32_t>*>(
inst->Destination(0))
->GetRegister();
- auto state = static_cast<KelvinState *>(inst->state());
+ auto state = static_cast<KelvinState*>(inst->state());
const int vector_size_in_bytes = state->vector_length() / 8;
uint32_t vlen = vector_size_in_bytes / sizeof(T);
if (strip_mine) {
@@ -327,20 +325,20 @@
}
dest_reg->data_buffer()->Set<uint32_t>(0, vlen);
}
-template void KelvinGetVl<int8_t>(bool, bool, bool, const Instruction *);
-template void KelvinGetVl<int16_t>(bool, bool, bool, const Instruction *);
-template void KelvinGetVl<int32_t>(bool, bool, bool, const Instruction *);
+template void KelvinGetVl<int8_t>(bool, bool, bool, const Instruction*);
+template void KelvinGetVl<int16_t>(bool, bool, bool, const Instruction*);
+template void KelvinGetVl<int32_t>(bool, bool, bool, const Instruction*);
// Copy convolution accumulation registers into general vector register. In HW,
// it is set to be v48..55.
-void KelvinVcGet(const mpact::sim::generic::Instruction *inst) {
- auto vd = static_cast<RV32VectorDestinationOperand *>(inst->Destination(0));
- auto *state = static_cast<KelvinState *>(inst->state());
+void KelvinVcGet(const mpact::sim::generic::Instruction* inst) {
+ auto vd = static_cast<RV32VectorDestinationOperand*>(inst->Destination(0));
+ auto* state = static_cast<KelvinState*>(inst->state());
const uint32_t kVecLenInWord = state->vector_length() / 32;
for (int op_index = 0; op_index < kVecLenInWord; ++op_index) {
- DataBuffer *dest_db = vd->AllocateDataBuffer(op_index);
+ DataBuffer* dest_db = vd->AllocateDataBuffer(op_index);
absl::Span<uint32_t> dest_span = dest_db->Get<uint32_t>();
- auto *acc_vec = state->acc_vec(op_index);
+ auto* acc_vec = state->acc_vec(op_index);
for (int i = 0; i < dest_span.size(); ++i) {
dest_span[i] = (*acc_vec)[i];
}
@@ -353,19 +351,19 @@
// accumulation register. In HW, vs has to be 16-register aligned, and vd has
// to be set to v48.
void KelvinAcSet(bool is_transpose,
- const mpact::sim::generic::Instruction *inst) {
- auto vs = static_cast<RV32VectorSourceOperand *>(inst->Source(0));
- auto *state = static_cast<KelvinState *>(inst->state());
+ const mpact::sim::generic::Instruction* inst) {
+ auto vs = static_cast<RV32VectorSourceOperand*>(inst->Source(0));
+ auto* state = static_cast<KelvinState*>(inst->state());
const uint32_t kVecLenInWord = state->vector_length() / 32;
for (int op_index = 0; op_index < kVecLenInWord; ++op_index) {
auto source_span =
vs->GetRegister(op_index)->data_buffer()->Get<uint32_t>();
for (int i = 0; i < source_span.size(); ++i) {
if (is_transpose) {
- auto *acc_vec = state->acc_vec(i);
+ auto* acc_vec = state->acc_vec(i);
(*acc_vec)[op_index] = source_span[i];
} else {
- auto *acc_vec = state->acc_vec(op_index);
+ auto* acc_vec = state->acc_vec(op_index);
(*acc_vec)[i] = source_span[i];
}
}
@@ -375,23 +373,23 @@
// Copy the content from the source `vs1` banks to the `vd` banks to prepare the
// depthwise convolution. Due to compiler encoding, this op is typeless and only
// assumes `vs1` and `vd` content in 8-bit type.
-void KelvinADwInit(const mpact::sim::generic::Instruction *inst) {
- auto *state = static_cast<KelvinState *>(inst->state());
+void KelvinADwInit(const mpact::sim::generic::Instruction* inst) {
+ auto* state = static_cast<KelvinState*>(inst->state());
// Only set a quarter of the to prepare for double-widening in depth-wise
// convolution.
const uint32_t init_n = state->vector_length() / (8 * 4);
constexpr int kInitSize = 4;
- auto vs = static_cast<RV32VectorSourceOperand *>(inst->Source(0));
- auto vd = static_cast<RV32VectorDestinationOperand *>(inst->Destination(0));
+ auto vs = static_cast<RV32VectorSourceOperand*>(inst->Source(0));
+ auto vd = static_cast<RV32VectorDestinationOperand*>(inst->Destination(0));
for (int op_index = 0; op_index < kInitSize; ++op_index) {
auto source_span = vs->GetRegister(op_index)->data_buffer()->Get<uint8_t>();
- uint8_t *dwacc_span =
- reinterpret_cast<uint8_t *>(state->dw_acc_vec(8 * op_index));
+ uint8_t* dwacc_span =
+ reinterpret_cast<uint8_t*>(state->dw_acc_vec(8 * op_index));
for (int i = 0; i < 32; i++) {
dwacc_span[i] = source_span[i];
}
- DataBuffer *dest_db = vd->AllocateDataBuffer(op_index);
+ DataBuffer* dest_db = vd->AllocateDataBuffer(op_index);
absl::Span<uint8_t> dest_span = dest_db->Get<uint8_t>();
for (int i = 0; i < init_n; ++i) {
dest_span[i] = source_span[i];
diff --git a/sim/kelvin_vector_memory_instructions.h b/sim/kelvin_vector_memory_instructions.h
index 6369f1a..25ed24e 100644
--- a/sim/kelvin_vector_memory_instructions.h
+++ b/sim/kelvin_vector_memory_instructions.h
@@ -25,31 +25,31 @@
template <typename T>
void KelvinVLd(bool has_length, bool has_stride, bool strip_mine,
- Instruction *inst);
+ Instruction* inst);
template <typename T>
-void KelvinVLdRegWrite(bool strip_mine, Instruction *inst);
+void KelvinVLdRegWrite(bool strip_mine, Instruction* inst);
template <typename T>
void KelvinVSt(bool has_length, bool has_stride, bool strip_mine,
- Instruction *inst);
+ Instruction* inst);
template <typename T>
-void KelvinVDup(bool strip_mine, Instruction *inst);
+void KelvinVDup(bool strip_mine, Instruction* inst);
template <typename T>
-void KelvinVStQ(bool strip_mine, Instruction *inst);
+void KelvinVStQ(bool strip_mine, Instruction* inst);
template <typename T>
void KelvinGetVl(bool strip_mine, bool is_rs1, bool is_rs2,
- const mpact::sim::generic::Instruction *inst);
+ const mpact::sim::generic::Instruction* inst);
-void KelvinVcGet(const mpact::sim::generic::Instruction *inst);
+void KelvinVcGet(const mpact::sim::generic::Instruction* inst);
void KelvinAcSet(bool is_transpose,
- const mpact::sim::generic::Instruction *inst);
+ const mpact::sim::generic::Instruction* inst);
-void KelvinADwInit(const mpact::sim::generic::Instruction *inst);
+void KelvinADwInit(const mpact::sim::generic::Instruction* inst);
} // namespace kelvin::sim
diff --git a/sim/proto/BUILD b/sim/proto/BUILD
index 690d9c1..ad1de67 100644
--- a/sim/proto/BUILD
+++ b/sim/proto/BUILD
@@ -24,6 +24,7 @@
srcs = [
"kelvin_trace.proto",
],
+
)
cc_proto_library(
diff --git a/sim/proto/kelvin_trace.proto b/sim/proto/kelvin_trace.proto
index 02e0c88..dc54bc4 100644
--- a/sim/proto/kelvin_trace.proto
+++ b/sim/proto/kelvin_trace.proto
@@ -16,6 +16,9 @@
package kelvin.sim.proto;
+
+
+
option features.utf8_validation = NONE;
option java_multiple_files = true;
diff --git a/sim/renode/BUILD b/sim/renode/BUILD
index 660e6f7..5eda89f 100644
--- a/sim/renode/BUILD
+++ b/sim/renode/BUILD
@@ -14,6 +14,8 @@
# Build Renode interface for kelvin
+
+
package(
default_visibility = ["//visibility:public"],
)
@@ -32,7 +34,6 @@
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/log",
"@com_google_absl//absl/strings",
- "@com_google_mpact-sim//mpact/sim/generic:core_debug_interface",
"@com_google_mpact-sim//mpact/sim/generic:type_helpers",
"@com_google_mpact-sim//mpact/sim/util/program_loader:elf_loader",
],
diff --git a/sim/renode/kelvin_renode.cc b/sim/renode/kelvin_renode.cc
index ffb5a8f..89c1c87 100644
--- a/sim/renode/kelvin_renode.cc
+++ b/sim/renode/kelvin_renode.cc
@@ -30,15 +30,15 @@
#include "mpact/sim/generic/data_buffer.h"
#include "mpact/sim/generic/instruction.h"
-kelvin::sim::renode::RenodeDebugInterface *CreateKelvinSim(std::string name) {
- auto *top = new kelvin::sim::KelvinRenode(name);
+kelvin::sim::renode::RenodeDebugInterface* CreateKelvinSim(std::string name) {
+ auto* top = new kelvin::sim::KelvinRenode(name);
return top;
}
-kelvin::sim::renode::RenodeDebugInterface *CreateKelvinSim(
+kelvin::sim::renode::RenodeDebugInterface* CreateKelvinSim(
std::string name, uint64_t memory_block_size_bytes,
- uint64_t memory_size_bytes, uint8_t **block_ptr_list) {
- auto *top = new kelvin::sim::KelvinRenode(name, memory_block_size_bytes,
+ uint64_t memory_size_bytes, uint8_t** block_ptr_list) {
+ auto* top = new kelvin::sim::KelvinRenode(name, memory_block_size_bytes,
memory_size_bytes, block_ptr_list);
return top;
}
@@ -57,7 +57,7 @@
KelvinRenode::KelvinRenode(std::string name, uint64_t memory_block_size_bytes,
uint64_t memory_size_bytes,
- uint8_t **block_ptr_list) {
+ uint8_t** block_ptr_list) {
kelvin_top_ = new KelvinTop(name, memory_block_size_bytes, memory_size_bytes,
block_ptr_list);
}
@@ -83,28 +83,28 @@
return kelvin_top_->GetLastHaltReason();
}
-absl::StatusOr<uint64_t> KelvinRenode::ReadRegister(const std::string &name) {
+absl::StatusOr<uint64_t> KelvinRenode::ReadRegister(const std::string& name) {
return kelvin_top_->ReadRegister(name);
}
-absl::Status KelvinRenode::WriteRegister(const std::string &name,
+absl::Status KelvinRenode::WriteRegister(const std::string& name,
uint64_t value) {
return kelvin_top_->WriteRegister(name, value);
}
-absl::StatusOr<size_t> KelvinRenode::ReadMemory(uint64_t address, void *buf,
+absl::StatusOr<size_t> KelvinRenode::ReadMemory(uint64_t address, void* buf,
size_t length) {
return kelvin_top_->ReadMemory(address, buf, length);
}
absl::StatusOr<size_t> KelvinRenode::WriteMemory(uint64_t address,
- const void *buf,
+ const void* buf,
size_t length) {
return kelvin_top_->WriteMemory(address, buf, length);
}
-absl::StatusOr<mpact::sim::generic::DataBuffer *>
-KelvinRenode::GetRegisterDataBuffer(const std::string &name) {
+absl::StatusOr<mpact::sim::generic::DataBuffer*>
+KelvinRenode::GetRegisterDataBuffer(const std::string& name) {
return kelvin_top_->GetRegisterDataBuffer(name);
}
@@ -124,7 +124,7 @@
return kelvin_top_->ClearAllSwBreakpoints();
}
-absl::StatusOr<mpact::sim::generic::Instruction *> KelvinRenode::GetInstruction(
+absl::StatusOr<mpact::sim::generic::Instruction*> KelvinRenode::GetInstruction(
uint64_t address) {
return kelvin_top_->GetInstruction(address);
}
@@ -133,7 +133,7 @@
return kelvin_top_->GetDisassembly(address);
}
-absl::Status KelvinRenode::LoadImage(const std::string &image_path,
+absl::Status KelvinRenode::LoadImage(const std::string& image_path,
uint64_t start_address) {
return kelvin_top_->LoadImage(image_path, start_address);
}
@@ -163,15 +163,15 @@
}
absl::Status KelvinRenode::GetRenodeRegisterInfo(int32_t index, int32_t max_len,
- char *name,
- RenodeCpuRegister &info) {
- auto const ®ister_info = KelvinRenodeRegisterInfo::GetRenodeRegisterInfo();
+ char* name,
+ RenodeCpuRegister& info) {
+ auto const& register_info = KelvinRenodeRegisterInfo::GetRenodeRegisterInfo();
if ((index < 0 || index >= register_info.size())) {
return absl::OutOfRangeError(
absl::StrCat("Register info index (", index, ") out of range"));
}
info = register_info[index];
- auto const ®_map = RiscVDebugInfo::Instance()->debug_register_map();
+ auto const& reg_map = RiscVDebugInfo::Instance()->debug_register_map();
auto ptr = reg_map.find(info.index);
if (ptr == reg_map.end()) {
name[0] = '\0';
diff --git a/sim/renode/kelvin_renode.h b/sim/renode/kelvin_renode.h
index 809651e..a672c39 100644
--- a/sim/renode/kelvin_renode.h
+++ b/sim/renode/kelvin_renode.h
@@ -33,12 +33,12 @@
// class defines a global namespace function that is used by the renode wrapper
// to create a top simulator instance.
-extern kelvin::sim::renode::RenodeDebugInterface *CreateKelvinSim(
+extern kelvin::sim::renode::RenodeDebugInterface* CreateKelvinSim(
std::string name);
-extern kelvin::sim::renode::RenodeDebugInterface *CreateKelvinSim(
+extern kelvin::sim::renode::RenodeDebugInterface* CreateKelvinSim(
std::string name, uint64_t memory_block_size_bytes,
- uint64_t memory_size_bytes, uint8_t **block_ptr_list);
+ uint64_t memory_size_bytes, uint8_t** block_ptr_list);
namespace kelvin::sim {
@@ -50,7 +50,7 @@
explicit KelvinRenode(std::string name);
explicit KelvinRenode(std::string name, uint64_t memory_block_size_bytes,
- uint64_t memory_size_bytes, uint8_t **block_ptr_list);
+ uint64_t memory_size_bytes, uint8_t** block_ptr_list);
~KelvinRenode() override;
@@ -72,18 +72,18 @@
// Returns the reason for the most recent halt.
absl::StatusOr<HaltReasonValueType> GetLastHaltReason() override;
// Read/write the named registers.
- absl::StatusOr<uint64_t> ReadRegister(const std::string &name) override;
- absl::Status WriteRegister(const std::string &name, uint64_t value) override;
+ absl::StatusOr<uint64_t> ReadRegister(const std::string& name) override;
+ absl::Status WriteRegister(const std::string& name, uint64_t value) override;
// Read/write the numeric id registers.
absl::StatusOr<uint64_t> ReadRegister(uint32_t reg_id) override;
absl::Status WriteRegister(uint32_t reg_id, uint64_t value) override;
- absl::StatusOr<mpact::sim::generic::DataBuffer *> GetRegisterDataBuffer(
- const std::string &name) override;
+ absl::StatusOr<mpact::sim::generic::DataBuffer*> GetRegisterDataBuffer(
+ const std::string& name) override;
// Read/write the buffers to memory.
- absl::StatusOr<size_t> ReadMemory(uint64_t address, void *buf,
+ absl::StatusOr<size_t> ReadMemory(uint64_t address, void* buf,
size_t length) override;
- absl::StatusOr<size_t> WriteMemory(uint64_t address, const void *buf,
+ absl::StatusOr<size_t> WriteMemory(uint64_t address, const void* buf,
size_t length) override;
bool HasBreakpoint(uint64_t address) override;
// Set/Clear software breakpoints at the given addresses.
@@ -91,20 +91,20 @@
absl::Status ClearSwBreakpoint(uint64_t address) override;
// Remove all software breakpoints.
absl::Status ClearAllSwBreakpoints() override;
- absl::StatusOr<mpact::sim::generic::Instruction *> GetInstruction(
+ absl::StatusOr<mpact::sim::generic::Instruction*> GetInstruction(
uint64_t address) override;
// Return the string representation for the instruction at the given address.
absl::StatusOr<std::string> GetDisassembly(uint64_t address) override;
// Return register information.
int32_t GetRenodeRegisterInfoSize() const override;
- absl::Status GetRenodeRegisterInfo(int32_t index, int32_t max_len, char *name,
- RenodeCpuRegister &info) override;
+ absl::Status GetRenodeRegisterInfo(int32_t index, int32_t max_len, char* name,
+ RenodeCpuRegister& info) override;
- absl::Status LoadImage(const std::string &image_path,
+ absl::Status LoadImage(const std::string& image_path,
uint64_t start_address) override;
private:
- KelvinTop *kelvin_top_ = nullptr;
+ KelvinTop* kelvin_top_ = nullptr;
};
} // namespace kelvin::sim
diff --git a/sim/renode/kelvin_renode_memory.cc b/sim/renode/kelvin_renode_memory.cc
index 2d5c9c8..57a4004 100644
--- a/sim/renode/kelvin_renode_memory.cc
+++ b/sim/renode/kelvin_renode_memory.cc
@@ -26,7 +26,7 @@
KelvinRenodeMemory::KelvinRenodeMemory(uint64_t block_size_bytes,
uint64_t memory_size_bytes,
- uint8_t **block_ptr_list,
+ uint8_t** block_ptr_list,
uint64_t base_address,
unsigned addressable_unit_size)
: addressable_unit_size_(addressable_unit_size),
@@ -49,13 +49,13 @@
return (address >= base_address_) && (high_address <= max_address_);
}
-void KelvinRenodeMemory::Load(uint64_t address, DataBuffer *db,
- Instruction *inst, ReferenceCount *context) {
+void KelvinRenodeMemory::Load(uint64_t address, DataBuffer* db,
+ Instruction* inst, ReferenceCount* context) {
int size_in_units = db->size<uint8_t>() / addressable_unit_size_;
uint64_t high = address + size_in_units;
ABSL_HARDENING_ASSERT(IsValidAddress(address, high));
ABSL_HARDENING_ASSERT(size_in_units > 0);
- uint8_t *byte_ptr = static_cast<uint8_t *>(db->raw_ptr());
+ uint8_t* byte_ptr = static_cast<uint8_t*>(db->raw_ptr());
// Load the data into the data buffer.
LoadStoreHelper(address, byte_ptr, size_in_units, true);
// Execute the instruction to process and write back the load data.
@@ -76,12 +76,12 @@
}
}
-void KelvinRenodeMemory::Load(DataBuffer *address_db, DataBuffer *mask_db,
- int el_size, DataBuffer *db, Instruction *inst,
- ReferenceCount *context) {
+void KelvinRenodeMemory::Load(DataBuffer* address_db, DataBuffer* mask_db,
+ int el_size, DataBuffer* db, Instruction* inst,
+ ReferenceCount* context) {
auto mask_span = mask_db->Get<bool>();
auto address_span = address_db->Get<uint64_t>();
- uint8_t *byte_ptr = static_cast<uint8_t *>(db->raw_ptr());
+ uint8_t* byte_ptr = static_cast<uint8_t*>(db->raw_ptr());
int size_in_units = el_size / addressable_unit_size_;
ABSL_HARDENING_ASSERT(size_in_units > 0);
// This is either a gather load, or a unit stride load depending on size of
@@ -112,20 +112,20 @@
}
}
-void KelvinRenodeMemory::Store(uint64_t address, DataBuffer *db) {
+void KelvinRenodeMemory::Store(uint64_t address, DataBuffer* db) {
int size_in_units = db->size<uint8_t>() / addressable_unit_size_;
uint64_t high = address + size_in_units;
ABSL_HARDENING_ASSERT(IsValidAddress(address, high));
ABSL_HARDENING_ASSERT(size_in_units > 0);
- uint8_t *byte_ptr = static_cast<uint8_t *>(db->raw_ptr());
+ uint8_t* byte_ptr = static_cast<uint8_t*>(db->raw_ptr());
LoadStoreHelper(address, byte_ptr, size_in_units, /*is_load*/ false);
}
-void KelvinRenodeMemory::Store(DataBuffer *address_db, DataBuffer *mask_db,
- int el_size, DataBuffer *db) {
+void KelvinRenodeMemory::Store(DataBuffer* address_db, DataBuffer* mask_db,
+ int el_size, DataBuffer* db) {
auto mask_span = mask_db->Get<bool>();
auto address_span = address_db->Get<uint64_t>();
- uint8_t *byte_ptr = static_cast<uint8_t *>(db->raw_ptr());
+ uint8_t* byte_ptr = static_cast<uint8_t*>(db->raw_ptr());
int size_in_units = el_size / addressable_unit_size_;
ABSL_HARDENING_ASSERT(size_in_units > 0);
// If the address_span.size() > 1, then this is a scatter store, otherwise
@@ -142,14 +142,14 @@
}
}
-void KelvinRenodeMemory::LoadStoreHelper(uint64_t address, uint8_t *byte_ptr,
+void KelvinRenodeMemory::LoadStoreHelper(uint64_t address, uint8_t* byte_ptr,
int size_in_units, bool is_load) {
ABSL_HARDENING_ASSERT(address < max_address_);
do {
// Find the block in the map.
uint64_t block_idx = address / memory_block_size_bytes_;
- uint8_t *block = block_map_[block_idx];
+ uint8_t* block = block_map_[block_idx];
int block_unit_offset = (address - block_idx * memory_block_size_bytes_);
diff --git a/sim/renode/kelvin_renode_memory.h b/sim/renode/kelvin_renode_memory.h
index ae26c5d..3ca98ba 100644
--- a/sim/renode/kelvin_renode_memory.h
+++ b/sim/renode/kelvin_renode_memory.h
@@ -40,10 +40,10 @@
class KelvinRenodeMemory : public mpact::sim::util::MemoryInterface {
public:
KelvinRenodeMemory(uint64_t block_size_bytes, uint64_t memory_size_bytes,
- uint8_t **block_ptr_list, uint64_t base_address,
+ uint8_t** block_ptr_list, uint64_t base_address,
unsigned addressable_unit_size);
KelvinRenodeMemory(uint64_t block_size_bytes, uint64_t memory_size_bytes,
- uint8_t **block_ptr_list)
+ uint8_t** block_ptr_list)
: KelvinRenodeMemory(block_size_bytes, memory_size_bytes, block_ptr_list,
0, 1) {}
@@ -52,34 +52,34 @@
~KelvinRenodeMemory() override = default;
// Implementation of the MemoryInterface methods.
- void Load(uint64_t address, DataBuffer *db, Instruction *inst,
- ReferenceCount *context) override;
+ void Load(uint64_t address, DataBuffer* db, Instruction* inst,
+ ReferenceCount* context) override;
- void Load(DataBuffer *address_db, DataBuffer *mask_db, int el_size,
- DataBuffer *db, Instruction *inst,
- ReferenceCount *context) override;
+ void Load(DataBuffer* address_db, DataBuffer* mask_db, int el_size,
+ DataBuffer* db, Instruction* inst,
+ ReferenceCount* context) override;
// Convenience template function that calls the above function with the
// element size as the sizeof() the template parameter type.
template <typename T>
- void Load(DataBuffer *address_db, DataBuffer *mask_db, DataBuffer *db,
- Instruction *inst, ReferenceCount *context) {
+ void Load(DataBuffer* address_db, DataBuffer* mask_db, DataBuffer* db,
+ Instruction* inst, ReferenceCount* context) {
Load(address_db, mask_db, sizeof(T), db, inst, context);
}
- void Store(uint64_t address, DataBuffer *db) override;
- void Store(DataBuffer *address_db, DataBuffer *mask_db, int el_size,
- DataBuffer *db) override;
+ void Store(uint64_t address, DataBuffer* db) override;
+ void Store(DataBuffer* address_db, DataBuffer* mask_db, int el_size,
+ DataBuffer* db) override;
// Convenience template function that calls the above function with the
// element size as the sizeof() the template parameter type.
template <typename T>
- void Store(DataBuffer *address_db, DataBuffer *mask_db, DataBuffer *db) {
+ void Store(DataBuffer* address_db, DataBuffer* mask_db, DataBuffer* db) {
Store(address_db, mask_db, sizeof(T), db);
}
private:
- void LoadStoreHelper(uint64_t address, uint8_t *byte_ptr, int size_in_units,
+ void LoadStoreHelper(uint64_t address, uint8_t* byte_ptr, int size_in_units,
bool is_load);
bool IsValidAddress(uint64_t address, uint64_t high_address);
@@ -90,7 +90,7 @@
uint64_t base_address_;
uint64_t max_address_;
- std::vector<uint8_t *> block_map_;
+ std::vector<uint8_t*> block_map_;
};
} // namespace kelvin::sim::renode
diff --git a/sim/renode/kelvin_renode_register_info.h b/sim/renode/kelvin_renode_register_info.h
index b96cc68..aa0f676 100644
--- a/sim/renode/kelvin_renode_register_info.h
+++ b/sim/renode/kelvin_renode_register_info.h
@@ -29,15 +29,15 @@
class KelvinRenodeRegisterInfo {
public:
using RenodeRegisterInfo = std::vector<renode::RenodeCpuRegister>;
- static const RenodeRegisterInfo &GetRenodeRegisterInfo();
+ static const RenodeRegisterInfo& GetRenodeRegisterInfo();
private:
KelvinRenodeRegisterInfo();
- static KelvinRenodeRegisterInfo *Instance();
+ static KelvinRenodeRegisterInfo* Instance();
void InitializeRenodeRegisterInfo();
- const RenodeRegisterInfo &GetRenodeRegisterInfoPrivate();
+ const RenodeRegisterInfo& GetRenodeRegisterInfoPrivate();
- static KelvinRenodeRegisterInfo *instance_;
+ static KelvinRenodeRegisterInfo* instance_;
RenodeRegisterInfo renode_register_info_;
};
diff --git a/sim/renode/kelvin_renode_reigster_info.cc b/sim/renode/kelvin_renode_reigster_info.cc
index 5359915..ad2b9f1 100644
--- a/sim/renode/kelvin_renode_reigster_info.cc
+++ b/sim/renode/kelvin_renode_reigster_info.cc
@@ -20,7 +20,7 @@
using ::mpact::sim::generic::operator*; // NOLINT: used below (clange error).
-KelvinRenodeRegisterInfo *KelvinRenodeRegisterInfo::instance_ = nullptr;
+KelvinRenodeRegisterInfo* KelvinRenodeRegisterInfo::instance_ = nullptr;
void KelvinRenodeRegisterInfo::InitializeRenodeRegisterInfo() {
using DbgReg = mpact::sim::riscv::DebugRegisterEnum;
@@ -50,19 +50,19 @@
InitializeRenodeRegisterInfo();
}
-const KelvinRenodeRegisterInfo::RenodeRegisterInfo &
+const KelvinRenodeRegisterInfo::RenodeRegisterInfo&
KelvinRenodeRegisterInfo::GetRenodeRegisterInfo() {
return Instance()->GetRenodeRegisterInfoPrivate();
}
-KelvinRenodeRegisterInfo *KelvinRenodeRegisterInfo::Instance() {
+KelvinRenodeRegisterInfo* KelvinRenodeRegisterInfo::Instance() {
if (instance_ == nullptr) {
instance_ = new KelvinRenodeRegisterInfo();
}
return instance_;
}
-const KelvinRenodeRegisterInfo::RenodeRegisterInfo &
+const KelvinRenodeRegisterInfo::RenodeRegisterInfo&
KelvinRenodeRegisterInfo::GetRenodeRegisterInfoPrivate() {
return renode_register_info_;
}
diff --git a/sim/renode/renode_debug_interface.h b/sim/renode/renode_debug_interface.h
index 3951222..fe44b80 100644
--- a/sim/renode/renode_debug_interface.h
+++ b/sim/renode/renode_debug_interface.h
@@ -49,10 +49,10 @@
// Get register information.
virtual int32_t GetRenodeRegisterInfoSize() const = 0;
virtual absl::Status GetRenodeRegisterInfo(int32_t index, int32_t max_len,
- char *name,
- RenodeCpuRegister &info) = 0;
+ char* name,
+ RenodeCpuRegister& info) = 0;
- virtual absl::Status LoadImage(const std::string &image_path,
+ virtual absl::Status LoadImage(const std::string& image_path,
uint64_t start_address) = 0;
};
diff --git a/sim/renode/renode_mpact.cc b/sim/renode/renode_mpact.cc
index 1648dc2..9a82c03 100644
--- a/sim/renode/renode_mpact.cc
+++ b/sim/renode/renode_mpact.cc
@@ -26,12 +26,12 @@
#include "mpact/sim/util/program_loader/elf_program_loader.h"
// This function must be defined in the library.
-extern kelvin::sim::renode::RenodeDebugInterface *CreateKelvinSim(std::string);
+extern kelvin::sim::renode::RenodeDebugInterface* CreateKelvinSim(std::string);
-extern kelvin::sim::renode::RenodeDebugInterface *CreateKelvinSim(std::string,
+extern kelvin::sim::renode::RenodeDebugInterface* CreateKelvinSim(std::string,
uint64_t,
uint64_t,
- uint8_t **);
+ uint8_t**);
// External "C" functions visible to Renode.
using kelvin::sim::renode::RenodeAgent;
@@ -46,7 +46,7 @@
int32_t construct_with_memory(int32_t max_name_length,
uint64_t memory_block_size_bytes,
uint64_t memory_size_bytes,
- uint8_t **mem_block_ptr_list) {
+ uint8_t** mem_block_ptr_list) {
return RenodeAgent::Instance()->Construct(
max_name_length, memory_block_size_bytes, memory_size_bytes,
mem_block_ptr_list);
@@ -57,48 +57,48 @@
int32_t get_reg_info_size(int32_t id) {
return RenodeAgent::Instance()->GetRegisterInfoSize(id);
}
-int32_t get_reg_info(int32_t id, int32_t index, char *name, void *info) {
+int32_t get_reg_info(int32_t id, int32_t index, char* name, void* info) {
if (info == nullptr) return -1;
return RenodeAgent::Instance()->GetRegisterInfo(
- id, index, name, static_cast<RenodeCpuRegister *>(info));
+ id, index, name, static_cast<RenodeCpuRegister*>(info));
}
-uint64_t load_executable(int32_t id, const char *elf_file_name,
- int32_t *status) {
+uint64_t load_executable(int32_t id, const char* elf_file_name,
+ int32_t* status) {
return RenodeAgent::Instance()->LoadExecutable(id, elf_file_name, status);
}
-int32_t load_image(int32_t id, const char *file_name, uint64_t address) {
+int32_t load_image(int32_t id, const char* file_name, uint64_t address) {
return RenodeAgent::Instance()->LoadImage(id, file_name, address);
}
-int32_t read_register(int32_t id, uint32_t reg_id, uint64_t *value) {
+int32_t read_register(int32_t id, uint32_t reg_id, uint64_t* value) {
return RenodeAgent::Instance()->ReadRegister(id, reg_id, value);
}
int32_t write_register(int32_t id, uint32_t reg_id, uint64_t value) {
return RenodeAgent::Instance()->WriteRegister(id, reg_id, value);
}
-uint64_t read_memory(int32_t id, uint64_t address, char *buffer,
+uint64_t read_memory(int32_t id, uint64_t address, char* buffer,
uint64_t length) {
return RenodeAgent::Instance()->ReadMemory(id, address, buffer, length);
}
-uint64_t write_memory(int32_t id, uint64_t address, const char *buffer,
+uint64_t write_memory(int32_t id, uint64_t address, const char* buffer,
uint64_t length) {
return RenodeAgent::Instance()->WriteMemory(id, address, buffer, length);
}
-uint64_t step(int32_t id, uint64_t num_to_step, int32_t *status) {
+uint64_t step(int32_t id, uint64_t num_to_step, int32_t* status) {
return RenodeAgent::Instance()->Step(id, num_to_step, status);
}
-int32_t halt(int32_t id, int32_t *status) {
+int32_t halt(int32_t id, int32_t* status) {
return RenodeAgent::Instance()->Halt(id, status);
}
namespace kelvin::sim::renode {
-RenodeAgent *RenodeAgent::instance_ = nullptr;
+RenodeAgent* RenodeAgent::instance_ = nullptr;
uint32_t RenodeAgent::count_ = 0;
// Create the debug instance by calling the factory function.
int32_t RenodeAgent::Construct(int32_t max_name_length) {
std::string name = absl::StrCat("renode", count_);
- auto *dbg = CreateKelvinSim(name);
+ auto* dbg = CreateKelvinSim(name);
if (dbg == nullptr) {
return -1;
}
@@ -110,9 +110,9 @@
int32_t RenodeAgent::Construct(int32_t max_name_length,
uint64_t memory_block_size_bytes,
uint64_t memory_size_bytes,
- uint8_t **mem_block_ptr_list) {
+ uint8_t** mem_block_ptr_list) {
std::string name = absl::StrCat("renode", count_);
- auto *dbg = CreateKelvinSim(name, memory_block_size_bytes, memory_size_bytes,
+ auto* dbg = CreateKelvinSim(name, memory_block_size_bytes, memory_size_bytes,
mem_block_ptr_list);
if (dbg == nullptr) {
return -1;
@@ -144,17 +144,17 @@
// Check for valid instance.
auto dbg_iter = core_dbg_instances_.find(id);
if (dbg_iter == core_dbg_instances_.end()) return -1;
- auto *dbg = dbg_iter->second;
+ auto* dbg = dbg_iter->second;
return dbg->GetRenodeRegisterInfoSize();
}
-int32_t RenodeAgent::GetRegisterInfo(int32_t id, int32_t index, char *name,
- RenodeCpuRegister *info) {
+int32_t RenodeAgent::GetRegisterInfo(int32_t id, int32_t index, char* name,
+ RenodeCpuRegister* info) {
// Check for valid instance.
if (info == nullptr) return -1;
auto dbg_iter = core_dbg_instances_.find(id);
if (dbg_iter == core_dbg_instances_.end()) return -1;
- auto *dbg = dbg_iter->second;
+ auto* dbg = dbg_iter->second;
int32_t max_len = name_length_map_.at(id);
auto result = dbg->GetRenodeRegisterInfo(index, max_len, name, *info);
if (!result.ok()) return -1;
@@ -163,13 +163,13 @@
// Read the register given by the id.
int32_t RenodeAgent::ReadRegister(int32_t id, uint32_t reg_id,
- uint64_t *value) {
+ uint64_t* value) {
// Check for valid instance.
if (value == nullptr) return -1;
auto dbg_iter = core_dbg_instances_.find(id);
if (dbg_iter == core_dbg_instances_.end()) return -1;
// Read register.
- auto *dbg = dbg_iter->second;
+ auto* dbg = dbg_iter->second;
auto result = dbg->ReadRegister(reg_id);
if (!result.ok()) return -1;
*value = result.value();
@@ -182,13 +182,13 @@
auto dbg_iter = core_dbg_instances_.find(id);
if (dbg_iter == core_dbg_instances_.end()) return -1;
// Write register.
- auto *dbg = dbg_iter->second;
+ auto* dbg = dbg_iter->second;
auto result = dbg->WriteRegister(reg_id, value);
if (!result.ok()) return -1;
return 0;
}
-uint64_t RenodeAgent::ReadMemory(int32_t id, uint64_t address, char *buffer,
+uint64_t RenodeAgent::ReadMemory(int32_t id, uint64_t address, char* buffer,
uint64_t length) {
// Check for valid desktop.
auto dbg_iter = core_dbg_instances_.find(id);
@@ -196,28 +196,28 @@
LOG(ERROR) << "No such core dbg instance: " << id;
return 0;
}
- auto *dbg = dbg_iter->second;
+ auto* dbg = dbg_iter->second;
auto res = dbg->ReadMemory(address, buffer, length);
if (!res.ok()) return 0;
return res.value();
}
uint64_t RenodeAgent::WriteMemory(int32_t id, uint64_t address,
- const char *buffer, uint64_t length) {
+ const char* buffer, uint64_t length) {
// Check for valid desktop.
auto dbg_iter = core_dbg_instances_.find(id);
if (dbg_iter == core_dbg_instances_.end()) {
LOG(ERROR) << "No such core dbg instance: " << id;
return 0;
}
- auto *dbg = dbg_iter->second;
+ auto* dbg = dbg_iter->second;
auto res = dbg->WriteMemory(address, buffer, length);
if (!res.ok()) return 0;
return res.value();
}
-uint64_t RenodeAgent::LoadExecutable(int32_t id, const char *file_name,
- int32_t *status) {
+uint64_t RenodeAgent::LoadExecutable(int32_t id, const char* file_name,
+ int32_t* status) {
// Check for valid desktop.
auto dbg_iter = core_dbg_instances_.find(id);
if (dbg_iter == core_dbg_instances_.end()) {
@@ -226,7 +226,7 @@
return 0;
}
// Instantiate loader and try to load the file.
- auto *dbg = dbg_iter->second;
+ auto* dbg = dbg_iter->second;
mpact::sim::util::ElfProgramLoader loader(dbg);
auto load_res = loader.LoadProgram(file_name);
if (!load_res.ok()) {
@@ -244,7 +244,7 @@
return entry;
}
-int32_t RenodeAgent::LoadImage(int32_t id, const char *file_name,
+int32_t RenodeAgent::LoadImage(int32_t id, const char* file_name,
uint64_t address) {
// Get the debug interface.
auto dbg_iter = core_dbg_instances_.find(id);
@@ -252,8 +252,8 @@
LOG(ERROR) << "No such core dbg instance: " << id;
return -1;
}
- auto *dbg = dbg_iter->second;
- auto res = dbg->LoadImage(std::string(file_name), address);
+ auto* dbg = dbg_iter->second;
+ auto res = dbg->LoadImage(file_name, address);
if (!res.ok()) {
LOG(ERROR) << "Failed to load image: " << res.message();
return -1;
@@ -261,14 +261,14 @@
return 0;
}
-uint64_t RenodeAgent::Step(int32_t id, uint64_t num_to_step, int32_t *status) {
+uint64_t RenodeAgent::Step(int32_t id, uint64_t num_to_step, int32_t* status) {
// Set the default execution status
if (status != nullptr) {
*status = static_cast<int32_t>(ExecutionResult::kAborted);
}
// Get the core debug if object.
- auto *dbg = RenodeAgent::Instance()->core_dbg(id);
+ auto* dbg = RenodeAgent::Instance()->core_dbg(id);
// Is the debug interface valid?
if (dbg == nullptr) {
return 0;
@@ -358,9 +358,9 @@
}
// Signal the simulator to halt.
-int32_t RenodeAgent::Halt(int32_t id, int32_t *status) {
+int32_t RenodeAgent::Halt(int32_t id, int32_t* status) {
// Get the core debug if object.
- auto *dbg = RenodeAgent::Instance()->core_dbg(id);
+ auto* dbg = RenodeAgent::Instance()->core_dbg(id);
// Is the debug interface valid?
if (dbg == nullptr) {
return -1;
diff --git a/sim/renode/renode_mpact.h b/sim/renode/renode_mpact.h
index 756c4d8..617929f 100644
--- a/sim/renode/renode_mpact.h
+++ b/sim/renode/renode_mpact.h
@@ -37,7 +37,7 @@
int32_t construct_with_memory(int32_t max_name_length,
uint64_t memory_block_size_bytes,
uint64_t memory_size_bytes,
- uint8_t **mem_block_ptr_list);
+ uint8_t** mem_block_ptr_list);
// Destruct the given debug instance. A negative return value indicates an
// error.
int32_t destruct(int32_t id);
@@ -45,31 +45,31 @@
int32_t get_reg_info_size(int32_t id);
// Return the register entry with the given index. The info pointer should
// store an object of type RenodeCpuRegister.
-int32_t get_reg_info(int32_t id, int32_t index, char *name, void *info);
+int32_t get_reg_info(int32_t id, int32_t index, char* name, void* info);
// Load the given executable into the instance with the given id. Return the
// entry point.
-uint64_t load_executable(int32_t id, const char *elf_file_name,
- int32_t *status);
+uint64_t load_executable(int32_t id, const char* elf_file_name,
+ int32_t* status);
// Load the content of the given file into memory, starting at the given
// address.
-int32_t load_image(int32_t id, const char *file_name, uint64_t address);
+int32_t load_image(int32_t id, const char* file_name, uint64_t address);
// Read register reg_id in the instance id, store the value in the pointer
// given. A return value < 0 is an error.
-int32_t read_register(int32_t id, uint32_t reg_id, uint64_t *value);
+int32_t read_register(int32_t id, uint32_t reg_id, uint64_t* value);
// Write register reg_id in the instance id. A return value < 0 is an error.
int32_t write_register(int32_t id, uint32_t reg_id, uint64_t value);
-uint64_t read_memory(int32_t id, uint64_t address, char *buffer,
+uint64_t read_memory(int32_t id, uint64_t address, char* buffer,
uint64_t length);
-uint64_t write_memory(int32_t id, uint64_t address, const char *buffer,
+uint64_t write_memory(int32_t id, uint64_t address, const char* buffer,
uint64_t length);
// Reset the instance. A return value < 0 is an error.
int32_t reset(int32_t id);
// Step the instance id by num_to_step instructions. Return the number of
// instructions stepped. The status is written to the pointer *status.
-uint64_t step(int32_t id, uint64_t num_to_step, int32_t *status);
+uint64_t step(int32_t id, uint64_t num_to_step, int32_t* status);
// Halt a free running simulator.
-int32_t halt(int32_t id, int32_t *status);
+int32_t halt(int32_t id, int32_t* status);
}
namespace kelvin::sim::renode {
@@ -91,7 +91,7 @@
using RenodeCpuRegister = kelvin::sim::renode::RenodeCpuRegister;
constexpr static size_t kBufferSize = 64 * 1024;
// This is a singleton class, so need a static Instance method.
- static RenodeAgent *Instance() {
+ static RenodeAgent* Instance() {
if (instance_ != nullptr) return instance_;
instance_ = new RenodeAgent();
return instance_;
@@ -99,35 +99,35 @@
// These methods correspond to the C methods defined above.
int32_t Construct(int32_t max_name_length);
int32_t Construct(int32_t max_name_length, uint64_t memory_block_size_bytes,
- uint64_t memory_size_bytes, uint8_t **mem_block_ptr_list);
+ uint64_t memory_size_bytes, uint8_t** mem_block_ptr_list);
int32_t Destroy(int32_t id);
int32_t Reset(int32_t id);
int32_t GetRegisterInfoSize(int32_t id) const;
- int32_t GetRegisterInfo(int32_t id, int32_t index, char *name,
- RenodeCpuRegister *info);
- int32_t ReadRegister(int32_t id, uint32_t reg_id, uint64_t *value);
+ int32_t GetRegisterInfo(int32_t id, int32_t index, char* name,
+ RenodeCpuRegister* info);
+ int32_t ReadRegister(int32_t id, uint32_t reg_id, uint64_t* value);
int32_t WriteRegister(int32_t id, uint32_t reg_id, uint64_t value);
- uint64_t ReadMemory(int32_t id, uint64_t address, char *buffer,
+ uint64_t ReadMemory(int32_t id, uint64_t address, char* buffer,
uint64_t length);
- uint64_t WriteMemory(int32_t id, uint64_t address, const char *buffer,
+ uint64_t WriteMemory(int32_t id, uint64_t address, const char* buffer,
uint64_t length);
- uint64_t LoadExecutable(int32_t id, const char *elf_file_name,
- int32_t *status);
- int32_t LoadImage(int32_t id, const char *file_name, uint64_t address);
- uint64_t Step(int32_t id, uint64_t num_to_step, int32_t *status);
- int32_t Halt(int32_t id, int32_t *status);
+ uint64_t LoadExecutable(int32_t id, const char* elf_file_name,
+ int32_t* status);
+ int32_t LoadImage(int32_t id, const char* file_name, uint64_t address);
+ uint64_t Step(int32_t id, uint64_t num_to_step, int32_t* status);
+ int32_t Halt(int32_t id, int32_t* status);
// Accessor.
- kelvin::sim::renode::RenodeDebugInterface *core_dbg(int32_t id) const {
+ kelvin::sim::renode::RenodeDebugInterface* core_dbg(int32_t id) const {
auto ptr = core_dbg_instances_.find(id);
if (ptr != core_dbg_instances_.end()) return ptr->second;
return nullptr;
}
private:
- static RenodeAgent *instance_;
+ static RenodeAgent* instance_;
static uint32_t count_;
RenodeAgent() = default;
- absl::flat_hash_map<uint32_t, kelvin::sim::renode::RenodeDebugInterface *>
+ absl::flat_hash_map<uint32_t, kelvin::sim::renode::RenodeDebugInterface*>
core_dbg_instances_;
absl::flat_hash_map<uint32_t, int32_t> name_length_map_;
};
diff --git a/sim/renode/test/BUILD b/sim/renode/test/BUILD
index ae3b053..0e45fa0 100644
--- a/sim/renode/test/BUILD
+++ b/sim/renode/test/BUILD
@@ -15,6 +15,8 @@
# This project contains a small set of tests to test the functionality of
# the MPACT-Sim/Renode interface.
+
+
cc_test(
name = "renode_mpact_test",
size = "small",
diff --git a/sim/renode/test/kelvin_renode_test.cc b/sim/renode/test/kelvin_renode_test.cc
index 8b15f4b..f267021 100644
--- a/sim/renode/test/kelvin_renode_test.cc
+++ b/sim/renode/test/kelvin_renode_test.cc
@@ -47,7 +47,7 @@
~KelvinRenodeTest() override { delete top_; }
- RenodeDebugInterface *top_ = nullptr;
+ RenodeDebugInterface* top_ = nullptr;
};
// Test the implementation of the added methods in the RenodeDebugInterface.
@@ -74,7 +74,7 @@
TEST_F(KelvinRenodeTest, RunElfProgram) {
std::string file_name = absl::StrCat(kDepotPath, "testfiles/", kFileName);
// Load the program.
- auto *loader = new mpact::sim::util::ElfProgramLoader(top_);
+ auto* loader = new mpact::sim::util::ElfProgramLoader(top_);
auto result = loader->LoadProgram(file_name);
CHECK_OK(result);
auto entry_point = result.value();
@@ -98,7 +98,7 @@
std::string file_name =
absl::StrCat(kDepotPath, "testfiles/", kEbreakFileName);
// Load the program.
- auto *loader = new mpact::sim::util::ElfProgramLoader(top_);
+ auto* loader = new mpact::sim::util::ElfProgramLoader(top_);
auto result = loader->LoadProgram(file_name);
CHECK_OK(result);
auto entry_point = result.value();
@@ -151,7 +151,7 @@
// Setup the external memory.
constexpr uint64_t kMemoryBlockSize = 0x40000; // 256KB
constexpr uint64_t kNumBlock = 16; // 4MB / 256KB
- uint8_t *memory_block[kNumBlock] = {nullptr};
+ uint8_t* memory_block[kNumBlock] = {nullptr};
// Allocate memory blocks.
for (int i = 0; i < kNumBlock; ++i) {
memory_block[i] = new uint8_t[kMemoryBlockSize];
diff --git a/sim/renode/test/renode_mpact_test.cc b/sim/renode/test/renode_mpact_test.cc
index ad5ffad..7ec5224 100644
--- a/sim/renode/test/renode_mpact_test.cc
+++ b/sim/renode/test/renode_mpact_test.cc
@@ -119,23 +119,23 @@
TEST_F(RenodeMpactTest, ReadWriteMem) {
constexpr uint8_t kBytes[] = {0x01, 0x02, 0x03, 0x04, 0xff, 0xfe, 0xfd, 0xfc};
int res =
- write_memory(sim_id_, 0x100, reinterpret_cast<const char *>(kBytes), 8);
+ write_memory(sim_id_, 0x100, reinterpret_cast<const char*>(kBytes), 8);
EXPECT_EQ(res, 8);
uint8_t mem_bytes[8] = {0xde, 0xad, 0xbe, 0xef, 0x5a, 0xa5, 0xff, 0x00};
- res = read_memory(sim_id_, 0x104, reinterpret_cast<char *>(mem_bytes), 1);
+ res = read_memory(sim_id_, 0x104, reinterpret_cast<char*>(mem_bytes), 1);
EXPECT_EQ(res, 1);
EXPECT_EQ(mem_bytes[0], kBytes[4]);
- res = read_memory(sim_id_, 0x100, reinterpret_cast<char *>(mem_bytes), 8);
+ res = read_memory(sim_id_, 0x100, reinterpret_cast<char*>(mem_bytes), 8);
for (int i = 0; i < 8; i++) EXPECT_EQ(kBytes[i], mem_bytes[i]);
// Read memory from out of bound address
constexpr uint64_t kOutOfBoundAddress = 0x3'FFFF'FFFFULL;
res = read_memory(sim_id_, kOutOfBoundAddress,
- reinterpret_cast<char *>(mem_bytes), 1);
+ reinterpret_cast<char*>(mem_bytes), 1);
EXPECT_EQ(res, 0);
// Write to out of bound memory address
res = write_memory(sim_id_, kOutOfBoundAddress,
- reinterpret_cast<const char *>(mem_bytes), 1);
+ reinterpret_cast<const char*>(mem_bytes), 1);
EXPECT_EQ(res, 0);
}
@@ -266,7 +266,7 @@
// Setup the external memory.
constexpr uint64_t kMemoryBlockSize = 0x40000; // 256KB
constexpr uint64_t kNumBlock = 16; // 4MB / 256KB
- uint8_t *memory_block[kNumBlock] = {nullptr};
+ uint8_t* memory_block[kNumBlock] = {nullptr};
// Allocate memory blocks.
for (int i = 0; i < kNumBlock; ++i) {
memory_block[i] = new uint8_t[kMemoryBlockSize];
diff --git a/sim/test/BUILD b/sim/test/BUILD
index efcca3b..f966a87 100644
--- a/sim/test/BUILD
+++ b/sim/test/BUILD
@@ -14,6 +14,9 @@
# Unit tests for kelvin simulator.
+
+
+
exports_files(
srcs = [
"testfiles/hello_world_mpause.bin",
@@ -201,3 +204,12 @@
"@com_google_mpact-sim//mpact/sim/generic:instruction",
],
)
+
+cc_test(
+ name = "kelvin_cosim_dpi_wrapper_test",
+ srcs = ["kelvin_cosim_dpi_wrapper_test.cc"],
+ deps = [
+ "//sim/cosim:kelvin_cosim_lib",
+ "@com_google_googletest//:gtest_main",
+ ],
+)
diff --git a/sim/test/kelvin_cosim_dpi_wrapper_test.cc b/sim/test/kelvin_cosim_dpi_wrapper_test.cc
new file mode 100644
index 0000000..0c5fca5
--- /dev/null
+++ b/sim/test/kelvin_cosim_dpi_wrapper_test.cc
@@ -0,0 +1,66 @@
+#include <cstdint>
+
+#include "sim/cosim/kelvin_cosim_dpi.h"
+#include "googletest/include/gtest/gtest.h"
+#include "external/svdpi_h_file/file/svdpi.h"
+
+namespace {
+
+const uint32_t kLoadImmediateToX5 = 0b11011110101011011011'00101'0110111;
+const uint32_t kAddImmediateToX5_2047 = 0b011111111111'00101'000'00101'0010011;
+const uint32_t kAddImmediateToX5_1776 = 0b011011110000'00101'000'00101'0010011;
+const uint32_t kExpectedX5Value = 0xdeadbeef;
+const uint32_t kNopInstruction = 0x00000013; // x0 = x0 + 0 (nop)
+const uint32_t kMcycleCsrAddress = 0xb00;
+
+class CosimFixture : public ::testing::Test {
+ public:
+ CosimFixture() { mpact_init(); }
+ ~CosimFixture() override { mpact_fini(); }
+};
+
+TEST_F(CosimFixture, Step) {
+ svLogicVecVal instruction;
+ instruction.aval = 0x00000000;
+ EXPECT_EQ(mpact_step(&instruction), 0);
+}
+
+TEST_F(CosimFixture, GetPc) { EXPECT_EQ(mpact_get_pc(), 0); }
+
+TEST_F(CosimFixture, GetPcAfterStep) {
+ svLogicVecVal instruction;
+ instruction.aval = kNopInstruction;
+ EXPECT_EQ(mpact_step(&instruction), 0);
+ EXPECT_EQ(mpact_get_pc(), 4);
+}
+
+TEST_F(CosimFixture, GetPcAfterReset) {
+ svLogicVecVal instruction;
+ instruction.aval = kNopInstruction; // x0 = x0 + 0 (nop)
+ EXPECT_EQ(mpact_step(&instruction), 0);
+ EXPECT_NE(mpact_get_pc(), 0);
+ EXPECT_EQ(mpact_reset(), 0);
+ EXPECT_EQ(mpact_get_pc(), 0);
+}
+
+TEST_F(CosimFixture, CheckGpr) {
+ EXPECT_EQ(mpact_get_gpr(5), 0);
+ svLogicVecVal instruction;
+ instruction.aval = kLoadImmediateToX5;
+ EXPECT_EQ(mpact_step(&instruction), 0);
+ instruction.aval = kAddImmediateToX5_2047;
+ EXPECT_EQ(mpact_step(&instruction), 0);
+ instruction.aval = kAddImmediateToX5_1776;
+ EXPECT_EQ(mpact_step(&instruction), 0);
+ EXPECT_EQ(mpact_get_gpr(5), kExpectedX5Value);
+}
+
+TEST_F(CosimFixture, GetMcycleCsr) {
+ EXPECT_EQ(mpact_get_csr(kMcycleCsrAddress), 0);
+ svLogicVecVal instruction;
+ instruction.aval = kNopInstruction; // x0 = x0 + 0 (nop)
+ EXPECT_EQ(mpact_step(&instruction), 0);
+ EXPECT_EQ(mpact_get_csr(kMcycleCsrAddress), 1);
+}
+
+} // namespace
diff --git a/sim/test/kelvin_decoder_test.cc b/sim/test/kelvin_decoder_test.cc
index d719f8b..a68365b 100644
--- a/sim/test/kelvin_decoder_test.cc
+++ b/sim/test/kelvin_decoder_test.cc
@@ -55,7 +55,7 @@
auto result = loader_.LoadProgram(input_file);
CHECK_OK(result.status());
elf_reader_.load(input_file);
- auto *symtab = elf_reader_.sections[".symtab"];
+ auto* symtab = elf_reader_.sections[".symtab"];
CHECK_NE(symtab, nullptr);
symbol_accessor_ = new SymbolAccessor(elf_reader_, symtab);
}
@@ -67,7 +67,7 @@
kelvin::sim::KelvinState state_;
mpact::sim::util::ElfProgramLoader loader_;
kelvin::sim::KelvinDecoder decoder_;
- SymbolAccessor *symbol_accessor_;
+ SymbolAccessor* symbol_accessor_;
};
// This test is really pretty simple. It decodes the instructions in "main".
@@ -88,15 +88,15 @@
while (address < value + size) {
LOG(INFO) << "Address: " << std::hex << address;
EXPECT_FALSE(state_.program_error_controller()->HasError());
- auto *inst = decoder_.DecodeInstruction(address);
+ auto* inst = decoder_.DecodeInstruction(address);
ASSERT_NE(inst, nullptr);
inst->Execute(nullptr);
if (state_.program_error_controller()->HasError()) {
auto errvec = state_.program_error_controller()->GetUnmaskedErrorNames();
- for (auto &err : errvec) {
+ for (auto& err : errvec) {
LOG(INFO) << "Error: " << err;
auto msgvec = state_.program_error_controller()->GetErrorMessages(err);
- for (auto &msg : msgvec) {
+ for (auto& msg : msgvec) {
LOG(INFO) << " " << msg;
}
}
@@ -111,7 +111,7 @@
// Even with a bad address, a valid instruction object should be returned.
TEST_F(KelvinDecoderTest, BadAddress) {
- auto *inst = decoder_.DecodeInstruction(0x4321);
+ auto* inst = decoder_.DecodeInstruction(0x4321);
ASSERT_NE(inst, nullptr);
inst->Execute(nullptr);
inst->DecRef();
diff --git a/sim/test/kelvin_encoding_test.cc b/sim/test/kelvin_encoding_test.cc
index 8200b90..683efa3 100644
--- a/sim/test/kelvin_encoding_test.cc
+++ b/sim/test/kelvin_encoding_test.cc
@@ -153,24 +153,24 @@
}
template <typename T>
- T *EncodeOpHelper(uint32_t inst_word, OpcodeEnum opcode, std::any op) const {
+ T* EncodeOpHelper(uint32_t inst_word, OpcodeEnum opcode, std::any op) const {
enc_->ParseInstruction(inst_word);
EXPECT_EQ(enc_->GetOpcode(SlotEnum::kKelvin, 0), opcode);
if (std::is_same<T, RV32SourceOperand>::value ||
std::is_same<T, RV32VectorSourceOperand>::value) {
- auto *source = enc_->GetSource(SlotEnum::kKelvin, 0, opcode,
+ auto* source = enc_->GetSource(SlotEnum::kKelvin, 0, opcode,
std::any_cast<SourceOpEnum>(op), 0);
- return reinterpret_cast<T *>(source);
+ return reinterpret_cast<T*>(source);
}
- auto *dest = enc_->GetDestination(SlotEnum::kKelvin, 0, opcode,
+ auto* dest = enc_->GetDestination(SlotEnum::kKelvin, 0, opcode,
std::any_cast<DestOpEnum>(op), 0,
/*latency=*/0);
- return reinterpret_cast<T *>(dest);
+ return reinterpret_cast<T*>(dest);
}
- FlatDemandMemory *memory_;
- KelvinState *state_;
- KelvinEncoding *enc_;
+ FlatDemandMemory* memory_;
+ KelvinState* state_;
+ KelvinEncoding* enc_;
};
constexpr int kRdValue = 1;
@@ -422,18 +422,18 @@
TEST_F(KelvinEncodingTest, NoSourceDest) {
enc_->ParseInstruction(kVld);
- auto *src = enc_->GetSource(SlotEnum::kKelvin, 0, OpcodeEnum::kVldBX,
+ auto* src = enc_->GetSource(SlotEnum::kKelvin, 0, OpcodeEnum::kVldBX,
SourceOpEnum::kNone, 0);
EXPECT_EQ(src, nullptr);
- auto *src_op = enc_->GetSource(SlotEnum::kKelvin, 0, OpcodeEnum::kVldBX,
+ auto* src_op = enc_->GetSource(SlotEnum::kKelvin, 0, OpcodeEnum::kVldBX,
SourceOpEnum::kPastMaxValue, 0);
EXPECT_EQ(src_op, nullptr);
- auto *dest = enc_->GetDestination(SlotEnum::kKelvin, 0, OpcodeEnum::kVldBX,
+ auto* dest = enc_->GetDestination(SlotEnum::kKelvin, 0, OpcodeEnum::kVldBX,
DestOpEnum::kNone, 0, /*latency=*/0);
EXPECT_EQ(dest, nullptr);
- auto *dest_op =
+ auto* dest_op =
enc_->GetDestination(SlotEnum::kKelvin, 0, OpcodeEnum::kVldBX,
DestOpEnum::kPastMaxValue, 0, /*latency=*/0);
EXPECT_EQ(dest_op, nullptr);
@@ -445,7 +445,7 @@
enc_->ParseInstruction(SetSz(SetRs1(kVld, kRdValue), 0b1));
EXPECT_EQ(enc_->GetOpcode(SlotEnum::kKelvin, 0), OpcodeEnum::kVldHX);
// Test vld.b.x (x = x0)
- auto *src = EncodeOpHelper<RV32SourceOperand>(kVld, OpcodeEnum::kVldBX,
+ auto* src = EncodeOpHelper<RV32SourceOperand>(kVld, OpcodeEnum::kVldBX,
SourceOpEnum::kVs1);
EXPECT_EQ(src->AsString(), "zero");
delete src;
@@ -468,13 +468,13 @@
TEST_F(KelvinEncodingTest, KelvinVstEncodeXs1Xs2Vd) {
constexpr uint32_t kVstBase = 0b001000'000000'000000'00'000000'0'111'11;
// Test vd in vst.b.x as source
- auto *v_src = EncodeOpHelper<RV32VectorSourceOperand>(
+ auto* v_src = EncodeOpHelper<RV32VectorSourceOperand>(
SetRs1(kVstBase, kRdValue), OpcodeEnum::kVstBX, SourceOpEnum::kVd);
EXPECT_EQ(v_src->AsString(), "v0");
delete v_src;
// Test xs1 as x0
- auto *dest = EncodeOpHelper<RV32DestOperand>(kVstBase, OpcodeEnum::kVstBX,
+ auto* dest = EncodeOpHelper<RV32DestOperand>(kVstBase, OpcodeEnum::kVstBX,
DestOpEnum::kVs1);
EXPECT_EQ(dest->AsString(), "zero");
delete dest;
@@ -488,7 +488,7 @@
delete dest;
// Test xs2 in vstq.b.s.xx as source
- auto *src = EncodeOpHelper<RV32SourceOperand>(
+ auto* src = EncodeOpHelper<RV32SourceOperand>(
SetRs1(kVstBase, kRdValue) | (1 << 30 /* vstq */) |
(0b10 << 20 /* xs2 */) | (1 << 27 /* stride */),
OpcodeEnum::kVstqBSXx, SourceOpEnum::kVs2);
@@ -498,7 +498,7 @@
TEST_F(KelvinEncodingTest, KelvinWideningVs1) {
constexpr uint32_t kVSransBase = 0b010000'000001'000000'00'001000'0'010'00;
- auto *v_src = EncodeOpHelper<RV32VectorSourceOperand>(
+ auto* v_src = EncodeOpHelper<RV32VectorSourceOperand>(
kVSransBase, OpcodeEnum::kVsransBVv, SourceOpEnum::kVs1);
EXPECT_EQ(v_src->size(), 2);
delete v_src;
@@ -587,7 +587,7 @@
TEST_F(KelvinEncodingTest, KelvinWideningVd) {
// No widening for vld
- auto *v_dest = EncodeOpHelper<RV32VectorDestOperand>(
+ auto* v_dest = EncodeOpHelper<RV32VectorDestOperand>(
SetRs1(kVld, kRdValue), OpcodeEnum::kVldBX, DestOpEnum::kVd);
EXPECT_EQ(v_dest->size(), 1);
delete v_dest;
@@ -683,7 +683,7 @@
}
TEST_F(KelvinEncodingTest, KelvinEncodeVs3) {
- auto *v_src = EncodeOpHelper<RV32VectorSourceOperand>(
+ auto* v_src = EncodeOpHelper<RV32VectorSourceOperand>(
kAconvBase, OpcodeEnum::kAconvVxv, SourceOpEnum::kVs3);
EXPECT_EQ(v_src->AsString(), "v8");
EXPECT_EQ(v_src->size(), 8);
@@ -691,13 +691,13 @@
}
TEST_F(KelvinEncodingTest, KelvinEncodeVs2) {
- auto *v_src = EncodeOpHelper<RV32VectorSourceOperand>(
+ auto* v_src = EncodeOpHelper<RV32VectorSourceOperand>(
kVAddBase, OpcodeEnum::kVaddBVv, SourceOpEnum::kVs2);
EXPECT_EQ(v_src->size(), 1);
EXPECT_EQ(v_src->AsString(), "v0");
delete v_src;
- auto *src = EncodeOpHelper<RV32SourceOperand>(
+ auto* src = EncodeOpHelper<RV32SourceOperand>(
kVAddBase | 0b10, OpcodeEnum::kVaddBVx, SourceOpEnum::kVs2);
EXPECT_EQ(src->AsString(), "zero");
delete src;
diff --git a/sim/test/kelvin_log_instructions_test.cc b/sim/test/kelvin_log_instructions_test.cc
index fa3f842..e43e89e 100644
--- a/sim/test/kelvin_log_instructions_test.cc
+++ b/sim/test/kelvin_log_instructions_test.cc
@@ -40,7 +40,7 @@
constexpr char kHelloString[] = "Hello World!\n";
// Initialize memory.
- auto *db = state_->db_factory()->Allocate<char>(sizeof(kHelloString));
+ auto* db = state_->db_factory()->Allocate<char>(sizeof(kHelloString));
for (int i = 0; i < sizeof(kHelloString); ++i) {
db->Set<char>(i, kHelloString[i]);
}
@@ -65,7 +65,7 @@
constexpr uint32_t kPrintNum = 2200000000; // a number > INT32_MAX
// Initialize memory.
- auto *db = state_->db_factory()->Allocate<char>(sizeof(kFormatString));
+ auto* db = state_->db_factory()->Allocate<char>(sizeof(kFormatString));
for (int i = 0; i < sizeof(kFormatString); ++i) {
db->Set<char>(i, kFormatString[i]);
}
@@ -102,7 +102,7 @@
constexpr int32_t kPrintNum = -1337;
// Initialize memory.
- auto *db = state_->db_factory()->Allocate<char>(sizeof(kFormatString));
+ auto* db = state_->db_factory()->Allocate<char>(sizeof(kFormatString));
for (int i = 0; i < sizeof(kFormatString); ++i) {
db->Set<char>(i, kFormatString[i]);
}
@@ -139,7 +139,7 @@
constexpr uint32_t kCharStream[] = {0x6c6c6548, 0x0000006f}; // "Hello"
// Initialize memory.
- auto *db = state_->db_factory()->Allocate<char>(sizeof(kFormatString));
+ auto* db = state_->db_factory()->Allocate<char>(sizeof(kFormatString));
for (int i = 0; i < sizeof(kFormatString); ++i) {
db->Set<char>(i, kFormatString[i]);
}
@@ -179,7 +179,7 @@
constexpr uint32_t kPrintNum = 0xbaddecaf;
// Initialize memory.
- auto *db = state_->db_factory()->Allocate<char>(sizeof(kFormatString));
+ auto* db = state_->db_factory()->Allocate<char>(sizeof(kFormatString));
for (int i = 0; i < sizeof(kFormatString); ++i) {
db->Set<char>(i, kFormatString[i]);
}
@@ -189,7 +189,7 @@
CreateInstruction(), CreateInstruction(), CreateInstruction()};
// Also store the kCharStream elsewhere in the memory.
- auto *str_db = state_->db_factory()->Allocate<uint32_t>(sizeof(1));
+ auto* str_db = state_->db_factory()->Allocate<uint32_t>(sizeof(1));
str_db->Set<uint32_t>(0, kCharStream);
str_db->DecRef();
diff --git a/sim/test/kelvin_top_test.cc b/sim/test/kelvin_top_test.cc
index 3d9a956..e4595b8 100644
--- a/sim/test/kelvin_top_test.cc
+++ b/sim/test/kelvin_top_test.cc
@@ -85,9 +85,9 @@
}
uint32_t entry_point_;
- KelvinTop *kelvin_top_ = nullptr;
- ElfProgramLoader *loader_ = nullptr;
- FlatDemandMemory *memory_ = nullptr;
+ KelvinTop* kelvin_top_ = nullptr;
+ ElfProgramLoader* loader_ = nullptr;
+ FlatDemandMemory* memory_ = nullptr;
};
// Check the max memory size
@@ -435,7 +435,7 @@
EXPECT_EQ(kelvin_top_->WriteRegister("x32", word_value).code(),
absl::StatusCode::kNotFound);
// Aliases.
- for (auto &[name, alias] : {std::tuple<std::string, std::string>{"x1", "ra"},
+ for (auto& [name, alias] : {std::tuple<std::string, std::string>{"x1", "ra"},
{"x4", "tp"},
{"x8", "s0"}}) {
uint32_t write_value = 0xba5eba11;
@@ -453,7 +453,7 @@
// CSRs that diverge from stock values in MPACT.
constexpr uint32_t kMisaValue = 0x40801100;
- for (auto &[name, expected_value] :
+ for (auto& [name, expected_value] :
{std::tuple<std::string, uint32_t>{"misa", kMisaValue}}) {
auto result = kelvin_top_->ReadRegister(name);
EXPECT_OK(result.status());
@@ -525,9 +525,9 @@
}
uint32_t entry_point_;
- KelvinTop *kelvin_top_ = nullptr;
- ElfProgramLoader *loader_ = nullptr;
- uint8_t *memory_blocks_[kNumMemoryBlocks] = {nullptr};
+ KelvinTop* kelvin_top_ = nullptr;
+ ElfProgramLoader* loader_ = nullptr;
+ uint8_t* memory_blocks_[kNumMemoryBlocks] = {nullptr};
uint64_t memory_size_;
};
diff --git a/sim/test/kelvin_vector_convolution_instructions_test.cc b/sim/test/kelvin_vector_convolution_instructions_test.cc
index 8dbefe6..f673305 100644
--- a/sim/test/kelvin_vector_convolution_instructions_test.cc
+++ b/sim/test/kelvin_vector_convolution_instructions_test.cc
@@ -94,15 +94,15 @@
AppendVectorRegisterOperands(instruction.get(), 1, 3, kVs3, {},
false /* widen_dst*/, {});
if (kWriteAcc) {
- std::vector<kelvin::sim::test::RegisterBase *> reg_vec;
+ std::vector<kelvin::sim::test::RegisterBase*> reg_vec;
for (int i = 0; i < 4; i++) {
auto reg_name = absl::StrCat("v", kVd + i);
reg_vec.push_back(
state_->GetRegister<kelvin::sim::test::RVVectorRegister>(reg_name)
.first);
}
- auto *op = new kelvin::sim::test::RV32VectorDestinationOperand(
- absl::Span<kelvin::sim::test::RegisterBase *>(reg_vec), 0,
+ auto* op = new kelvin::sim::test::RV32VectorDestinationOperand(
+ absl::Span<kelvin::sim::test::RegisterBase*>(reg_vec), 0,
absl::StrCat("v", kVd));
instruction->AppendDestination(op);
}
@@ -314,10 +314,10 @@
private:
bool execution_fail_;
- std::function<bool(bool, uint64_t, uint64_t, uint64_t, const Instruction *)>
+ std::function<bool(bool, uint64_t, uint64_t, uint64_t, const Instruction*)>
trap_call_back_ = [this](bool is_interrupt, uint64_t trap_value,
uint64_t exception_code, uint64_t epc,
- const Instruction *instruction) {
+ const Instruction* instruction) {
auto code =
static_cast<mpact::sim::riscv::ExceptionCode>(exception_code);
if (code == mpact::sim::riscv::ExceptionCode::kIllegalInstruction) {
diff --git a/sim/test/kelvin_vector_instructions_test.cc b/sim/test/kelvin_vector_instructions_test.cc
index 652181a..e430af5 100644
--- a/sim/test/kelvin_vector_instructions_test.cc
+++ b/sim/test/kelvin_vector_instructions_test.cc
@@ -282,7 +282,7 @@
int64_t vs2_ext = static_cast<int64_t>(vs2);
return static_cast<Vd>(vs1_ext + vs2_ext);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVAdd<Vd>(scalar, strip_mine, inst);
}
};
@@ -298,7 +298,7 @@
int64_t vs2_ext = static_cast<int64_t>(vs2);
return static_cast<Vd>(vs1_ext - vs2_ext);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVSub<Vd>(scalar, strip_mine, inst);
}
};
@@ -314,7 +314,7 @@
int64_t vs2_ext = static_cast<int64_t>(vs2);
return static_cast<Vd>(vs2_ext - vs1_ext);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVRSub<Vd>(scalar, strip_mine, inst);
}
};
@@ -326,7 +326,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VEqOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 == vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVEq<Vd>(scalar, strip_mine, inst);
}
};
@@ -338,7 +338,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VNeOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 != vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVNe<Vd>(scalar, strip_mine, inst);
}
};
@@ -350,7 +350,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VLtOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 < vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVLt<Vd>(scalar, strip_mine, inst);
}
};
@@ -367,7 +367,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VLeOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 <= vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVLe<Vd>(scalar, strip_mine, inst);
}
};
@@ -384,7 +384,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VGtOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 > vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVGt<Vd>(scalar, strip_mine, inst);
}
};
@@ -401,7 +401,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VGeOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 >= vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVGe<Vd>(scalar, strip_mine, inst);
}
};
@@ -423,7 +423,7 @@
auto result = vs1_ext > vs2_ext ? vs1_ext - vs2_ext : vs2_ext - vs1_ext;
return static_cast<Vd>(result);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVAbsd<Vs1>(scalar, strip_mine, inst);
}
};
@@ -442,7 +442,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VMaxOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return std::max(vs1, vs2); }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVMax<Vd>(scalar, strip_mine, inst);
}
};
@@ -459,7 +459,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VMinOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return std::min(vs1, vs2); }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVMin<Vd>(scalar, strip_mine, inst);
}
};
@@ -481,7 +481,7 @@
int64_t vd_ext = static_cast<int64_t>(vd);
return static_cast<Vd>(vd_ext + vs1_ext + vs2_ext);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVAdd3<Vd>(scalar, strip_mine, inst);
}
};
@@ -500,7 +500,7 @@
std::max<int64_t>(std::numeric_limits<Vd>::min(), sum),
std::numeric_limits<Vd>::max());
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVAdds<Vd>(scalar, strip_mine, inst);
}
};
@@ -516,7 +516,7 @@
uint64_t sum = static_cast<uint64_t>(vs1) + static_cast<uint64_t>(vs2);
return std::min<uint64_t>(std::numeric_limits<Vd>::max(), sum);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVAddsu<Vd>(scalar, strip_mine, inst);
}
};
@@ -536,7 +536,7 @@
std::max<int64_t>(std::numeric_limits<Vd>::min(), sub),
std::numeric_limits<Vd>::max());
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVSubs<Vd>(scalar, strip_mine, inst);
}
};
@@ -549,7 +549,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VSubsuOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 < vs2 ? 0 : vs1 - vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVSubsu<Vd>(scalar, strip_mine, inst);
}
};
@@ -564,7 +564,7 @@
static Vd Op(Vs1 vs1, Vs2 vs2) {
return static_cast<Vd>(vs1) + static_cast<Vd>(vs2);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVAddw<Vd, Vs1>(scalar, strip_mine, inst);
}
};
@@ -585,7 +585,7 @@
static Vd Op(Vs1 vs1, Vs2 vs2) {
return static_cast<Vd>(vs1) - static_cast<Vd>(vs2);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVSubw<Vd, Vs1>(scalar, strip_mine, inst);
}
};
@@ -608,7 +608,7 @@
int64_t vs2_ext = static_cast<int64_t>(vs2);
return static_cast<Vd>(vs1_ext + vs2_ext);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVAcc<Vd, Vs2>(scalar, strip_mine, inst);
}
};
@@ -628,8 +628,8 @@
static std::pair<T, T> PairwiseOpArgsGetter(
int num_ops, int op_num, int dest_reg_sub_index, int element_index,
int vd_size, bool widen_dst, int src1_widen_factor, int vs1_size,
- const std::vector<T> &vs1_value, int vs2_size, bool s2_scalar,
- const std::vector<T> &vs2_value, T rs2_value, bool halftype_op,
+ const std::vector<T>& vs1_value, int vs2_size, bool s2_scalar,
+ const std::vector<T>& vs2_value, T rs2_value, bool halftype_op,
bool vmvp_op) {
int start_index = (op_num * vs1_size) + (2 * element_index);
if (dest_reg_sub_index == 0) {
@@ -645,7 +645,7 @@
static Vd Op(Vs1 vs1, Vs2 vs2) {
return static_cast<Vd>(vs1) + static_cast<Vd>(vs2);
}
- static void KelvinOp(bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool strip_mine, Instruction* inst) {
KelvinVPadd<Vd, Vs2>(strip_mine, inst);
}
};
@@ -666,7 +666,7 @@
static Vd Op(Vs1 vs1, Vs2 vs2) {
return static_cast<Vd>(vs1) - static_cast<Vd>(vs2);
}
- static void KelvinOp(bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool strip_mine, Instruction* inst) {
KelvinVPsub<Vd, Vs2>(strip_mine, inst);
}
};
@@ -693,7 +693,7 @@
return static_cast<Vd>(
(static_cast<uint64_t>(vs1) + static_cast<uint64_t>(vs2)) >> 1);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVHadd<Vd>(scalar, strip_mine, false /* round */, inst);
}
};
@@ -718,7 +718,7 @@
return static_cast<Vd>(
(static_cast<uint64_t>(vs1) + static_cast<uint64_t>(vs2) + 1) >> 1);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVHadd<Vd>(scalar, strip_mine, true /* round */, inst);
}
};
@@ -743,7 +743,7 @@
return static_cast<Vd>(
(static_cast<uint64_t>(vs1) - static_cast<uint64_t>(vs2)) >> 1);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVHsub<Vd>(scalar, strip_mine, false /* round */, inst);
}
};
@@ -768,7 +768,7 @@
return static_cast<Vd>(
(static_cast<uint64_t>(vs1) - static_cast<uint64_t>(vs2) + 1) >> 1);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVHsub<Vd>(scalar, strip_mine, true /* round */, inst);
}
};
@@ -785,7 +785,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VAndOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 & vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVAnd<Vd>(scalar, strip_mine, inst);
}
};
@@ -798,7 +798,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VOrOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 | vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVOr<Vd>(scalar, strip_mine, inst);
}
};
@@ -811,7 +811,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VXorOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 ^ vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVXor<Vd>(scalar, strip_mine, inst);
}
};
@@ -824,7 +824,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VSllOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 << (vs2 & (sizeof(Vd) * 8 - 1)); }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVSll<Vd>(scalar, strip_mine, inst);
}
};
@@ -837,7 +837,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VSrlOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 >> (vs2 & (sizeof(Vd) * 8 - 1)); }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVSrl<Vd>(scalar, strip_mine, inst);
}
};
@@ -850,7 +850,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VSraOp {
static Vd Op(Vs1 vs1, Vs2 vs2) { return vs1 >> (vs2 & (sizeof(Vd) * 8 - 1)); }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVSra<Vd>(scalar, strip_mine, inst);
}
};
@@ -874,7 +874,7 @@
if (count & 16) r = ((r & 0x0000FFFF) << 16) | ((r & 0xFFFF0000) >> 16);
return r;
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVRev<Vd>(scalar, strip_mine, inst);
}
};
@@ -896,7 +896,7 @@
}
return r;
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVRor<Vd>(scalar, strip_mine, inst);
}
};
@@ -911,7 +911,7 @@
template <typename T>
struct VMvpOp {
static T Op(T vs1, T vs2) { return vs1; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVMvp<T>(scalar, strip_mine, inst);
}
};
@@ -1020,7 +1020,7 @@
}
static void KelvinOp(bool round, bool scalar, bool strip_mine,
- Instruction *inst) {
+ Instruction* inst) {
KelvinVShift<Vd>(round, scalar, strip_mine, inst);
}
};
@@ -1034,7 +1034,7 @@
template <typename Vd, typename Vs>
struct VNotOp {
static Vd Op(Vs vs) { return ~vs; }
- static void KelvinOp(bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool strip_mine, Instruction* inst) {
KelvinVNot<Vs>(strip_mine, inst);
}
};
@@ -1058,7 +1058,7 @@
}
return n;
}
- static void KelvinOp(bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool strip_mine, Instruction* inst) {
KelvinVClb<Vs>(strip_mine, inst);
}
};
@@ -1080,7 +1080,7 @@
}
return n;
}
- static void KelvinOp(bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool strip_mine, Instruction* inst) {
KelvinVClz<Vs>(strip_mine, inst);
}
};
@@ -1094,7 +1094,7 @@
template <typename Vd, typename Vs>
struct VCpopOp {
static Vd Op(Vs vs) { return absl::popcount(vs); }
- static void KelvinOp(bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool strip_mine, Instruction* inst) {
KelvinVCpop<Vs>(strip_mine, inst);
}
};
@@ -1108,7 +1108,7 @@
template <typename Vd, typename Vs>
struct VMvOp {
static Vd Op(Vs vs) { return vs; }
- static void KelvinOp(bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool strip_mine, Instruction* inst) {
KelvinVMv<Vs>(strip_mine, inst);
}
};
@@ -1137,7 +1137,7 @@
if (zero) return 0;
return res;
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVSrans<Vd, Vs1>(kNonRounding, scalar, strip_mine, inst);
}
};
@@ -1169,7 +1169,7 @@
if (zero) return 0;
return res;
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVSrans<Vd, Vs1>(kIsRounding, scalar, strip_mine, inst);
}
};
@@ -1202,7 +1202,7 @@
return static_cast<Vd>(static_cast<uint64_t>(vs1) *
static_cast<uint64_t>(vs2));
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVMul<Vd>(scalar, strip_mine, inst);
}
};
@@ -1226,7 +1226,7 @@
m = std::min(static_cast<uint64_t>(std::numeric_limits<Vd>::max()), m);
return m;
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVMuls<Vd>(scalar, strip_mine, inst);
}
};
@@ -1245,7 +1245,7 @@
static Vd Op(Vs1 vs1, Vs2 vs2) {
return static_cast<Vd>(vs1) * static_cast<Vd>(vs2);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVMulw<Vd, Vs1>(scalar, strip_mine, inst);
}
};
@@ -1273,7 +1273,7 @@
uint64_t result = static_cast<uint64_t>(vs1) * static_cast<uint64_t>(vs2);
return result >> n;
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVMulh<Vd>(scalar, strip_mine, false /* round */, inst);
}
};
@@ -1302,7 +1302,7 @@
result += 1ull << (n - 1);
return result >> n;
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVMulh<Vd>(scalar, strip_mine, true /* round */, inst);
}
};
@@ -1341,7 +1341,7 @@
static Vd Op(Vs1 vs1, Vs2 vs2) {
return KelvinVDmulhHelper<Vd>(kNonRounding, false /* round_neg*/, vs1, vs2);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVDmulh<Vd>(scalar, strip_mine, kNonRounding, false /* round_neg*/,
inst);
}
@@ -1352,7 +1352,7 @@
static Vd Op(Vs1 vs1, Vs2 vs2) {
return KelvinVDmulhHelper<Vd>(kIsRounding, false /* round_neg*/, vs1, vs2);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVDmulh<Vd>(scalar, strip_mine, kIsRounding, false /* round_neg*/,
inst);
}
@@ -1363,7 +1363,7 @@
static Vd Op(Vs1 vs1, Vs2 vs2) {
return KelvinVDmulhHelper<Vd>(kIsRounding, true /* round_neg*/, vs1, vs2);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVDmulh<Vd>(scalar, strip_mine, kIsRounding, true /* round_neg*/,
inst);
}
@@ -1388,7 +1388,7 @@
return static_cast<int64_t>(vd) +
static_cast<int64_t>(vs1) * static_cast<int64_t>(vs2);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVMacc<Vd>(scalar, strip_mine, inst);
}
};
@@ -1404,7 +1404,7 @@
return static_cast<int64_t>(vs1) +
static_cast<int64_t>(vd) * static_cast<int64_t>(vs2);
}
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVMadd<Vd>(scalar, strip_mine, inst);
}
};
@@ -1418,8 +1418,8 @@
static std::pair<T, T> SlidenArgsGetter(
bool horizontal, int index, int num_ops, int op_num, int dest_reg_sub_index,
int element_index, int vd_size, bool widen_dst, int src1_widen_factor,
- int vs1_size, const std::vector<T> &vs1_value, int vs2_size, bool s2_scalar,
- const std::vector<T> &vs2_value, T rs2_value, bool halftype_op,
+ int vs1_size, const std::vector<T>& vs1_value, int vs2_size, bool s2_scalar,
+ const std::vector<T>& vs2_value, T rs2_value, bool halftype_op,
bool vmvp_op) {
assert(!s2_scalar && !halftype_op && !vmvp_op && dest_reg_sub_index == 0);
@@ -1458,7 +1458,7 @@
struct VSlidehnOp {
static constexpr auto kArgsGetter = SlidenArgsGetter<T>;
static T Op(T vs1, T vs2) { return vs1; }
- static void KelvinOp(int index, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(int index, bool strip_mine, Instruction* inst) {
KelvinVSlidehn<T>(index, inst);
}
};
@@ -1472,7 +1472,7 @@
struct VSlidevnOp {
static constexpr auto kArgsGetter = SlidenArgsGetter<T>;
static T Op(T vs1, T vs2) { return vs1; }
- static void KelvinOp(int index, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(int index, bool strip_mine, Instruction* inst) {
KelvinVSlidevn<T>(index, strip_mine, inst);
}
};
@@ -1532,7 +1532,7 @@
struct VSlidehpOp {
static constexpr auto kArgsGetter = SlidepArgsGetter<T>;
static T Op(T vs1, T vs2) { return vs1; }
- static void KelvinOp(int index, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(int index, bool strip_mine, Instruction* inst) {
KelvinVSlidehp<T>(index, inst);
}
};
@@ -1546,7 +1546,7 @@
struct VSlidevpOp {
static constexpr auto kArgsGetter = SlidepArgsGetter<T>;
static T Op(T vs1, T vs2) { return vs1; }
- static void KelvinOp(int index, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(int index, bool strip_mine, Instruction* inst) {
KelvinVSlidevp<T>(index, strip_mine, inst);
}
};
@@ -1565,7 +1565,7 @@
template <typename Vd, typename Vs1, typename Vs2>
struct VSelOp {
static Vd Op(Vd vd, Vs1 vs1, Vs2 vs2) { return vs1 & 1 ? vd : vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVSel<Vd>(scalar, strip_mine, inst);
}
};
@@ -1578,8 +1578,8 @@
static std::pair<T, T> EvnOddOpArgsGetter(
int num_ops, int op_num, int dest_reg_sub_index, int element_index,
int vd_size, bool widen_dst, int src1_widen_factor, int vs1_size,
- const std::vector<T> &vs1_value, int vs2_size, bool s2_scalar,
- const std::vector<T> &vs2_value, T rs2_value, bool halftype_op,
+ const std::vector<T>& vs1_value, int vs2_size, bool s2_scalar,
+ const std::vector<T>& vs2_value, T rs2_value, bool halftype_op,
bool vmvp_op) {
const int combined_element_index = (op_num * vs1_size + element_index) * 2;
const int elts_per_src = num_ops * vs1_size;
@@ -1602,7 +1602,7 @@
struct VEvnOp {
static constexpr auto kArgsGetter = EvnOddOpArgsGetter<T>;
static T Op(T vs1, T vs2) { return vs1; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVEvn<T>(scalar, strip_mine, inst);
}
};
@@ -1614,7 +1614,7 @@
struct VOddOp {
static constexpr auto kArgsGetter = EvnOddOpArgsGetter<T>;
static T Op(T vs1, T vs2) { return vs2; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVOdd<T>(scalar, strip_mine, inst);
}
};
@@ -1626,7 +1626,7 @@
struct VEvnoddOp {
static constexpr auto kArgsGetter = EvnOddOpArgsGetter<T>;
static T Op(T vs1, T vs2) { return vs1; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVEvnodd<T>(scalar, strip_mine, inst);
}
};
@@ -1640,8 +1640,8 @@
static std::pair<T, T> ZipOpArgsGetter(
int num_ops, int op_num, int dest_reg_sub_index, int element_index,
int vd_size, bool widen_dst, int src1_widen_factor, int vs1_size,
- const std::vector<T> &vs1_value, int vs2_size, bool s2_scalar,
- const std::vector<T> &vs2_value, T rs2_value, bool halftype_op,
+ const std::vector<T>& vs1_value, int vs2_size, bool s2_scalar,
+ const std::vector<T>& vs2_value, T rs2_value, bool halftype_op,
bool vmvp_op) {
auto src_index = (op_num * vs1_size + element_index +
dest_reg_sub_index * vs1_size * num_ops) /
@@ -1660,7 +1660,7 @@
struct VZipOp {
static constexpr auto kArgsGetter = ZipOpArgsGetter<T>;
static T Op(T vs1, T vs2) { return vs1; }
- static void KelvinOp(bool scalar, bool strip_mine, Instruction *inst) {
+ static void KelvinOp(bool scalar, bool strip_mine, Instruction* inst) {
KelvinVZip<T>(scalar, strip_mine, inst);
}
};
diff --git a/sim/test/kelvin_vector_instructions_test_base.h b/sim/test/kelvin_vector_instructions_test_base.h
index 8141ef7..6b191e6 100644
--- a/sim/test/kelvin_vector_instructions_test_base.h
+++ b/sim/test/kelvin_vector_instructions_test_base.h
@@ -75,7 +75,7 @@
state_ =
new KelvinState("test", mpact::sim::riscv::RiscVXlen::RV32, memory_);
// Initialize a portion of memory with a known pattern.
- auto *db = state_->db_factory()->Allocate(8192);
+ auto* db = state_->db_factory()->Allocate(8192);
auto span = db->Get<uint8_t>();
for (int i = 0; i < 8192; i++) {
span[i] = i & 0xff;
@@ -116,8 +116,8 @@
static std::pair<Vs1, Vs2> CommonBinaryOpArgsGetter(
int num_ops, int op_num, int dest_reg_sub_index, int element_index,
int vd_size, bool widen_dst, int src1_widen_factor, int vs1_size,
- const std::vector<Vs1> &vs1_value, int vs2_size, bool s2_scalar,
- const std::vector<Vs2> &vs2_value, Vs2 rs2_value, bool halftype_op,
+ const std::vector<Vs1>& vs1_value, int vs2_size, bool s2_scalar,
+ const std::vector<Vs2>& vs2_value, Vs2 rs2_value, bool halftype_op,
bool vmvp_op) {
auto src1_element_index =
op_num * vs1_size + element_index * sizeof(Vd) / sizeof(Vs1);
@@ -395,7 +395,7 @@
// Fill the span with random values.
template <typename T>
void FillArrayWithRandomValues(absl::Span<T> span) {
- for (auto &val : span) {
+ for (auto& val : span) {
val = RandomValue<T>();
}
}
@@ -406,9 +406,9 @@
template <typename T>
void SetVectorRegisterValues(
absl::Span<const std::tuple<std::string, Span<const T>>> values) {
- for (auto &[vreg_name, span] : values) {
- auto *vreg = state_->GetRegister<RVVectorRegister>(vreg_name).first;
- auto *db = state_->db_factory()->MakeCopyOf(vreg->data_buffer());
+ for (auto& [vreg_name, span] : values) {
+ auto* vreg = state_->GetRegister<RVVectorRegister>(vreg_name).first;
+ auto* db = state_->db_factory()->MakeCopyOf(vreg->data_buffer());
db->template Set<T>(span);
vreg->SetDataBuffer(db);
db->DecRef();
@@ -419,9 +419,9 @@
template <typename T, typename RegisterType = RV32Register>
void SetRegisterValues(
absl::Span<const std::tuple<std::string, const T>> values) {
- for (auto &[reg_name, value] : values) {
- auto *reg = state_->GetRegister<RegisterType>(reg_name).first;
- auto *db =
+ for (auto& [reg_name, value] : values) {
+ auto* reg = state_->GetRegister<RegisterType>(reg_name).first;
+ auto* db =
state_->db_factory()->Allocate<typename RegisterType::ValueType>(1);
db->template Set<T>(0, value);
reg->SetDataBuffer(db);
@@ -431,28 +431,28 @@
// Creates source and destination scalar register operands for the registers
// named in the two vectors and appends them to the given instruction.
- void AppendRegisterOperands(Instruction *inst,
+ void AppendRegisterOperands(Instruction* inst,
absl::Span<const std::string> sources,
absl::Span<const std::string> destinations) {
- for (auto ®_name : sources) {
- auto *reg = state_->GetRegister<RV32Register>(reg_name).first;
+ for (auto& reg_name : sources) {
+ auto* reg = state_->GetRegister<RV32Register>(reg_name).first;
inst->AppendSource(reg->CreateSourceOperand());
}
- for (auto ®_name : destinations) {
- auto *reg = state_->GetRegister<RV32Register>(reg_name).first;
+ for (auto& reg_name : destinations) {
+ auto* reg = state_->GetRegister<RV32Register>(reg_name).first;
inst->AppendDestination(reg->CreateDestinationOperand(0));
}
}
// Creates source and destination scalar register operands for the registers
// named in the two vectors and appends them to the given instruction.
- void AppendVectorRegisterOperands(Instruction *inst, const uint32_t num_ops,
+ void AppendVectorRegisterOperands(Instruction* inst, const uint32_t num_ops,
int src1_widen_factor, int src1_reg,
absl::Span<const int> other_sources,
bool widen_dst,
absl::Span<const int> destinations) {
{
- std::vector<RegisterBase *> reg_vec;
+ std::vector<RegisterBase*> reg_vec;
auto regs_count = src1_widen_factor * num_ops;
for (int i = 0; (i < regs_count) && (i + src1_reg < kNumVectorRegister);
i++) {
@@ -460,23 +460,23 @@
reg_vec.push_back(
state_->GetRegister<RVVectorRegister>(reg_name).first);
}
- auto *op = new RV32VectorSourceOperand(
- absl::Span<RegisterBase *>(reg_vec), absl::StrCat("v", src1_reg));
+ auto* op = new RV32VectorSourceOperand(absl::Span<RegisterBase*>(reg_vec),
+ absl::StrCat("v", src1_reg));
inst->AppendSource(op);
}
- for (auto ®_no : other_sources) {
- std::vector<RegisterBase *> reg_vec;
+ for (auto& reg_no : other_sources) {
+ std::vector<RegisterBase*> reg_vec;
for (int i = 0; (i < num_ops) && (i + reg_no < kNumVectorRegister); i++) {
std::string reg_name = absl::StrCat("v", i + reg_no);
reg_vec.push_back(
state_->GetRegister<RVVectorRegister>(reg_name).first);
}
- auto *op = new RV32VectorSourceOperand(
- absl::Span<RegisterBase *>(reg_vec), absl::StrCat("v", reg_no));
+ auto* op = new RV32VectorSourceOperand(absl::Span<RegisterBase*>(reg_vec),
+ absl::StrCat("v", reg_no));
inst->AppendSource(op);
}
- for (auto ®_no : destinations) {
- std::vector<RegisterBase *> reg_vec;
+ for (auto& reg_no : destinations) {
+ std::vector<RegisterBase*> reg_vec;
auto regs_count = widen_dst ? num_ops * 2 : num_ops;
for (int i = 0; (i < regs_count) && (i + reg_no < kNumVectorRegister);
i++) {
@@ -484,25 +484,25 @@
reg_vec.push_back(
state_->GetRegister<RVVectorRegister>(reg_name).first);
}
- auto *op = new RV32VectorDestinationOperand(
- absl::Span<RegisterBase *>(reg_vec), 0, absl::StrCat("v", reg_no));
+ auto* op = new RV32VectorDestinationOperand(
+ absl::Span<RegisterBase*>(reg_vec), 0, absl::StrCat("v", reg_no));
inst->AppendDestination(op);
}
}
- using InstructionPtr = std::unique_ptr<Instruction, void (*)(Instruction *)>;
+ using InstructionPtr = std::unique_ptr<Instruction, void (*)(Instruction*)>;
InstructionPtr CreateInstruction() {
InstructionPtr inst(new Instruction(next_instruction_address_, state_),
- [](Instruction *inst) { inst->DecRef(); });
+ [](Instruction* inst) { inst->DecRef(); });
inst->set_size(4);
next_instruction_address_ += 4;
return inst;
}
- RVVectorRegister *vreg_[kNumVectorRegister];
- RV32Register *xreg_[32];
- KelvinState *state_;
- FlatDemandMemory *memory_;
+ RVVectorRegister* vreg_[kNumVectorRegister];
+ RV32Register* xreg_[32];
+ KelvinState* state_;
+ FlatDemandMemory* memory_;
absl::BitGen bitgen_;
uint32_t next_instruction_address_ = kInstAddress;
};
diff --git a/sim/test/kelvin_vector_memory_instructions_test.cc b/sim/test/kelvin_vector_memory_instructions_test.cc
index 9ad8bc6..c319524 100644
--- a/sim/test/kelvin_vector_memory_instructions_test.cc
+++ b/sim/test/kelvin_vector_memory_instructions_test.cc
@@ -61,7 +61,7 @@
bool is_uncached = false) {
InstructionPtr child_instruction(
new Instruction(next_instruction_address_, state_),
- [](Instruction *inst) { inst->DecRef(); });
+ [](Instruction* inst) { inst->DecRef(); });
child_instruction->set_size(4);
auto instruction = CreateInstruction();
@@ -257,7 +257,7 @@
if (post_increment) {
// Check rs1 value.
- auto *reg = state_
+ auto* reg = state_
->GetRegister<kelvin::sim::test::RV32Register>(
kelvin::sim::test::kRs1Name)
.first;
@@ -416,7 +416,7 @@
template <typename T>
T GetDefaultMemoryValue(int address) {
T value = 0;
- uint8_t *ptr = reinterpret_cast<uint8_t *>(&value);
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(&value);
for (int j = 0; j < sizeof(T); j++) {
ptr[j] = (address + j) & 0xff;
}
@@ -425,7 +425,7 @@
template <typename T>
T GetSavedMemoryValue(int address) {
- auto *db = state_->db_factory()->Allocate<T>(1);
+ auto* db = state_->db_factory()->Allocate<T>(1);
memory_->Load(address, db, nullptr, nullptr);
T data = db->template Get<T>(0);
db->DecRef();
@@ -574,12 +574,12 @@
for (int element_index = 0; element_index < kVLenInWord;
element_index++) {
if (is_transpose) {
- auto *acc_vec = state_->acc_vec(element_index);
+ auto* acc_vec = state_->acc_vec(element_index);
EXPECT_EQ(vreg_span[element_index], (*acc_vec)[i])
<< absl::StrCat("vreg[", vreg_num, "][", element_index,
"] != acc[", element_index, "][", i, "]");
} else {
- auto *acc_vec = state_->acc_vec(i);
+ auto* acc_vec = state_->acc_vec(i);
EXPECT_EQ(vreg_span[element_index], (*acc_vec)[element_index])
<< absl::StrCat("vreg[", vreg_num, "][", element_index,
"] != acc[", i, "][", element_index, "]");
@@ -633,8 +633,7 @@
auto ref_vreg = vreg_[vref_num];
auto ref_span = ref_vreg->data_buffer()->Get<uint8_t>();
- uint8_t *dwacc_span =
- reinterpret_cast<uint8_t *>(state_->dw_acc_vec(8 * i));
+ uint8_t* dwacc_span = reinterpret_cast<uint8_t*>(state_->dw_acc_vec(8 * i));
for (int element_index = 0; element_index < ref_span.size() / 4;
element_index++) {
EXPECT_EQ(vreg_span[element_index], ref_span[element_index])