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

Filter by
Sorted by
Tagged with
1 vote
1 answer
29 views

Cannot specify the operands when using inline asm outside a function

My code is unsigned long user_stack_pointer; __asm__( ".global exception_handling_entry\n" "exception_handling_entry:\n" "add %0, sp, x0\n" : "=r&...
maplgebra's user avatar
  • 123
0 votes
1 answer
30 views

Why RISC-V Assembly Error: Runtime Exception - Address Out of Range?

Code: assembly Copy code .data ask1: .string "Please enter a number to compute its factorial value: " msg: .string "The result is: %d\n" # Format for the result .text .globl ...
Cocomelon's user avatar
0 votes
1 answer
24 views

Debugging with LLDB: running commands after a breakpoint/watchnpoint event

I am debugging a risc-v processor and I am using LLDB with On-Chip Debugging trough JTAG. Going straight to the point, I want to write some data through JTAG and I want to do it at a certain point in ...
Sergio Castillo's user avatar
0 votes
0 answers
20 views

Queries regarding RISC-V emulation on QEMU [closed]

I am new to RISC-V emulation and wanted some direction as to how to go about with the development. I am building a simple emulation of a RISC-V system running on QEMU with FreeRTOS. I am following ...
shravan.sukumar's user avatar
4 votes
0 answers
79 views

problem with sending instructions to the Rocket-chip riscv core

I am trying to simulate rocket-chip with rocket core and a RoCC accelerator using chipyard framework. I want to be able to receive a sequence of RoCC instructions, each containing the starting address ...
engineer1155's user avatar
-2 votes
0 answers
31 views

Error when compiling riscv code: cannot execute binary file: Exec format error

I want to learn risc-v assembly and tried the very first "hello world" program but encountered a problem. This is my code: .global _start _start: addi a7, zero, 64 addi a0, zero, 1 ...
Zivglb's user avatar
  • 1
-1 votes
0 answers
44 views

RISC-V Simulator in C

#include <stdio.h> #include <math.h> #include <stdlib.h> // define instruction types (opcode) #define R_TYPE 0x33 // 0b011_0011 #define I_TYPE_ARIT 0x13 // 0b001_0011 #...
song_'s user avatar
  • 1
2 votes
2 answers
71 views

RISC-V architecture, why do one add 4 bytes with no branch but shift with one when branch?

If I understand correctly, when you increment the Program Counter (PC), it needs to be increased by four bytes because all instructions are 32 bits, correct? What confuses me is that I thought the '...
Markus helbæk's user avatar
0 votes
0 answers
37 views

How RISCV architecture suggest to fill mtval register in instruction address fault?

If mtval is written with a nonzero value when a breakpoint, address-misaligned, access-fault, or page-fault exception occurs on an instruction fetch, load, or store, then mtval will contain the ...
Ömer GÜZEL's user avatar
0 votes
1 answer
24 views

How to check if overflow occurs in risc-v addition?

To check overflow after multiplication in RISC-V, we can use mulh and mulhu. But how can one check overflow after add or sub instruction?
user153245's user avatar
0 votes
1 answer
78 views

How to make an unsigned to signed number, and reverse in verilog

I have an school assignment at my university in verilog where i need to create an ALU for a RISC-V processor. In the ALU, i need to perform the operations AND, OR, XOR, sub, add, bitwise left and ...
Dimitris Vagenas's user avatar
0 votes
0 answers
44 views

RISC-V jumps with zero offset

I want to verify my understanding of the RISC-V standard concerning jump commands. For this, I have considered the three following three assembly commands: j 0 j 4 j 8 where j is the jump pseudo-...
Schottky's user avatar
  • 1,591
0 votes
0 answers
36 views

How to implement the Gshare TAGE hybrid predictor combination on the RISC V BOOM core using Chisel

I am working on implementing hybrid branch predictors listed below Gshare + TAGE TAGE + Alpha Perceptron + TAGE Gshare + Alpha Perceptron + Gshare Perceptron + Alpha Perceptron + TAGE + Alpha I ...
albie_01's user avatar
0 votes
0 answers
22 views

In virtual address translation with hypervisor extension, can't Hypervisor's virtual address cache collide with VS-level address translation cache? [closed]

AFAIK, VMID and ASID are attached to TLB entries to distinguish same VA across different VM/processes. While the VM is running, vsatp holds the ASID and hgatp holds the VMID. While the hypervisor (...
j.s.shin's user avatar
0 votes
0 answers
25 views

Running QEMU with support for RISC-V Vector Extensions

I am doing research for my thesis on a topic that requires running QEMU with support for the SVE format. My issue is that I cannot figure out how to find the matching versions of the various tools ...
Stelios Papamichail's user avatar
1 vote
0 answers
43 views

Adding NOP instructions after branches and jumps for control hazards in a 5-stage RISC pipeline without hazard detection?

There is a RISCV (5 stages pipeline 32-bits) If we supose there is no hazard unit nor forwarding support, so I have to add nop instructions. If the branch policy is Branch never taken, so we have to ...
Claudio Rodriguez's user avatar
4 votes
0 answers
73 views

Preventing gcc from FP optimizations spanning over an inline assembly instruction that might change FP math

I am doing some research on RISC-V processors, i have created csr register that changes how the processor does float calculations. Is there any way to create a boundary, so that gcc will perform ...
Stephan Brüning's user avatar
0 votes
0 answers
44 views

Why is RISC-V GCC breaking my code when optimizations are enabled? [duplicate]

I have the following C code for 32-bit RISC-V: static void test(uint32_t key, uint32_t chr, uint32_t state) { char s[2]; if(state != KEYSTATE_PRESSED) { return; } if(!isprint(chr)) { ...
anton-tchekov's user avatar
0 votes
0 answers
17 views

How to test the cross-compiled tensorflow lite?

I want to deploy dnn models on nezha Linux SBC with Xuantie C906 core. I cross-compile the tensorflow lite successfully. export RISCVCC_PREFIX=/home/fcqiao/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2....
fcqiao's user avatar
  • 1
0 votes
0 answers
16 views

How to link libc.a files to clang

When i try to compile a c program using clang frontend, i am getting a error saying: ld.lld: error: unable to find library -lc ld.lld: error: unable to find library -lm ld.lld: error: unable to find ...
Nehal Sangaonkar's user avatar
0 votes
0 answers
36 views

Explain jump table construct in RISC-V assembly

In some disassembly I see jal ra sym.imp.strlen which jumps to a construct which looks like this in radare2: ┌ 128: size_t sym.imp.strlen (const char *s); │ 0x00035b40 172eb600 ...
confusedandsad's user avatar
0 votes
0 answers
26 views

Issues cross-compiling on WSL2 -> RISCV in order to simulate with GEM5

sorry if i'm a newbie and maybe i didn't used the interface properly. I'm developing a project for uni where i have to simulate a RISCV-based OoO CPU executing a C benchmark. As Gem5 have to be ...
Alessandro Di Matteo's user avatar
1 vote
0 answers
19 views

How to decide minimum pmp region for an architecture?

In RISCV architecture, there are pmp registers that define and control the memory regions. It is stated in the spec "Although the PMP mechanism supports regions as small as four bytes, platforms ...
Ömer GÜZEL's user avatar
0 votes
1 answer
91 views

Learning RISC-V assembly and need help converting a C loop

I'm learning how to convert RISC-V assembly code to C, and I don't understand this conversion. A few questions I have: why is t1 being initialized to 6 instead of 0? We're using bne to compare t1 and ...
test1's user avatar
  • 3
0 votes
0 answers
89 views

how to blink an LED using a PWM pin on Debian with C

I have a VisionFive 2 SBC with Debian and I want to blink an LED attached to GPIO46 PWM0 pin using the Linux PWM library with a C program. The goal is to modify an old existing program from a ...
Richard Chambers's user avatar
1 vote
0 answers
60 views

In RISCV Exception/Interrupt Handlers, how to return to the correct privilege mode?

Suppose I have configured all exceptions and interrupts to be handled in machine-mode... How do my machine-mode handlers know to put PRV_U or PRV_M, etc. into mstatus.MPP before executing mret so ...
Lance E.T. Compte's user avatar
0 votes
0 answers
78 views

What features does OpenSBI provide that a DTS does not in an emulated environment?

I have been experimenting with RISC-V emulators, QEMU and mini-rv32ima mainly, and have come across OpenSBI. The project defines itself as: The RISC-V Supervisor Binary Interface (SBI) is the ...
Liam Kelly's user avatar
  • 3,472
-1 votes
0 answers
42 views

I'm building a RISC-V processor and the 'always' block gives me a "build" error, what can I do? [duplicate]

I'm working on a RISC-V processor that has a UART included, and will be impacted in to a FPGA. Everything works fine on testbench. My problem comes when I do apio build before uploading to the FPGA. ...
Segundo Saccani's user avatar
0 votes
0 answers
32 views

Does RISCV SBI refers a hardware implementation or a software standard?

In the RISCV SBI, there are explanations about supervisor and machine communication. As an example, A0-A7 registers are filled with Function and extension ID and also return values for SBI functions. ...
Ömer GÜZEL's user avatar
0 votes
0 answers
47 views

Pipelining stalls and data-forwarding

Assuming no data forwarding, and no hazard detection I've been trying to see if I can optimize this code but since 4 of the 5 statements are data-dependent in some way I keep getting 5 stalls or "...
Tyler's user avatar
  • 1
2 votes
1 answer
101 views

Masking individual rows for CSR SpMV in RISC-V RVV 0.7.1

EDIT: I have reformulated my question into something more productive, and will provide an answer below. The old version of this question is below still. I am implementing an optimized SpMV kernel for ...
Alex's user avatar
  • 163
-1 votes
0 answers
22 views

Invalid filename error for sbt.listes file while running riscv gnu toolchain installation

I've been trying to install riscv gnu toolchain by cloning the repo and then configuring. But while installation it is showing sbt.listes as invalid filename. I've tried proceeding to further steps ...
Manvi Chaudhary's user avatar
0 votes
0 answers
27 views

Do someone knows how to read an hexadecimal value with RISC-V?

I have this code where I need to enter as an int argument an hexadecimal value to return it's coordinates, I use "li a7, 5" for basic int but when I try inputing an hexa like 0x1001010C it ...
yassine_deux_s's user avatar
0 votes
0 answers
35 views

Creating Cache Conflict in assembly

Cache Size: 4 KB By Default Line Size : 32 Bytes Address Bits division: Number of sets: Cache Size/ 2x line size (multiplying by two as we have two way set associative cache) = 4096/2x32 = 64 Sets 1- ...
Muhammad Zahid iqbal's user avatar
-1 votes
1 answer
88 views

What would prevent converting RISC-V instructions to Intel micro-ops? [closed]

Intel is known to have been working on hardware to support the RISC-V ISA. What however specifically would prevent them from adding a second decoder to an x86 CPU that can decode RISC-V instructions ...
thequestioner's user avatar
0 votes
0 answers
55 views

Disc movement problem Hanoi Tower problem RISC-V

i am trying to make a program to emulate the towers of Hanoi, im using the RARS programm to compile the program. Right now it creates the towers, but the discs are not moving properly. Can anyone help ...
Linadhen7's user avatar
0 votes
0 answers
27 views

Zero pad RISC-V compressed instruction from objcopy

I have generated the ELF file and I am able to generate the Verilog format using riscv64-unknown-elf-objcopy tool. The problem is I have compressed instructions like below, but I am parsing the file ...
Ste3191's user avatar
0 votes
1 answer
35 views

What iswrong with this risc-v interpreter code in cornells?

addi t0, zero, 3 addi a6, zero, 3 fast_multiply: ADD a0, zero, zero next_digit: ANDI a1, a6, 1 SRAI a6, a6, 1 BEQ a1, zero, skip ADD a0, a0, t0 skip: ...
Andy McDonough's user avatar
0 votes
1 answer
86 views

How to compile for riscv zicond extension in gcc?

I wanted to use zicond extension for risc-v architecture. I read those messages. I couldn't understand how to compile for zicond extension. I tried in godbolt 1 and godbolt 2 with different march ...
Ömer GÜZEL's user avatar
0 votes
0 answers
61 views

Qemu error while launching Risc-V emulation

guys, I am trying to launch Linux emulation on Risc-V platform using Qemu. I did it step by step using this tutorial https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html On ...
Konstantin_30's user avatar
0 votes
0 answers
52 views

Wierd output in e^x function in RISC-V

Currently using RISC-V assembly language, CREATOR 4.0 emulator. I'm trying to implement the function e^x using Taylor Polinomial. Problem is the output obtained: 3628800.0, it should be an ...
jmartinpizarro's user avatar
0 votes
0 answers
23 views

Not receiving any output in RISC-V when using a recursive function inside a normal function

Currently using the CREATOR RISC-V simulator: Creator 4.0 RISC-V (RV32IMFD) didaCtic and geneRic assEmbly progrAmming simulaTOR I want to call the factorial function (recursive) inside a normal ...
jmartinpizarro's user avatar
0 votes
1 answer
61 views

Loop that prints infinite output

Currently using the CREATOR RISC-V simulator: Creator 4.0 RISC-V (RV32IMFD) didaCtic and geneRic assEmbly progrAmming simulaTOR I'm trying to do the sin function and I was touching a little bit the ...
jmartinpizarro's user avatar
0 votes
0 answers
45 views

"Properly" dereferencing pointer to address zero in RISC-V

I am developing bare metal code for a RV32IMC chip using gcc. I have memory mapped starting from address 0x0. I use simple pointers like uint32_t *p = 0x0; to access that address. I was surprised when ...
filo's user avatar
  • 231
0 votes
0 answers
196 views

risc-v assembly code, c to assembly(bubble sort). when i use risc-v simulator-web, i get to this error. i i didn't solve it

i try to translate c to assembly code - (risc-v) but i met this screen and error when i use web risc-v simulator. i use it https://www.cs.cornell.edu/courses/cs3410/2019sp/riscv/interpreter/ https://...
skyriv213's user avatar
0 votes
0 answers
20 views

Why overflow equals carryin xor carryout in Riscv?

Just like the title, why overflow equals carryin xor carryout in Riscv? In ALU, we say we can caculate the overflow bit using xor carryin and carryout, however, I cannot find the reason of this.
DamXosp4j's user avatar
0 votes
0 answers
53 views

How to test how does a RISC-V implementation process misaligned data access?

I see some words on riscv-spec-20191213: Loads and stores where the effective address is not naturally aligned to the referenced datatype (i.e., on a four-byte boundary for 32-bit accesses, and a two-...
Teng Wu's user avatar
  • 77
1 vote
1 answer
44 views

No output out of llvm-objdump for rustc compiled RISC-V32IM binary

When I compile following rust code: #![no_std] #![no_main] use core::panic::PanicInfo; #[panic_handler] fn panic(_panic: &PanicInfo<'_>) -> ! { loop {} } fn mult(a: u32, b: u32) -&...
Tony I.'s user avatar
  • 540
3 votes
1 answer
109 views

RISC-V GCC Compiler compiles ASM code incorrectly

I am writing an embedded C program to test a hardware IP that I have developed on an FPGA board. I was playing with the RISC-V GCC ASM syntax and found this weird issue. This is the code that I ...
Mohammed Arshaan's user avatar
0 votes
1 answer
40 views

Is there a set format on how immediates are shown in RISC-V assembly?

I'm working on parsing RISC-V assembly, and am working on parsing immediates. Using the LUI instruction as an example, I'm seeing examples which write it like lui t0, 0, and examples which write it ...
UnicornsOnLSD's user avatar

1
2 3 4 5
26