RISC-V softcore GPIO (memory mapped) sends the first value and fails later

65 views Asked by At

I have a RISC-V softcore based SoC (PICO-SoC) and I have implemented memory (32'h 00000090) mapped output port to send a set of values. The set up is running on PYNQ FPGA board. The softcore provides a web-based interface — Python notebook, to compile and execute application software on RISC-V. When I execute the below application software, I notice only te first value arrives at the output port and then the program exits (probably some exception occurs).

%%riscvc test overlay.tutorialProcessor

#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <time.h>   

#define reg_outp (*(volatile int*)0x00000090) 

int main(int argc, char ** argv)
{
    unsigned int * arr = (unsigned int *)argv[1];

    reg_outp = 7;           
    reg_outp = 9;            
    reg_outp = 15;

    return arr[2];           
}  

The first line is used for compiling. Post compiling the code is executed as below

import numpy as np

arg1 = np.array([4,2,3], np.uint32)
retval = overlay.tutorialProcessor.run(test, arg1)
if (retval != arg1[2]):
    print("Test failed!")
else:
    print("Test passed!") 

The result says Test failed! and, in the output port, I see only 7, which is the first value sent (The output port is connected to debug core to see the received values). If I comment the lines which writes to output port, then the software executes as expected with the result Test passed!

Below is the snippet for the memory mapped output port implementation.

always @(posedge clk) begin
        if (!resetn) begin
            gpio <= 0;
        end else begin
            rmem_ready <= 0;
            if (mem_valid && !mem_ready && mem_addr[31:0] == 32'h 00000090) begin
                rmem_ready <= 1;
                if (mem_wstrb[0]) gpio[ 7: 0] <= mem_wdata[ 7: 0];
                if (mem_wstrb[1]) gpio[15: 8] <= mem_wdata[15: 8];
                if (mem_wstrb[2]) gpio[23:16] <= mem_wdata[23:16];
                if (mem_wstrb[3]) gpio[31:24] <= mem_wdata[31:24];
            end
        end
    end

I am not sure why I am not getting the subsequent values after 7 at the output port. Is the program exiting after sending the first value due to some exception? what could be possibly going wrong here? Is the memory (0x00000090) that I mapped corresponds to code area? Where can I find the memory mapping and to which memory area should I connect the output port?

0

There are 0 answers