Questions tagged [riscv]

For questions related to RISC-V assembler, compiler specifics and HDL (hardware description language) implementation and use. Note: Questions on hardware implementation will be more appropriate for the electronics engineering site: https://electronics.stackexchange.com

Summary

RISC-V (pronounced "risk-five") is an instruction set architecture (ISA) that was originally designed to support computer architecture research and education and is now a standard open architecture for industry implementations under the governance of the RISC-V Foundation. RISC-V was originally developed in the Computer Science Division of the EECS Department at the University of California, Berkeley.

Features

  • A completely open ISA that is freely available to academia and industry.

  • A real ISA suitable for direct native hardware implementation, not just simulation or binary translation.

  • An ISA that avoids "over-architecting" for a particular microarchitecture style (e.g., microcoded, in-order, decoupled, out-of-order) or implementation technology (e.g., full-custom, ASIC, and FPGA), but which allows efficient implementation in any of these.

  • An ISA separated into a small base integer ISA, usable by itself as a base for customized accelerators or for educational purposes, and optional standard extensions, to support general-purpose software development.

  • Support for the revised 2008 IEEE-754 floating-point standard.

  • An ISA supporting extensive user-level ISA extensions and specialized variants.

  • 32-bit, 64-bit, and 128-bit address space variants for applications, operating system kernels, and hardware implementations.

  • An ISA with support for highly-parallel multicore or manycore implementations, including heterogeneous multiprocessors.

  • Optional variable-length instructions to both expand available instruction encoding space and to support an optional dense instruction encoding for improved performance, static code size, and energy efficiency.

  • A fully virtualizable ISA to ease hypervisor development.

  • An ISA that simplifies experiments with new supervisor-level and hypervisor-level ISA designs.

References

1220 questions
5
votes
3 answers

GPL'd RISC-V implementation?

Am I allowed to release a RISC-V implementation (written in VHDL or Verilog) under the GPL-v3? If so, what additional "credit", etc. do I have to give? The FAQ on the RISC-V site says that the ISA spec is licensed with a BSD license, but the BSD…
Leonhart231
  • 182
  • 2
  • 10
5
votes
1 answer

RISC-V RV32I soft float lib calls MUL and MULHU instructions in __muldf3

I'm using current riscv-tools to build a firmware image for the PicoRV32 core. The firmware requires floating point, so I'm using -msoft-float. This are the compiler/linker options I am using: -Os -m32 -march=RV32I -msoft-float -ffreestanding…
CliffordVienna
  • 7,995
  • 1
  • 37
  • 57
4
votes
0 answers

Could array and structures be initialized in a different way?

My question could looks weird, indeed, here's the context: I am currently facing a strange issue, while switching - on the project i'm working on - the core from pulpino to CV32 (some other changes have happend too, for instance about the crt0, like…
Guillaume D
  • 2,202
  • 2
  • 10
  • 37
4
votes
1 answer

RISCV branchless coding

On Intel AVX, there is a possibility of branchless code. Instead of branching for case0 or case1, you can compute both cases, and blend the results based on a condition. AVX does this 8 way for float using the vblendps instruction. You can also do…
Bram
  • 7,440
  • 3
  • 52
  • 94
4
votes
1 answer

How can I resolve RISC-V assembly pseudo instructions to true RISC-V instructions?

I need to build large RISC-V assembly programs (.a/.as/.S files) using a specific toolchain that doesn't support pseudo-instructions. (Synopsys' ASIP designer tool creates a custom assembler for a customized CPU / instruction set.) The programs…
4
votes
0 answers

Why is my RISC-V trap handler called again and again?

I'm writing an operating system (supervisor mode) in Rust for RISC-V in my free time. I'm trying to handle trap now. I'm trapping correctly in direct mode, but when executing the sret instruction, I'm going directly back to my trap handler, without…
Skallwar
  • 73
  • 2
  • 5
4
votes
1 answer

How does qemu-riscv pass the Device Tree Blob to the guest kernel?

How does the default bios (OpenSBI) in qemu-system-riscv pass the Device Tree Blob to a guest? I can see from the documentation for qemu-system-arm 'virt' platform that QEMU passes the address of the Device Tree Blob (dtb) to guests in r0 when using…
ajxs
  • 3,347
  • 2
  • 18
  • 33
4
votes
1 answer

Does RISC-V compressed instructions subset (RVC) always assemble into 32-bit instrucions in binary file?

I am confused. When I assemble compressed instruction subset in the binary file I get the 32-bit instruction, but I thought I would get 16-bit instructions because RVC subset is encoded with 16-bits. Do the instructions from RVC(compressed) subset…
miki1307
  • 147
  • 9
4
votes
2 answers

What is intended/correct way to handle interrupts and use the WFI risc-v cpu instruction?

I am very new to bare metal programming and have never delt with interrupts before, but I've been learning on a RISC-V FE310-G002 SOC powered dev board. I've been reading about the RISC-V WFI (Wait for interrupt) instruction and from the manuals, it…
Echelon X-Ray
  • 138
  • 1
  • 10
4
votes
1 answer

Risc-V: Minimum CSR requirements for simple RV32I implementation capable of leveraging GCC

What would be the bare minimum CSR requirements for a RV32I capable of running machine code generated with GCC? I'm thinking of a simple fpga-based (embedded) implementation. No virtual memory or linux support is required. Also, what GCC flags…
ANum
  • 107
  • 1
  • 9
4
votes
2 answers

Cannot access kernel space when debugging xv6 with QEMU and GDB

I am self-studying the 2019 version of MIT 6.828/6.S081: Operating System Engineering. I was trying to attach GDB to xv6 running on RISC-V using QEMU, to learn about what is going on when context switching happens between user mode and kernel…
4
votes
1 answer

RISCV - How are jump instructions PC-relative?

In the RISC-V Unpriviliged spec V20191213, the following is stated, (page 21) The unconditional jump instructions all use PC-relative addressing to help support position-independent code. Looking at the definition of the JALR instruction, The…
4
votes
1 answer

Why is JALR used instead of JAL for returning from subroutines

I´ve learned that both jal and jalr can be used for calling functions while on the contrary only jal can be used for returning from functions like this: sum3: add a0, a0, a1 add a0, a0, a2 jalr x0, 0(ra) However, this code uses jal…
Tania
  • 51
  • 1
  • 4
4
votes
1 answer

U-Boot with OpenSBI on HiFive Unleashed in QEMU: Store/AMO access fault

I've been trying to get U-Boot to work in QEMU for the sifive_u machine. I've tried using both the built in OpenSBI 'BIOS' and building my own OpenSBI, but I keep running into the same issue. I'm building U-Boot using the riscv64 toolchain from the…
p0llard
  • 439
  • 6
  • 17
4
votes
2 answers

Why $ra is Caller Saved in RISC-V

I find that in RISC-V, ra is caller saved, in MIPS, ra is callee, which means in RISC-V callee can directly change the value in ra without save, but since ra has changed, how callee return back to caller?
Phantom
  • 165
  • 1
  • 8