Skip to content

Commit 3570efb

Browse files
committed
projects/ad4630_fmc: Refactor ad463x
Separates the 1CH (AD4030) HDL support from the 2CH (AD4630) support. Previously, whenever 1CH was used it was necessary to throw away half of the data because the project was always expecting 2 channels for the ADC. Updated the XDC files for each supported mode considering how the amount of channels the ADC. Also updated the tcl script variables, now there is a NUM_OF_CHANNEL, updated the NUM_OF_SDI to LANES_PER_CHANNEL, and inserted INTERLEAVE_MODE variable. NO_REORDER became an internal compilation variable that is enabled according to the combination NUM_OF_CHANNEL, LANES_PER_CHANNEL and INTERLEAVE_MODE. Setting INTERLEAVE_MODE to 1 with unsupported configuration throws an error. Inserts a GPIO to drive CNV pin in parallel with the PWM. The CNV pin is an "or" function of the GPIO[36] and PWM. Updated examples in the README FILE. Signed-off-by: Carlos Souza <[email protected]>
1 parent 0261fea commit 3570efb

13 files changed

+333
-127
lines changed

projects/ad4630_fmc/common/ad463x_bd.tcl

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,32 @@
55

66
source $ad_hdl_dir/library/spi_engine/scripts/spi_engine.tcl
77
# system level parameters
8-
set NUM_OF_SDI $ad_project_params(NUM_OF_SDI)
9-
set CAPTURE_ZONE $ad_project_params(CAPTURE_ZONE)
10-
set CLK_MODE $ad_project_params(CLK_MODE)
11-
set DDR_EN $ad_project_params(DDR_EN)
12-
set NO_REORDER $ad_project_params(NO_REORDER)
8+
set LANES_PER_CHANNEL $ad_project_params(LANES_PER_CHANNEL)
9+
set NUM_OF_CHANNEL $ad_project_params(NUM_OF_CHANNEL)
10+
set CAPTURE_ZONE $ad_project_params(CAPTURE_ZONE)
11+
set CLK_MODE $ad_project_params(CLK_MODE)
12+
set DDR_EN $ad_project_params(DDR_EN)
13+
set INTERLEAVE_MODE $ad_project_params(INTERLEAVE_MODE)
14+
15+
if {$INTERLEAVE_MODE == 1} {
16+
if {$LANES_PER_CHANNEL > 1 || $NUM_OF_CHANNEL != 2} {
17+
puts "ERROR: Interleave mode is only supported with 2 channels (NUM_OF_CHANNEL == 2) and 1 lane per channel (LANES_PER_CHANNEL == 1)."
18+
exit 2
19+
}
20+
set NUM_OF_SDI 1
21+
# REORDER is mandatory in interleaved mode
22+
set NO_REORDER 0
23+
} else {
24+
set NUM_OF_SDI [expr {$ad_project_params(NUM_OF_CHANNEL) * $ad_project_params(LANES_PER_CHANNEL)}]
25+
if {$NUM_OF_SDI > 2} {
26+
# REORDER is mandatory when more than 2 lanes are used
27+
set NO_REORDER 0
28+
} else {
29+
set NO_REORDER 1
30+
}
31+
}
1332

14-
puts "build parameters: NUM_OF_SDI: $NUM_OF_SDI ; CAPTURE_ZONE: $CAPTURE_ZONE ; CLK_MODE: $CLK_MODE ; DDR_EN: $DDR_EN ; NO_REORDER: $NO_REORDER"
33+
puts "build parameters: NUM_OF_SDI: $NUM_OF_SDI ; CAPTURE_ZONE: $CAPTURE_ZONE ; CLK_MODE: $CLK_MODE ; DDR_EN: $DDR_EN ; INTERLEAVE_MODE: $INTERLEAVE_MODE"
1534

1635
# block design ports and interfaces
1736
# specify the CNV generator's reference clock frequency in MHz
@@ -36,6 +55,7 @@ create_bd_port -dir I ad463x_echo_sclk
3655

3756
create_bd_port -dir I ad463x_busy
3857
create_bd_port -dir O ad463x_cnv
58+
create_bd_port -dir I ad463x_trigger
3959
create_bd_port -dir I ad463x_ext_clk
4060

4161
create_bd_port -dir O max17687_sync_clk
@@ -77,7 +97,7 @@ ad_ip_parameter $hier_spi_engine/${hier_spi_engine}_axi_regmap CONFIG.CFG_INFO_3
7797
set sampling_cycle [expr int(ceil(double($cnv_ref_clk * 1000000) / $adc_sampling_rate))]
7898

7999
## setup the pulse period for the MAX17687 and LT8608 SYNC signal
80-
set max17687_cycle [expr int(ceil(double($cnv_ref_clk * 1000000) / $max17687_sync_freq))]
100+
set max17687_cycle [expr int(ceil(double($cnv_ref_clk * 1000000) / $max17687_sync_freq))]
81101

82102
ad_ip_instance axi_pwm_gen cnv_generator
83103
ad_ip_parameter cnv_generator CONFIG.N_PWMS 2
@@ -93,17 +113,8 @@ ad_ip_parameter sync_generator CONFIG.PULSE_0_PERIOD $max17687_cycle
93113
ad_ip_parameter sync_generator CONFIG.PULSE_0_WIDTH [expr int(ceil(double($max17687_cycle) / 2))]
94114

95115
if {$NO_REORDER == 0} {
96-
97116
ad_ip_instance spi_axis_reorder data_reorder
98117
ad_ip_parameter data_reorder CONFIG.NUM_OF_LANES $NUM_OF_SDI
99-
100-
} elseif {$NO_REORDER == 1} {
101-
102-
if {$CAPTURE_ZONE == 2} {
103-
puts "ERROR: Invalid configuration - Disabling Reorder IP is invalid for Capture Zone 2."
104-
exit 2
105-
}
106-
107118
}
108119

109120
# dma to receive data stream
@@ -116,19 +127,23 @@ ad_ip_parameter axi_ad463x_dma CONFIG.AXI_SLICE_DEST 1
116127
ad_ip_parameter axi_ad463x_dma CONFIG.AXI_SLICE_SRC 1
117128
if {$NO_REORDER == 0} {
118129
ad_ip_parameter axi_ad463x_dma CONFIG.DMA_DATA_WIDTH_SRC 64
119-
} elseif {$NO_REORDER == 1} {
120-
if {$NUM_OF_SDI == 1} {
121-
ad_ip_parameter axi_ad463x_dma CONFIG.DMA_DATA_WIDTH_SRC 32
122-
} elseif {$NUM_OF_SDI == 2} {
123-
ad_ip_parameter axi_ad463x_dma CONFIG.DMA_DATA_WIDTH_SRC 64
124-
}
130+
} else {
131+
#REORDER BYPASSED
132+
ad_ip_parameter axi_ad463x_dma CONFIG.DMA_DATA_WIDTH_SRC [expr min(32 * $NUM_OF_SDI, 64)]
125133
}
126-
134+
127135
ad_ip_parameter axi_ad463x_dma CONFIG.DMA_DATA_WIDTH_DEST 64
128136

137+
# or logic for CNV generation
138+
ad_ip_instance ilvector_logic or_logic_cnv
139+
ad_ip_parameter or_logic_cnv CONFIG.C_SIZE 1
140+
ad_ip_parameter or_logic_cnv CONFIG.C_OPERATION or
141+
142+
ad_connect cnv_generator/pwm_1 or_logic_cnv/Op1
143+
ad_connect ad463x_trigger or_logic_cnv/Op2
144+
129145
# Trigger for SPI offload
130146
if {$CAPTURE_ZONE == 1} {
131-
132147
## SPI mode is using the echo SCLK, on echo SPI and Master mode the BUSY
133148
# is used for SDI latching
134149
switch $CLK_MODE {
@@ -137,7 +152,7 @@ if {$CAPTURE_ZONE == 1} {
137152
}
138153
1 -
139154
2 {
140-
puts "ERROR: Invalid configuration option. CAPTURE_ZONE 1 can be used only in SPI mode (CLK_MODE == 1)."
155+
puts "ERROR: Invalid configuration option. CAPTURE_ZONE 1 can be used only in SPI mode (CLK_MODE == 0)."
141156
exit 2
142157
}
143158
default {
@@ -159,6 +174,7 @@ if {$CAPTURE_ZONE == 1} {
159174
ad_connect ad463x_busy busy_sync/in_bits
160175
ad_connect busy_sync/out_bits busy_capture/signal_in
161176
ad_connect $hier_spi_engine/trigger busy_capture/signal_out
177+
162178
## SDI is latched by the SPIE execution module
163179
if {$NO_REORDER == 0} {
164180
ad_connect $hier_spi_engine/m_axis_sample data_reorder/s_axis
@@ -167,7 +183,6 @@ if {$CAPTURE_ZONE == 1} {
167183
}
168184

169185
} elseif {$CAPTURE_ZONE == 2} {
170-
171186
# Zone 2 - trigger to next consecutive CNV
172187
ad_ip_parameter $hier_spi_engine/${hier_spi_engine}_offload CONFIG.ASYNC_TRIG 1
173188
ad_connect cnv_generator/pwm_0 $hier_spi_engine/trigger
@@ -179,7 +194,11 @@ if {$CAPTURE_ZONE == 1} {
179194
switch $CLK_MODE {
180195
0 {
181196
## SDI is latched by the SPIE execution module
182-
ad_connect $hier_spi_engine/m_axis_sample data_reorder/s_axis
197+
if {$NO_REORDER == 0} {
198+
ad_connect $hier_spi_engine/m_axis_sample data_reorder/s_axis
199+
} else {
200+
ad_connect $hier_spi_engine/m_axis_sample axi_ad463x_dma/s_axis
201+
}
183202
}
184203
1 -
185204
2 {
@@ -193,8 +212,12 @@ if {$CAPTURE_ZONE == 1} {
193212
ad_connect ad463x_busy data_capture/echo_sclk
194213
ad_connect ad463x_spi_sdi data_capture/data_in
195214

196-
ad_connect data_capture/m_axis data_reorder/s_axis
197-
215+
## SDI is latched by the SPIE execution module
216+
if {$NO_REORDER == 0} {
217+
ad_connect data_capture/m_axis data_reorder/s_axis
218+
} else {
219+
ad_connect data_capture/m_axis axi_ad463x_dma/s_axis
220+
}
198221
}
199222
default {
200223
puts "ERROR: Invalid value for CLK_MODE (valid values are 0 or 1 or 2)."
@@ -203,12 +226,11 @@ if {$CAPTURE_ZONE == 1} {
203226
}
204227

205228
} else {
206-
207229
puts "ERROR: Invalid capture zone, please choose 1 or 2."
208230
exit 2
209-
210231
}
211-
ad_connect ad463x_cnv cnv_generator/pwm_1
232+
233+
ad_connect ad463x_cnv or_logic_cnv/Res
212234
ad_connect max17687_sync_clk sync_generator/pwm_0
213235

214236
# clocks

projects/ad4630_fmc/zed/Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66

77
PROJECT_NAME := ad4630_fmc_zed
88

9-
M_DEPS += system_constr_8sdi.xdc
10-
M_DEPS += system_constr_4sdi.xdc
11-
M_DEPS += system_constr_2sdi.xdc
12-
M_DEPS += system_constr_1sdi.xdc
9+
M_DEPS += system_constr_4sdi_2ch.xdc
10+
M_DEPS += system_constr_4sdi_1ch.xdc
11+
M_DEPS += system_constr_2sdi_2ch.xdc
12+
M_DEPS += system_constr_2sdi_1ch.xdc
13+
M_DEPS += system_constr_1sdi_2ch_interleave.xdc
14+
M_DEPS += system_constr_1sdi_2ch.xdc
15+
M_DEPS += system_constr_1sdi_1ch.xdc
1316
M_DEPS += ../common/ad463x_bd.tcl
1417
M_DEPS += ../../scripts/adi_pd.tcl
1518
M_DEPS += ../../common/zed/zed_system_constr.xdc

0 commit comments

Comments
 (0)