Jump to content
  • 0

Zync Baremetal Physical Pins to XGpio channels - mapping/addressing


jungle

Question

Hello I have a Zynq Cora 7s.

I am adding some leds to control via software:

This is in the constraints:

#set_property -dict { PACKAGE_PIN L15   IOSTANDARD LVCMOS33 } [get_ports { led0_b }]; #IO_L22N_T3_AD7N_35 Sch=led0_b
#set_property -dict { PACKAGE_PIN G17   IOSTANDARD LVCMOS33 } [get_ports { led0_g }]; #IO_L16P_T2_35 Sch=led0_g
#set_property -dict { PACKAGE_PIN N15   IOSTANDARD LVCMOS33 } [get_ports { led0_r }]; #IO_L21P_T3_DQS_AD14P_35 Sch=led0_r
#set_property -dict { PACKAGE_PIN G14   IOSTANDARD LVCMOS33 } [get_ports { led1_b }]; #IO_0_35 Sch=led1_b
#set_property -dict { PACKAGE_PIN L14   IOSTANDARD LVCMOS33 } [get_ports { led1_g }]; #IO_L22P_T3_AD7P_35 Sch=led1_g
#set_property -dict { PACKAGE_PIN M15   IOSTANDARD LVCMOS33 } [get_ports { led1_r }]; #IO_L23N_T3_35 Sch=led1_r

I can see the physical pins:

1811798920_Screenshotfrom2021-01-2015-04-02.png.b028ea734a695996f01d6a6e17fcf1d2.png

In vivado I added a AXI GPIO block and connected leds and buttons. Its says:

zoom.png.01f014261519989f2fb143c3d1466b61.png

 

The vivado address editor shows an address 0x4120_0000

addr.png.79980b0a9b7d4bdca777da55f3eee866.png

Then when I make an application:
 

XGpio_SetDataDirection(&gpio, 2, 0x00000000); // set LED GPIO channel tristates to All Output
XGpio_SetDataDirection(&gpio, 1, 0xFFFFFFFF); // set BTN GPIO channel tristates to All Input

btn = XGpio_DiscreteRead(&gpio, 1);
XGpio_DiscreteWrite(&gpio, 2, led);

And that works...

But how do I work out that the GPIO is channel 1 and 2 from Vivado... when what I had was those addresses ?

I want to work with pmods too but I am not sure how to get everything connected.

 

 

 

 

Screenshot from 2021-01-20 14-47-23.png

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Hi @jungle,

The GPIO 1 and 2 are the channels that are shown on the axi_gpio_0 IP block in your Block Design, where channel 1 (labeled GPIO) is connected to btns_2bits and channel 2 (labeled GPIO2) is connected to rgb_leds. That is how you can know where the pins are connected; you can see the specific hardware mapping in xparameters.h, located in the wrapper->ps7_cortexa9_0->standalone_domain->bsp->ps7_cortexa9_0->include->xparameters.h.

Pmods will be handled similarly; if you haven't seen it before, we have a guide on how to do this in Vitis here: https://reference.digilentinc.com/reference/programmable-logic/guides/hierarchical-blocks.

Let me know if you have any other questions.

Tanks,
JColvin

Link to comment
Share on other sites

Okay that sort of helps. I added another AXI GPIO block and moved the leds to that. Then in xparameters I set #define XPAR_XGPIO_NUM_INSTANCES 2 and it allowed me to create two gpio devices and have the buttons and leds working on separate ones. The channels automatically map to addresses using the code in xgpio.c. But the Pmod drivers all use addresses so that easier.

One issue I am facing is with the PmodENC. It only uses 6 pins so I have a splitter cable connecting two pmodENCs to one Pmod connector. I looked at PmodENC.v and some of the related files and it looks like it just maps the pins to AXI. I saw some verilog somewhere else that does debouncing too.

The PmodENC AXI LITE GPIO block starts addressing at 0x4000_0000, so the first encoder is easy to pick up in software, but what address offest should I use for a second encoder attached on the remaining six pins ?

I'm not sure if I have to modify the Pmod ENC block and put a splitter on or does the current block and driver support multiple devices ?

 

Also I realised that my whole .xdc file is commented out... so how does vivado work out which package pins are the LEDS ?

 

Link to comment
Share on other sites

Hi @jungle,

Vivado will automatically generate it's own set of constraints for you based on your block design and board files you provided, so you don't have to worry about that side of things. You can still provide your own .xdc if you want to override Vivado generated constraints or manually provide your own in addition to what Vivado creates for itself though.

In terms of having multiple Pmods, there isn't anything in particular that needs to be done if you are using separate Pmod ports. If you are using a splitter to have two 6-pin Pmods on a single Pmod port, then you would need to do some extra work with the Pmod Bridge IP to get the two Pmods manually connected.

Let me know if you have any questions about this.

Thanks,
JColvin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...