UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
3,319 Views
Registered: ‎07-07-2017

SDK GPIO implementation

I am using KC705 Board

I have done the following block design(at the end) with clock frequency to microblaze as 100MHz and GPIO  is mapped to Y23 User Gpio pin.

I have programmed the GPIO using SDK and seen the output of GPIO in oscilloscope, I get only 1.7Mbps signal 

In SDK i implemented a counter I take the last bit so that i generate a square pulse i was expecting 50Mbps signal But i got only 1Mbps signal. Can someone say what is the issue here please ? Have also attached the screenshot of 1.7Mbps signal in oscilloscope

Please suggest some techniques so i can improve my speed to 50Mbps

block design.JPG

code snippet is as follows:

#include <stdio.h>
#include "xparameters.h"
#include "xil_cache.h"
#include "xgpio.h"
#include "xil_types.h"
#include "xil_assert.h"
#include "xstatus.h"
#include "xil_cache.h"
#define gpio1_device_id XPAR_AXI_GPIO_0_DEVICE_ID
XGpio GpioOutput;
int main()
{
int Status;
u8 value1=0;
Status = XGpio_Initialize(&GpioOutput,gpio1_device_id);
if(Status!=XST_SUCCESS)
{
xil_printf("Gpio Instance Didn't Initialize!\r\n");
return XST_FAILURE;
}
while(1)
{
XGpio_DiscreteWrite(&GpioOutput, 1,value1++);
}
return 0;
}

F0015TEK.JPG

 

 

0 Kudos
6 Replies
Voyager
Voyager
3,290 Views
Registered: ‎06-24-2013

Re: SDK GPIO implementation

Hey @shyam_sridharan

 

In SDK i implemented a counter I take the last bit so that i generate a square pulse i was expecting 50Mbps signal But i got only 1Mbps signal.

 

Let's assume for a moment, each instruction on the MicroBlaze just takes a single cycle, then the (almost) fastest way to toggle a GPIO pin would be an endless loop like this:

1 Set GPIO Pin
2 Clear GPIO Pin
3 Goto 1

But even this would not result in a 50Mhz toggle from a 100MHz clock, because the Goto would also consume a clock cycle to execute and thus you would get a 33MHz output with 33% duty cycle.

 

The only way to make it faster is to get rid of the Goto, which only works if you fill up all the instruction memory with those two instructions.

 

Incrementing a counter and setting the GPIO to the lowest bit will take a lot more cycles than this, so the output will toggle slower and slower ...

 

In reality, the execution of each command depends on the type of the command, the amount of data which needs to be retrieved or stored and the current state of the CPU.

 

If you get 1.7MHz output, this just means that your counter loop takes about 30 cycles to execute.

 

Please suggest some techniques so i can improve my speed to 50Mbps

 

In an FPGA, the solution is simple: don't use a CPU to generate the signal!

 

Hope that clarifies,

Herbert

-------------- Yes, I do this for fun!
3,284 Views
Registered: ‎07-07-2017

Re: SDK GPIO implementation

Thanks @hpoetzl

 

I do understand that it takes some clock cycles to set and clear the pins 

 

If you get 1.7MHz output, this just means that your counter loop takes about 30 cycles to execute.

> How did u calculate it is 30 cycles

 

In an FPGA, the solution is simple: don't use a CPU to generate the signal!

I want microblaze in my design so that i can connect other modules as and when required.

 

I have also tried sending data from counter block to gpio pin via microblaze it is still slower than this due to additional blocks

 

Can you suggest some other ways???

0 Kudos
Voyager
Voyager
3,280 Views
Registered: ‎06-24-2013

Re: SDK GPIO implementation

Hey @shyam_sridharan

 

How did u calculate it is 30 cycles

 

Every time your loop executes, it will do half a period of the output. If your loop executes in one cycle, you would get an output of 50MHz from a 100MHz clock. If it takes two cycles, you'll get 25MHz, five cycles, 10Mhz ...

 

I want microblaze in my design so that i can connect other modules as and when required.

 

That is perfectly fine, but that doesn't mean that the MicroBlaze has to do everything.

For example, if you just need/want a 50MHz signal on an FPGA pin, you can do that with a few lines of HDL code.

 

Hope that clarifies,

Herbert

-------------- Yes, I do this for fun!
0 Kudos
3,273 Views
Registered: ‎07-07-2017

Re: SDK GPIO implementation

Thanks for the explanation for the cycles 

 

Microblaze needn't do everything. I agree 

 

My ultimate goal is to generate a PRBS signal with higher data rates.

I am just trying with counter and then planned to replace the code with PRBS code.

 

So Microblaze can be used to start the process and end as and when needed by user.

I did implement the design without microblaze . But i want microblaze to start and stop the process when i need

 

Thanks in advance

 

0 Kudos
Voyager
Voyager
3,270 Views
Registered: ‎06-24-2013

Re: SDK GPIO implementation

@shyam_sridharan

 

Check out the prng tests I did some time ago, specifically the prng.vhd for the pseudo random number generation.

 

Hope this helps,

Herbert

-------------- Yes, I do this for fun!
0 Kudos
Visitor jaywayne
Visitor
2,559 Views
Registered: ‎01-12-2018

Re: SDK GPIO implementation

Hi @shyam_sridharan,

Curious if you were able to get to the higher data rates in Microblaze?  Would you mind sharing your implementation- what did you end up settling on using? I'm trying to do the same thing and would greatly speed things up- much appreciated!

J

0 Kudos