chipsalliance / chipsalliance/rocket-chip
Problem when writing software for Blackbox Rocc example
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 3.9k
- Forks
- 1.3k
- Avg merge
- 5d 13m
- Merged PRs (30d)
- 1
Description
Hi, I encounter a problem when implementing the software design for the Rock BlackBox example. I tried to use the black box in software, and I write the code like the following. But it gives no response when I test with ./simualtion-XXX-XXXConfig XXX.riscv in verilator.
#include<stdio.h>
#include "rocc.h"
static inline void accum_write(int idx, unsigned long data)
{
ROCC_INSTRUCTION_SS(3, data, idx, 0);
}
static inline unsigned long accum_read(int idx)
{
unsigned long value;
ROCC_INSTRUCTION_DSS(3, value, 0, idx, 1);
return value;
}
static inline void accum_load(int idx, void *ptr)
{
asm volatile ("fence");
ROCC_INSTRUCTION_SS(3, (uintptr_t) ptr, idx, 2);
}
static inline void accum_add(int idx, unsigned long addend)
{
ROCC_INSTRUCTION_SS(3, addend, idx, 3);
}
static inline unsigned long black_box(int num1, int num2)
{
unsigned long value;
ROCC_INSTRUCTION_DSS(0, value, num1, num2, 1);
return value;
}
unsigned long data = 0x3421L;
int main(void)
{
unsigned long result;
//Blackbox process
black_box(1,2);
black_box(3,4);
result=black_box(5,6);
printf("The result is: %ld\n",result);
printf("Blackbox Success!\n");
accum_load(0, &data);
accum_add(0, 2);
result = accum_read(0);
if (result != data + 2)
return 1;
accum_write(0, 3);
accum_add(0, 1);
result = accum_read(0);
if (result != 4)
{printf("Failed\n");
return 2;}
printf("Accum Success!\n");
return 0;
}
But if I move the blackbox process below the Accum part, it works, which makes me very confused.
I do not where I am wrong, I am quite confused.
Could you give an example of how to use Blackbox.
Thanks in advance
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied C program with the Rocket Chip BlackBox example under Verilator, comparing behavior when the BlackBox calls precede or follow the Accum calls. Determine the cause of the ordering-dependent lack of response and document a working BlackBox usage example, including the conditions that make the test complete successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100