cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
541 Views
Registered: ‎08-11-2019

can not able to read data from Custom IP.

Hello to All

I already created a synthesizable custom ip (which is sine wave IP)and also wrote a C code for read this ip output ( i want to read a data from register).But somehow its shows somthing diff. insted of what i expect. Can anyone explain me what is it !

here i'm atteching screenshot and my c code for that.

As, shown in picture

I can't understand what kind of ip state it is showing in the teraterm output.

here, i'm expecting sinewave output. ( in digit form )

 

SINE_THREE.PNG

0 Kudos
5 Replies
Highlighted
Voyager
Voyager
531 Views
Registered: ‎06-28-2018

Hi @h_upadhyay 

In your C code baseaddr is left uninitialized. You are probably reading some garbage data from a random location in the memory.

0 Kudos
Highlighted
Contributor
Contributor
465 Views
Registered: ‎08-11-2019

Thanks for your reply

hi,

As you said baseaddr is left uninitialized in my c code. 

could you pls explain in a more specific in this code.

0 Kudos
Highlighted
Voyager
Voyager
440 Views
Registered: ‎06-28-2018

Hi @h_upadhyay 

I've added some comments to help you solve your issues.

#include "xil_printf.h"
#include "xil_io.h"
#include "xparameters.h"
/*
	xparameters.h contains address definitions for memory mapped IP cores
	you'll find the valid address ranges that are accessible by your IP cores
	when you open your block design in Vivado there is an address editor tab
	you can change the address map using this editor
*/
#include "xil_types.h"
#include "xparameters_ps.h"
#include <stdio.h>

#define XPAR_MYIPINETHREE_0_DEVICE_ID 0
#define XPAR_MYIPINETHREE_0_S00_AXI_BASEADDR 0x43C00000
#define XPAR_MYIPINETHREE_0_S00_AXI_HIGHADDR 0x43C0FFFF
/*
	these are probably defined in xparameters.h
	you don't have to redefine them if they exist
	if you want to do it anyways do it properly using ifdef...endif syntax
	also these are not used in your code
*/

int main(){
	u32 baseaddr;
	/*
		no initial value is given to baseaddr, it has a garbage value
		you should assign a value to it such as
		u32 baseaddr = SOME_BASE_ADDR_DEFINED_IN_XPARAMETERS_DOT_H;
	*/
	int sine, sinephase, enable, reg;
	while (1)
	{
		xil_printf("start of ip test\r");
		if (enable == 1) // enable is not initialized
			reg = 0xFFFFFFFF; // reg is not used anywhere in your code
		else
			reg = 0x00000000;
		Xil_Out32(0x43C00000, 32);
		/*
			Xil_Out32(x,y) writes 32-bit y to the memory location starting at address x
			here you're writing 32 to address 0x43C00000 in each loop
			this does not make sense
		*/
		sine = Xil_In32(baseaddr+4);
		/*
			Xil_In32(x) reads 32 bits starting from the memory address x
			since baseaddr is not initialized you're reading from a random location in the memory
			in each loop you're reading from baseaddr+4, you're not incrementing baseaddr
			if you want to increment it add the following line to your code
			baseaddr = baseaddr + 4;
		*/
		xil_printf("\r state: %d", sine);
		Xil_Out32(0x43C00000, 32);
		sinephase = Xil_In32(baseaddr+4);
		xil_printf("\r state: %d", sinephase);
		return 0;
		/*
			after the first loop your program stops its execution
			you should move this outside the while loop
		*/
	}
	// return 0; should be here
}
Highlighted
Contributor
Contributor
375 Views
Registered: ‎08-11-2019

Thank you so much, sir

But still, it didn't show any data about my sine, sine phase output.

i'm still confused in Xil_Out32(x,y);

and one more silly Question

sir, how can I confirm that my custom IP is created in the right way? [i mean it has my sine and sine phase wave data or not !]

Here, Attaching my c code.

sine_data.PNG

0 Kudos
Highlighted
Voyager
Voyager
363 Views
Registered: ‎06-28-2018

Hi @h_upadhyay 

You've defined baseaddr as a pointer. To access the content of an object pointed to by baseaddr you have to use the indirection (*) operator before the name of the pointer such as *baseaddr.

However, you don't have to use pointers there. All you need is the value of baseaddr. Change that line to

baseaddr = XPAR_MYIPINETHREE_0_S00_AXI_BASEADDR;

Also do the following in a separate line, not inside Xil_In32() function call

base = baseaddr + 4;

Also, you should read a good C book or watch a video tutorial before starting coding.


sir, how can I confirm that my custom IP is created in the right way? [i mean it has my sine and sine phase wave data or not !


You should simulate it first and verify that it behaves correctly. To verify its operation on real hardware you can debug it by adding ILA cores to your design. To do that, open the synthesized design, select the wires you want to debug in the schematic and use Set Up Debug tool on the left panel.

0 Kudos