Skip to content

Commit

Permalink
mts logic and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pau Gomez committed Sep 23, 2022
1 parent 237aacc commit 6204053
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
29 changes: 29 additions & 0 deletions sdbuild/packages/xrfdc/package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ u32 XRFdc_GetLinkCoupling(XRFdc *InstancePtr, u32 Tile_Id, u32 Block_Id,
u32 *ModePtr);
u32 XRFdc_GetFabClkOutDiv(XRFdc *InstancePtr, u32 Type, u32 Tile_Id,
u16 *FabClkDivPtr);
u32 XRFdc_MultiConverter_Sync(XRFdc *InstancePtr, u32 Type,
XRFdc_MultiConverter_Sync_Config *ConfigPtr);
void XRFdc_MultiConverter_Init(XRFdc_MultiConverter_Sync_Config *ConfigPtr,
int *PLL_CodesPtr, int *T1_CodesPtr);
```
This list can also be found at the `Function Prototypes` section of
Expand All @@ -139,6 +143,31 @@ If attempting to use one of these functions on a Gen 1 board, the user will see
metal: error:
Requested functionality not available for this IP
## Multi-Tile Syncronization (MTS)
The underlying implementation is based on the [xrfdc_mts_example.c](https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/rfdc/examples/xrfdc_mts_example.c), which first defines the MTS configuration object and thereafter performs the actual MTS function call.
The following code snippet achieves MTS on all ADC (4) and DAC (2) tiles in flow:
```python
import pynq
import xrfclk
import xrfdc
#Config RF clocks (optional, lmk_freq and lmx_freq may differ depending on your application)
xrfclk.set_ref_clks(lmk_freq=122.88, lmx_freq=409.6)
#Load bitstream
ol = pynq.Overlay("bitstream_name.bit")
#MTS
ol.usp_rf_data_converter_0.mts_adc_config.Tiles = 0xf
ol.usp_rf_data_converter_0.mts_dac_config.Tiles = 0x3
ol.usp_rf_data_converter_0.mts_adc()
ol.usp_rf_data_converter_0.mts_dac()
```


Copyright (C) 2021 Xilinx, Inc

SPDX-License-Identifier: BSD-3-Clause
12 changes: 12 additions & 0 deletions sdbuild/packages/xrfdc/package/xrfdc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,22 @@ def __init__(self, description):
_lib.XRFdc_CfgInitialize(self._instance, self._config)
self.adc_tiles = [RFdcAdcTile(self, i) for i in range(4)]
self.dac_tiles = [RFdcDacTile(self, i) for i in range(4)]
self.mts_adc_config = _ffi.new('XRFdc_MultiConverter_Sync_Config*')
self.mts_dac_config = _ffi.new('XRFdc_MultiConverter_Sync_Config*')
_safe_wrapper("XRFdc_MultiConverter_Init", self.mts_adc_config, cffi.FFI.NULL, cffi.FFI.NULL)
_safe_wrapper("XRFdc_MultiConverter_Init", self.mts_dac_config, cffi.FFI.NULL, cffi.FFI.NULL)


def _call_function(self, name, *args):
_safe_wrapper(f"XRFdc_{name}", self._instance, *args)

def mts_adc(self):
return _safe_wrapper("XRFdc_MultiConverter_Sync", self._instance, 0, self.mts_adc_config)

def mts_dac(self):
return _safe_wrapper("XRFdc_MultiConverter_Sync", self._instance, 1, self.mts_dac_config)



# Finally we can add our data-driven properties to each class in the hierarchy

Expand Down
Binary file added sdbuild/packages/xrfdc/package/xrfdc/libxrfdc.so
Binary file not shown.
44 changes: 43 additions & 1 deletion sdbuild/packages/xrfdc/package/xrfdc/xrfdc_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,44 @@ typedef struct {
XRFdc_Distribution DistributionStatus[8];
} XRFdc_Distribution_Settings;

/**
* MTS DTC Settings.
*/
typedef struct {
u32 RefTile;
u32 IsPLL;
int Target[4];
int Scan_Mode;
int DTC_Code[4];
int Num_Windows[4];
int Max_Gap[4];
int Min_Gap[4];
int Max_Overlap[4];
} XRFdc_MTS_DTC_Settings;

/**
* MTS Sync Settings.
*/
typedef struct {
u32 RefTile;
u32 Tiles;
int Target_Latency;
int Offset[4];
int Latency[4];
int Marker_Delay;
int SysRef_Enable;
XRFdc_MTS_DTC_Settings DTC_Set_PLL;
XRFdc_MTS_DTC_Settings DTC_Set_T1;
} XRFdc_MultiConverter_Sync_Config;

/**
* MTS Marker Struct.
*/
typedef struct {
u32 Count[4];
u32 Loc[4];
} XRFdc_MTS_Marker;

/**
* ADC Signal Detect Settings.
*/
Expand Down Expand Up @@ -412,6 +450,8 @@ typedef struct {
} XRFdc;




/***************** Macros (Inline Functions) Definitions *********************/
#define XRFDC_ADC_TILE 0U
#define XRFDC_DAC_TILE 1U
Expand Down Expand Up @@ -517,4 +557,6 @@ u32 XRFdc_GetDSA(XRFdc *InstancePtr, u32 Tile_Id, u32 Block_Id, XRFdc_DSA_Settin
u32 XRFdc_SetPwrMode(XRFdc *InstancePtr, u32 Type, u32 Tile_Id, u32 Block_Id, XRFdc_Pwr_Mode_Settings *SettingsPtr);
u32 XRFdc_GetPwrMode(XRFdc *InstancePtr, u32 Type, u32 Tile_Id, u32 Block_Id, XRFdc_Pwr_Mode_Settings *SettingsPtr);
u32 XRFdc_ResetInternalFIFOWidth(XRFdc *InstancePtr, u32 Type, u32 Tile_Id, u32 Block_Id);
u32 XRFdc_ResetInternalFIFOWidthObs(XRFdc *InstancePtr, u32 Tile_Id, u32 Block_Id);
u32 XRFdc_ResetInternalFIFOWidthObs(XRFdc *InstancePtr, u32 Tile_Id, u32 Block_Id);
u32 XRFdc_MultiConverter_Sync(XRFdc *InstancePtr, u32 Type, XRFdc_MultiConverter_Sync_Config *ConfigPtr);
void XRFdc_MultiConverter_Init(XRFdc_MultiConverter_Sync_Config *ConfigPtr, int *PLL_CodesPtr, int *T1_CodesPtr);

0 comments on commit 6204053

Please sign in to comment.