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) 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
15
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!
31
32/**********************************************************************/
42static inline 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/**********************************************************************/
64static inline uint32_t __attribute__ ((always_inline)) RISCV_INSTR_R4_TYPE(const int opcode, const int funct3, const int funct2, uint32_t rs1, uint32_t rs2, uint32_t rs3) {
65
66 register uint32_t __rd;
67 register uint32_t __rs1 = rs1;
68 register uint32_t __rs2 = rs2;
69 register uint32_t __rs3 = rs3;
70
71 asm volatile (".insn r4 %4, %5, %6, %0, %1, %2, %3" : "=r"(__rd) : "r"(__rs1), "r"(__rs2), "r"(__rs3), "i"(opcode), "i"(funct3), "i"(funct2));
72
73 return __rd;
74}
75
76/**********************************************************************/
85static inline uint32_t __attribute__ ((always_inline)) RISCV_INSTR_I_TYPE(const int opcode, const int funct3, uint32_t rs1, const int imm12) {
86
87 register uint32_t __rd;
88 register uint32_t __rs1 = rs1;
89
90 asm volatile (".insn i %2, %3, %0, %1, %4" : "=r"(__rd) : "r"(__rs1), "i"(opcode), "i"(funct3), "i"(imm12));
91
92 return __rd;
93}
94
95#endif // NEORV32_INTRINSICS_H
Main NEORV32 core library / driver / HAL include file.
static uint32_t RISCV_INSTR_I_TYPE(const int opcode, const int funct3, uint32_t rs1, const int imm12)
Definition neorv32_intrinsics.h:85
static uint32_t RISCV_INSTR_R4_TYPE(const int opcode, const int funct3, const int funct2, uint32_t rs1, uint32_t rs2, uint32_t rs3)
Definition neorv32_intrinsics.h:64
static 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