Where to find Red Pitaya's FPGA memory map exact pin addresses?

Applications, development tools, FPGA, C, WEB
Post Reply
WindJammer
Posts: 4
Joined: Thu Apr 04, 2024 6:37 pm

Where to find Red Pitaya's FPGA memory map exact pin addresses?

Post by WindJammer » Thu Apr 04, 2024 7:05 pm

Hello :lol: , complete beginner to Red Pitaya here... I am helping out on a project with red pitaya and I am trying to program the Red Pitaya FPGA in C to customize the functionality of some FPGA pins. However, I need the exact address for the FPGA pins in order to do so.
I had been searching everywhere, trying to look for an exact mapping of each pin on the Red Pitaya FPGA in the Red Pitaya github, forum, documentation, schematics and even the Zynq7 docs.

I am aware that in the Red Pitaya docs they showed only the range of addresses for a specific module (housekeeping, oscilloscope, etc.) here: https://redpitaya.readthedocs.io/en/lat ... v0.94.html

but never showing the specific address for a specific FPGA pin.


Similarly, in this code I found,
//set up shared memory (please refer to the memory offset table)
slcr = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0xF8000000);
cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40000000);
sts = mmap(NULL, synconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
0x40001000);
rx_data = mmap(NULL, 16*sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40010000);
tx_data = mmap(NULL, 16*synconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40020000);
pulseq_memory = mmap(NULL, 16*synconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40030000);
seq_config = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40040000);

They assign the byte address of the different registers in the red pitaya to the variable, allowing us to control the I/O pins and RF ports using those variables.

But it does not say exactly which address is to which FPGA pin...


Would very much appreciate it if anyone can share some insights as well as point me in the direction where I can find the exact address to each Red Pitaya FPGA pin. :D :D Thanks in advance!

User avatar
redpitaya
Site Admin
Posts: 926
Joined: Wed Mar 26, 2014 7:04 pm

Re: Where to find Red Pitaya's FPGA memory map exact pin addresses?

Post by redpitaya » Mon Apr 15, 2024 3:02 pm

Hello WindJammer,

You can find the official register map for the latest OS versions here:
https://redpitaya.readthedocs.io/en/lat ... #registers

The exact addresses are extracted like this (see link above). Let us assume you are trying to change one of the GPIO_P pins to output a 0 (from a C program perspective):
- Check the register map to find GPIO pins - they are located under Housekeeping
- You need to modify two registers - Expansion connector direction P and Expansion connector output P, they are located at offsets 0x10 and 0x18.
- Check where the Housekeeping section is located - 0x40000000 (start), 0x400FFFFF (end)

So you need to address 0x40000010 to modify the DIO_P direction and 0x40000018 to modify the DIO_P output. Each bit in the registers corresponds to a particular pin (bit 0 to DIO0_P, bit 1 to DIO1_P, etc.).

You can address the registers through the monitor command, use the C API functions, or map the memory using the mmap functionality (in case you have some other, custom registers assigned somewhere else).

Here is the reference (latest OS): https://redpitaya.readthedocs.io/en/lat ... ject-v0-94

User avatar
redpitaya
Site Admin
Posts: 926
Joined: Wed Mar 26, 2014 7:04 pm

Re: Where to find Red Pitaya's FPGA memory map exact pin addresses?

Post by redpitaya » Mon Apr 15, 2024 3:02 pm

There is no specific address for one pin, but you have a register containing values for 8 pins at a time (relevant for digital pins).

WindJammer
Posts: 4
Joined: Thu Apr 04, 2024 6:37 pm

Re: Where to find Red Pitaya's FPGA memory map exact pin addresses?

Post by WindJammer » Sun Apr 21, 2024 5:35 pm

--False post--
Last edited by WindJammer on Sun Apr 21, 2024 6:03 pm, edited 1 time in total.

WindJammer
Posts: 4
Joined: Thu Apr 04, 2024 6:37 pm

Re: Where to find Red Pitaya's FPGA memory map exact pin addresses?

Post by WindJammer » Sun Apr 21, 2024 6:01 pm

Hello Red Pitaya administrator, I am terribly sorry about the delayed response...

We are extremely grateful for your guidance for our question.

Just to clarify our understanding with your response, from this table found from: https://redpitaya.readthedocs.io/en/lat ... ject-v0-94, under the 'Housekeeping' module,

Offset| Description -------------------------| bits | R/W
0x10 | Expansion connector direction P |--------|
--------| Reserved ---------------------------- | 31:8 | R
--------| Direction for P lines -------------- | 7:0 | R/W
--------| 1-out -------------------------------- | -------|
--------|0-in ---------------------------------- | -------|
(since every consecutive register is 4 bytes, and hence 32 bits)

There is no specific address for each pin, but the functionality of each DIO pin can be modified by modifying the output of the registers at:

- 'Expansion Connector Direction N' at offset 0x14
- 'Expansion Connector Output N' at offset 0x1C
- 'Expansion Connector Input N' at offset 0x24
for the DIO _N pins, and

- 'Expansion Connector Direction P' at offset 0x10
- 'Expansion Connector Output P' at offset 0x18
- 'Expansion Connector Input P' at offset 0x20
for the DIO _P pins.



And using 'Expansion Connector Direction P', 'Expansion Connector Output P', 'Expansion Connector Input P' as an example, where they control DIO0_P to DIO7_P.

By re-writing the output (0 or 1) for that particular bit (from bits 0 to 7 (as it is R/W), since bits 8 to 32 are reserved (as it is R only)), where bit 0 is DIO0_P and bit 7 is DIO7_P, we can control that particular functionality of that pin (e.g. for 'Expansion Connector Direction P' re-writing the output for a particular bit will modify the direction of the corresponding pin, and for 'Expansion Connector Output P', re-writing the output for a particular bit will modify the output value of the corresponding pin).



Do let me know if there is any mistake in my understanding... Would it be possible to direct where I can find an example of Red Pitaya bit manipulation of a register to customise pin functionality in C? May I also know what are the 'reserved' bits for in the table for personal curiousity :D ?

User avatar
redpitaya
Site Admin
Posts: 926
Joined: Wed Mar 26, 2014 7:04 pm

Re: Where to find Red Pitaya's FPGA memory map exact pin addresses?

Post by redpitaya » Mon Apr 22, 2024 2:01 pm

Yes, that is correct. You can completely control the pins just by writing values into those registers or reading from them (in case of Input N and Input P registers). Your understanding of the functionality of the registers is correct, this is how it works. Each register has 32-bit of which not all are necessarily used (for the GPIOs only the lower 8-bits are used). Techically, you can write a full 32-bit number to an address, but only the lower 8-bits will be used.

For example, how to change output of DIO0_N to 1 (assuming the other pins do not matter).
- First we set the direction of the pin by writing 0x01 to address 0x40000014 (using hexa values)
- Then we specify the output by writing 0x01 to address 0x4000001C

You can test this functionality through the Jupyter Notebook (Red Pitaya OS versions 2.00-30 or 2.00-35) by using the functions to write directly into the registers (here is a link to the Jupyter example):
https://github.com/RedPitaya/jupyter/bl ... gpio.ipynb

As I already mentioned, the register width is 32-bit, so inside the FPGA the data also has a 32-bit width, but you might not want to use the full 32-bits, so you can just wire the lower 8 to control the GPIOs and ignore the rest. This saves FPGA resources (now you only need space to store 8 bits), is clean, and makes it easier for users to understand. This means the upper 24 bits are not connected to anything (when writing to address for GPIOs). If you need an example in C, why would you use an a full integer for bit operations when you might only need the lower 8-bits (you might as well use uint8_t).

If you want to manipulate the registers from C, take a look at the C API functions, they do exactly that:
- https://redpitaya.readthedocs.io/en/lat ... plications
- https://github.com/RedPitaya/RedPitaya/ ... pi/include

I hope this helps :D

WindJammer
Posts: 4
Joined: Thu Apr 04, 2024 6:37 pm

Re: Where to find Red Pitaya's FPGA memory map exact pin addresses?

Post by WindJammer » Mon May 06, 2024 1:31 pm

Hello Red PItaya Administrator,

Sorry again for the delayed response...

Thank you for confirming our understanding! Your responses have also been very informative in guiding us towards the right direction in using the Red Pitaya in our project.

We really appreciate your responses to our queries :D

User avatar
redpitaya
Site Admin
Posts: 926
Joined: Wed Mar 26, 2014 7:04 pm

Re: Where to find Red Pitaya's FPGA memory map exact pin addresses?

Post by redpitaya » Tue May 07, 2024 9:00 am

Dear WindJammer,

I am glad that we were able to solve the problem. If you have any questions, please let me know.

Good luck with your projects.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 18 guests