FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6355 Discussions

How to setup Transceiver Phy Serial Loopback using C Application

matif
Novice
831 Views

​Hi,

In altera manual for transceiver custom phy ip, it is mentioned that it is possible to set up serial loopback by setting register equal to 1 at phy-mgmt_address 0x061. I have seen a tutorial at YouTube where the instructor do it using Transciever toolkit option of Quartus 2 but for that I need USB blaster cable which I dont have.

Here is the link to that tutorial

https://www.youtube.com/watch?v=vjeMWJ-mNaw

Now, is there any other way to write 1 to this register? I tried following c program to do this but it shows me segmentation error.

Any help please, if there is any other way except usb blaster cable to do this task..

Here is my c code

#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <stdint.h> #include <fcntl.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include "C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\hwlib.h" #include "C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\soc_cv_av\socal\socal.h" #include "C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\soc_cv_av\socal\hps.h" #include "C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\soc_cv_av\socal\alt_gpio.h" #include "D:\masterarbeit3\HWXCVRHW2\hps_0.h" #define REG_BASE 0xFF200000 /*LWFPGA SLAVE Address*/ #define REG_SPAN 0x00200000 #define serial_loopback 0x061 /*phy_mgmt_address for serial loopback*/ volatile unsigned int *xcvr_addr; /*this is the pointer that will read from transceiver*/ volatile unsigned int *xcvr_addr_serial_loopback; void* virtual_base; /*pointer to open device memory file*/ int main () { int fd = EXIT_FAILURE; fd=open("/dev/mem",(O_RDWR|O_SYNC)); if (fd < 0) { perror("open"); exit(EXIT_FAILURE); } /*setting serial loopback of transceiver by setting register 1 at address 0x061*/ xcvr_addr_serial_loopback = (unsigned int *) (XCVR_CUSTOM_PHY_0_BASE+serial_loopback); *xcvr_addr_serial_loopback =1; /*memory mapping*/ virtual_base=mmap(NULL,REG_SPAN,(PROT_READ|PROT_WRITE),MAP_SHARED,fd,REG_BASE); xcvr_addr = (unsigned int *) (virtual_base+XCVR_CUSTOM_PHY_0_BASE); /*accessing base address of xcvr*/ while(1) { printf("pointer value is %d\n", *xcvr_addr); } return 0; }

Here is the header file that contains address of my transceiver,

#ifndef _ALTERA_HPS_0_H_ #define _ALTERA_HPS_0_H_ /* * This file was automatically generated by the swinfo2header utility. * * Created from SOPC Builder system 'soc_system' in * file 'soc_system.sopcinfo'. */ /* * This file contains macros for module 'hps_0' and devices * connected to the following master: * h2f_lw_axi_master * * Do not include this header file and another header file created for a * different module or master group at the same time. * Doing so may result in duplicate macro names. * Instead, use the system header file which has macros with unique names. */ /* * Macros for device 'xcvr_custom_phy_0', class 'altera_xcvr_custom_phy' * The macros are prefixed with 'XCVR_CUSTOM_PHY_0_'. * The prefix is the slave descriptor. */ #define XCVR_CUSTOM_PHY_0_COMPONENT_TYPE altera_xcvr_custom_phy #define XCVR_CUSTOM_PHY_0_COMPONENT_NAME xcvr_custom_phy_0 #define XCVR_CUSTOM_PHY_0_BASE 0x0 #define XCVR_CUSTOM_PHY_0_SPAN 2048 #define XCVR_CUSTOM_PHY_0_END 0x7ff #endif /* _ALTERA_HPS_0_H_ */

 

0 Kudos
6 Replies
CheePin_C_Intel
Employee
499 Views
Hi Muhammad, As I understand it, you have some inquiries on way to enable the internal serial loopback for the XCVR custom PHY IP apart from using Transceiver Toolkit. One of the alternative way would be for you to perform the register writing by coding a state machine in Verilog to control the On/Off of the internal serial loopback. As I did a search in web, I found the following simple example design which might be helpful to you. It would be great if you could refer to it: https://fpgawiki.intel.com/wiki/Arria_V_Transceiver_PHY_Basic_Design_Examples#Arria_V_Custom_PHY_simple_ways_to_enable_internal_serial_loopback_design_examples Sorry as I am not familiar with C programming and thus could provide further comment on it. Sorry for the inconvenience. Please let me know if there is any concern. Thank you. Best regards, Chee Pin
matif
Novice
499 Views

Hey,

Thanks a lot. The link you provided is really useful. Thanks again.

0 Kudos
matif
Novice
499 Views

Hi,

I am trying to download files on your link but I am having trouble. Are the files working for you on this link?

0 Kudos
CheePin_C_Intel
Employee
499 Views
Hi, I have tested the link and seems like not issue downloading the QARs. I have sent the QARs to your through email because the system seems not allow me to attach to the Forum thread.
matif
Novice
499 Views

Thanks you so much. i really appreciate your help and support

 

0 Kudos
CheePin_C_Intel
Employee
499 Views
You are most welcome.
0 Kudos
Reply