API Reference
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_intrinsics.h
Go to the documentation of this file.
1// ================================================================================ //
2// The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 //
3// Copyright (c) NEORV32 contributors. //
4// Copyright (c) 2020 - 2026 Stephan Nolting. All rights reserved. //
5// Licensed under the BSD-3-Clause license, see LICENSE for details. //
6// SPDX-License-Identifier: BSD-3-Clause //
7// ================================================================================ //
8
16#ifndef NEORV32_INTRINSICS_H
17#define NEORV32_INTRINSICS_H
18
19#include <neorv32.h>
20#include <stdint.h>
21
22/**********************************************************************/
26#define RISCV_OPCODE_CUSTOM0 0b0001011 // RISC-V "CUSTOM-0"
27#define RISCV_OPCODE_CUSTOM1 0b0101011 // RISC-V "CUSTOM-1"
28#define RISCV_OPCODE_OP32 0b0111011 // RISC-V "OP-32", experimental!
29#define RISCV_OPCODE_OPIMM32 0b0011011 // RISC-V "OP-IMM-32", experimental!
32/**********************************************************************/
42inline uint32_t __attribute__ ((always_inline)) RISCV_INSTR_R_TYPE(const int opcode, const int funct3, const int funct7, uint32_t rs1, uint32_t rs2) {
43
44 register uint32_t __rd;
45 register uint32_t __rs1 = rs1;
46 register uint32_t __rs2 = rs2;
47
48 asm volatile (".insn r %3, %4, %5, %0, %1, %2" : "=r"(__rd) : "r"(__rs1), "r"(__rs2), "i"(opcode), "i"(funct3), "i"(funct7));
49
50 return __rd;
51}
52
53/**********************************************************************/
62inline uint32_t __attribute__ ((always_inline)) RISCV_INSTR_I_TYPE(const int opcode, const int funct3, uint32_t rs1, const int imm12) {
63
64 register uint32_t __rd;
65 register uint32_t __rs1 = rs1;
66
67 asm volatile (".insn i %2, %3, %0, %1, %4" : "=r"(__rd) : "r"(__rs1), "i"(opcode), "i"(funct3), "i"(imm12));
68
69 return __rd;
70}
71
72#endif // NEORV32_INTRINSICS_H
Main NEORV32 core library / driver / HAL include file.
uint32_t RISCV_INSTR_I_TYPE(const int opcode, const int funct3, uint32_t rs1, const int imm12)
Definition neorv32_intrinsics.h:62
uint32_t RISCV_INSTR_R_TYPE(const int opcode, const int funct3, const int funct7, uint32_t rs1, uint32_t rs2)
Definition neorv32_intrinsics.h:42