File riscv.h
File List > include > simtix > riscv.h
Go to the documentation of this file
#pragma once
#include <stdint.h>
namespace simtix {
namespace riscv {
enum CSR : uint16_t {
// clang-format off
// RISCV CSRs
MCYCLE = 0xb00,
MINSTRET = 0xb02,
MEPC = 0x341,
MCAUSE = 0x342,
MTVAL = 0x343,
MVENDORID = 0xf11,
MARCHID = 0xf12,
MHARTID = 0xf14,
HPMCOUNTER3 = 0xc03,
// Custom CSRs
// Per-core
XCID = 0xfc0,
XNW = 0xfc1,
XCLGSX = 0xfc2,
XCLGSY = 0xfc3,
XCLGSZ = 0xfc4,
XCLGOFFX = 0xfc5,
XCLGOFFY = 0xfc6,
XCLGOFFZ = 0xfc7,
XCLSX = 0xfc8,
XCLSY = 0xfc9,
XCLSZ = 0xfca,
XCLWX = 0xfcb,
XCLWY = 0xfcc,
XCLWZ = 0xfcd,
XDIM = 0xfce,
XMHARTIDBASE = 0xfcf,
// Per-warp
XWID = 0xfd0,
XNT = 0xfd1,
// Per-thread
XTID = 0xfe0,
XTSTATUS = 0xfe1,
XCLLX = 0xfe2,
XCLLY = 0xfe3,
XCLLZ = 0xfe4,
XKERNELPC = 0xfe5,
XKERNELARG = 0xfe7,
// clang-format on
};
// Floating point rounding mode
enum ROUNDING_MODE : uint8_t {
RNE = 0b000, // Round to nearest, ties to even
RTZ = 0b001, // round towards zero
RDN = 0b010, // round down
RUP = 0b011, // round up
RMM = 0b100, // round to nearest, ties to max
DYN = 0b111 // encoded in instruction `rm` field
};
// Exception Codes
enum Exceptions : uint32_t {
// clang-format off
INSTRUCTION_ADDR_MISALIGNED = 0,
INSTRUCTION_ACCESS_FAULT = 1,
ILLEGAL_INSTRUCTION = 2,
BREAKPOINT = 3,
LOAD_ADDR_MISALIGNED = 4,
LOAD_ACCESS_FAULT = 5,
STORE_ADDR_MISALIGNED = 6,
STORE_ACCESS_FAULT = 7,
ECALL = 11
// clang-format on
};
enum FPExceptions : uint8_t {
NX = 1, // Inexact
UF = 2, // Underflow
OF = 4, // Overflow
DZ = 8, // Divide by zero
NV = 16 // Invalid operation
};
enum RISCV_CONFIG : uint32_t { XLEN = 64 };
inline const char *X_ABI_NAMES[] = {
"zero", "ra", "sp", "gp", "tp", "t0", "t1", "t2", "s0", "s1", "a0",
"a1", "a2", "a3", "a4", "a5", "a6", "a7", "s2", "s3", "s4", "s5",
"s6", "s7", "s8", "s9", "s10", "s11", "t3", "t4", "t5", "t6"};
inline const char *F_ABI_NAMES[] = {
"ft0", "ft1", "ft2", "ft3", "ft4", "ft5", "ft6", "ft7",
"fs0", "fs1", "fa0", "fa1", "fa2", "fa3", "fa4", "fa5",
"fa6", "fa7", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7",
"fs8", "fs9", "fs10", "fs11", "ft8", "ft9", "ft10", "ft11"};
inline const char *RND_NAMES[] = {"rne", "rtz", "rdn", "rup", "rmm"};
} // namespace riscv
} // namespace simtix