| /* |
| * Copyright 2024 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. |
| */ |
| |
| #ifndef MPACT_CHERIOT__RISCV_CHERIOT_I_INSTRUCTIONS_H_ |
| #define MPACT_CHERIOT__RISCV_CHERIOT_I_INSTRUCTIONS_H_ |
| |
| #include "mpact/sim/generic/instruction.h" |
| |
| // This file contains the declarations of the instruction semantic functions |
| // for the RiscV i instructions. The 32 bit instruction versions are in the |
| // RV32 namespace, whereas the 64 bit versions are in the RV64 namespace. |
| // Instructions that are the same across 32 and 64 bits are in the riscv |
| // namespace. |
| |
| namespace mpact { |
| namespace sim { |
| namespace cheriot { |
| |
| using ::mpact::sim::generic::Instruction; |
| |
| void RiscVIllegalInstruction(const Instruction *inst); |
| |
| // No operands necessary for Nop. For now, all hint instructions should be |
| // decoded as Nop. |
| void RiscVINop(const Instruction *instruction); |
| |
| // For the following, source operand 0 refers to the register specified in rs1, |
| // and source operand 1 refers to either the register specified in rs2, or the |
| // immediate. Destination operand 0 refers to the register specified in rd. |
| void RiscVIAdd(const Instruction *instruction); |
| void RiscVISub(const Instruction *instruction); |
| void RiscVISlt(const Instruction *instruction); |
| void RiscVISltu(const Instruction *instruction); |
| void RiscVIAnd(const Instruction *instruction); |
| void RiscVIOr(const Instruction *instruction); |
| void RiscVIXor(const Instruction *instruction); |
| void RiscVISll(const Instruction *instruction); |
| void RiscVISrl(const Instruction *instruction); |
| void RiscVISra(const Instruction *instruction); |
| // For the following semantic function, source operand 0 refers to the |
| // immediate value, and destination 0 the register specified in rd. Note, the |
| // value of the immediate shall be properly shifted. |
| void RiscVILui(const Instruction *instruction); |
| // Source operand 0 contains the immediate value. Destination operand 0 refers |
| // to the pc destination operand, wheras destination operand 1 refers to the |
| // link register specified in rd. |
| void RiscVIBeq(const Instruction *instruction); |
| void RiscVIBne(const Instruction *instruction); |
| void RiscVIBlt(const Instruction *instruction); |
| void RiscVIBltu(const Instruction *instruction); |
| void RiscVIBge(const Instruction *instruction); |
| void RiscVIBgeu(const Instruction *instruction); |
| // Each of the load instructions are modeled by a pair of semantic instruction |
| // functions. The "main" function computes the effective address and initiates |
| // the load, the "child" function processes the load result and writes it back |
| // to the destination register. |
| // For the "main" semantic function, source operand 0 is the base register, |
| // source operand 1 the offset. Destination operand 0 is the register specified |
| // by rd. The "child" semantic function will get a copy of the destination |
| // operand. |
| void RiscVILd(const Instruction *instruction); |
| void RiscVILw(const Instruction *instruction); |
| void RiscVILwChild(const Instruction *instruction); |
| void RiscVILh(const Instruction *instruction); |
| void RiscVILhChild(const Instruction *instruction); |
| void RiscVILhu(const Instruction *instruction); |
| void RiscVILhuChild(const Instruction *instruction); |
| void RiscVILb(const Instruction *instruction); |
| void RiscVILbChild(const Instruction *instruction); |
| void RiscVILbu(const Instruction *instruction); |
| void RiscVILbuChild(const Instruction *instruction); |
| // For each store instruction semantic function, source operand 0 is the base |
| // register, source operand 1 is the offset, while source operand 2 is the value |
| // to be stored referred to by rs2. |
| void RiscVISd(const Instruction *instruction); |
| void RiscVISw(const Instruction *instruction); |
| void RiscVISh(const Instruction *instruction); |
| void RiscVISb(const Instruction *instruction); |
| |
| // The Fence instruction takes a single source operand (index 0) which consists |
| // of an immediate value containing the right justified concatenation of the FM, |
| // predecessor, and successor bit fields of the instruction. |
| void RiscVIFence(const Instruction *instruction); |
| // Ecall and EBreak take no source or destination operands. |
| void RiscVIEcall(const Instruction *instruction); |
| void RiscVIEbreak(const Instruction *instruction); |
| // Trap doesn't implement any specific instruction, but can be called as an |
| // instruction, for instance for unknown instructions. |
| void RiscVITrap(bool is_interrupt, uint32_t cause, Instruction *instruction); |
| |
| } // namespace cheriot |
| } // namespace sim |
| } // namespace mpact |
| |
| #endif // MPACT_CHERIOT__RISCV_CHERIOT_I_INSTRUCTIONS_H_ |