Write to CSR (fpga) from software

Is there a way to write and read to a custom CSR register on the FPGA (LimeSDR XTRX v1.2) with the LimeSuiteNG software?

I am trying to write some custom module on the RX pipeline following the example (adding an fft module). I have the LimeSDR XTRX connected with an Raspberry pi.

I also tried to add a CSR register in the LimeSDR_GW code in the LimeTop.py module:

self.output_mode = CSRStorage(size=16, reset=10, description=“Chooses output mode”)

I find in the generated csr.json:

“lime_top_output_mode”: {“addr”: 4026552652, “size”: 1, “type”: “rw”},

and in a generated csr.h file I find:

static inline uint32_t lime_top_output_mode_read(void) {
return csr_read_simple((CSR_BASE + 0x514cL));
}

static inline void lime_top_output_mode_write(uint32_t v) {
csr_write_simple(v, (CSR_BASE + 0x514cL));
}

It looks like there are logic generated, on the FPGA Software/Hardware system to write to the custom CSR register. My question is how to interact with the system from the Raspberry pi host, to write to the CSR register. When I tried to use limeGUI (CSR and limeSPI) to write to the register, nothing happens. It is possible to read from some low address value registers.

Do I somehow have to map some of the low address registers to my custom registers which the post implies?

Hi @gear,

yes, you can use limeCSR from command line and CSR from limeGUI.

First check if you are using correct CSR address. In your case address would be:
CSR_BASE + 0x514c=0x00000000f000514c (I am assuming that CSR_BASE was not changed and it is 0xf0000000)

to use limeCSR from command line:

./limeCSR read --stream 00000000F000514c

./limeCSR write  --stream 00000000F000514c0000000000000003

Note that in limeCSR you have to use 8byte word for read and 16byte for write without 0x prefix. Check limeCSR --help for details.

I tried the limeCSR commands and it works writing and reading to/from the CSR register. I tested in command line (limeCSR) and CSR in limeGUI, both works. Thank you @VytautasB .