Skip to content

library/spi_engine: SDO Extension upgrade#1808

Open
caosjr wants to merge 3 commits into
mainfrom
sdo_extension_spi_engine
Open

library/spi_engine: SDO Extension upgrade#1808
caosjr wants to merge 3 commits into
mainfrom
sdo_extension_spi_engine

Conversation

@caosjr
Copy link
Copy Markdown
Contributor

@caosjr caosjr commented Jul 1, 2025

PR Description

Upgrade SPI engine to support up to 8 lanes. For that, two new registers were inserted into Configuration Write Instruction, they are responsible for setting the SDI and SDO lane masks. Each bit represents a lane.
This PR also removes register 8'h3b from the SPI Engine regmap.
The testbench for this modification is here: analogdevicesinc/testbenches#240

PR Type

  • Bug fix (change that fixes an issue)
  • New feature (change that adds new functionality)
  • Breaking change (has dependencies in other repos or will cause CI to fail)
  • Documentation

PR Checklist

  • I have followed the code style guidelines
  • I have performed a self-review of changes
  • I have compiled all hdl projects and libraries affected by this PR
  • I have tested in hardware affected projects, at least on relevant boards
  • I have commented my code, at least hard-to-understand parts
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe files, Copyright etc)
  • I have not introduced new Warnings/Critical Warnings on compilation
  • I have added new hdl testbenches or updated existing ones

Copy link
Copy Markdown
Contributor

@LBFFilho LBFFilho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this seems headed in a nice direction, and thanks for also doing a lot of small fixes and improvements to the existing code along the way.

About the version: is this going to be a minor version or a major version bump? I understand that the removed register was not used anywhere (it was broken even), but technically we're breaking anything that relied on it. Also changing the behavior of the SDI & SDO FIFOs.

Also, please check timing on ad4052/de10nano just to be sure if it's all good.

Comment thread docs/library/spi_engine/spi_engine_interconnect.rst Outdated
Comment thread docs/regmap/adi_regmap_spi_engine.txt Outdated
Comment thread docs/library/spi_engine/spi_engine_interconnect.rst Outdated
Comment thread docs/library/spi_engine/spi_engine_interconnect.rst Outdated
Comment thread library/spi_engine/axi_spi_engine/axi_spi_engine.v Outdated
Comment thread library/spi_engine/spi_engine_execution/spi_engine_execution.v Outdated
Comment thread library/spi_engine/spi_engine_execution/spi_engine_execution.v Outdated
Comment thread library/spi_engine/spi_engine_execution/spi_engine_execution_shiftreg.v Outdated
Comment thread library/spi_engine/spi_engine_execution/spi_engine_execution_shiftreg.v Outdated
Comment thread docs/library/spi_engine/instruction-format.rst Outdated
Comment thread docs/library/spi_engine/instruction-format.rst Outdated
Comment thread docs/library/spi_engine/instruction-format.rst Outdated
Comment thread docs/library/spi_engine/instruction-format.rst Outdated
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch 3 times, most recently from 8a2552e to 15eaefd Compare July 4, 2025 14:44
@caosjr caosjr changed the title library/spi_engine: Extend SDO support for the SPI Engine library/spi_engine: SDO Extension upgrade Jul 7, 2025
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch 4 times, most recently from 4300d4c to 6d23286 Compare July 10, 2025 13:53
Comment thread docs/library/spi_engine/axi_spi_engine.rst Outdated
Comment thread docs/library/spi_engine/instruction-format.rst Outdated
Comment thread library/spi_engine/spi_engine_execution/spi_engine_execution.v Outdated
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch from df039b8 to ce44e94 Compare August 5, 2025 19:36
@caosjr caosjr marked this pull request as ready for review August 7, 2025 12:59
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch 2 times, most recently from 149396a to ab91a18 Compare August 7, 2025 15:14
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch 2 times, most recently from cb4785c to 0ff6ae5 Compare August 7, 2025 15:19
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch from 5cf2987 to 3692374 Compare September 19, 2025 13:11
@dlech
Copy link
Copy Markdown
Collaborator

dlech commented Sep 19, 2025

I've tested this again today with the latest rebase. Seems to be working OK still.

So the only request from my side still remaining is bumping the SPI Engine IP version to 2.0.0.

Comment thread projects/ad4630_fmc/common/ad463x_bd.tcl Outdated
Comment thread projects/ad4630_fmc/common/ad463x_bd.tcl Outdated
Comment thread docs/projects/ad4630_fmc/index.rst
@caosjr
Copy link
Copy Markdown
Contributor Author

caosjr commented Sep 23, 2025

I have updated the version of the SPI Engine to 2.0 and solved the issues of the tcl scripts.

@caosjr caosjr force-pushed the sdo_extension_spi_engine branch from 0f4024a to e1fbc2e Compare September 29, 2025 16:47
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch from d95ada4 to 7516b6e Compare February 24, 2026 15:18
@dlech
Copy link
Copy Markdown
Collaborator

dlech commented Feb 24, 2026

The SPI driver changes have been accepted upstream in the Linux kernel and included in kernel v7.0. So we can now backport those changes to the ADI kernel tree and get this merged.

@caosjr caosjr force-pushed the sdo_extension_spi_engine branch 3 times, most recently from ba03905 to 6d7734a Compare February 24, 2026 18:03
@caosjr caosjr requested a review from LBFFilho February 24, 2026 18:13
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch 2 times, most recently from ecb512f to 8f53cd1 Compare March 10, 2026 13:05
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch from 8f53cd1 to 626aeef Compare March 16, 2026 16:31
@caosjr caosjr marked this pull request as ready for review March 19, 2026 12:41
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch 2 times, most recently from f5d9317 to db7bc42 Compare March 25, 2026 17:12
Copy link
Copy Markdown
Contributor

@IstvanZsSzekely IstvanZsSzekely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was asked to check the util_axis_fifo_asym changes in this PR.
The suggested modification with an added AXI4Stream register slice kind of does and doesn't belong to it. It makes sense to add it to ensure better timing overall, but at the same time I can imagine it being used without knowing why. Helps timing? Yes. Then just add it and don't think about it. And I would like to avoid this if possible. If you want to add the slice to the SPI Engine to ease timing, I would suggest doing it outside of the FIFO, as it maintains the boundaries of the core.
I built the AD4630 with a couple of parameter options provided by @sarpadi without the util_axis_fifo_asym changes and I did not see a timing violation on the module. However, I did see some timing violations on in the SPI Engine. Built with Vivado version 2025.1
Here are the build parameters I used:
make CLK_MODE=1 NUM_OF_CHANNEL=2 LANES_PER_CHANNEL=4 CAPTURE_ZONE=2 DDR_EN=1
make CLK_MODE=1 NUM_OF_CHANNEL=2 LANES_PER_CHANNEL=4 CAPTURE_ZONE=2 DDR_EN=0
make CLK_MODE=0 NUM_OF_CHANNEL=2 LANES_PER_CHANNEL=4 CAPTURE_ZONE=2 DDR_EN=0

@caosjr
Copy link
Copy Markdown
Contributor Author

caosjr commented Mar 31, 2026

I was asked to check the util_axis_fifo_asym changes in this PR. The suggested modification with an added AXI4Stream register slice kind of does and doesn't belong to it. It makes sense to add it to ensure better timing overall, but at the same time I can imagine it being used without knowing why. Helps timing? Yes. Then just add it and don't think about it. And I would like to avoid this if possible. If you want to add the slice to the SPI Engine to ease timing, I would suggest doing it outside of the FIFO, as it maintains the boundaries of the core. I built the AD4630 with a couple of parameter options provided by @sarpadi without the util_axis_fifo_asym changes and I did not see a timing violation on the module. However, I did see some timing violations on in the SPI Engine. Built with Vivado version 2025.1 Here are the build parameters I used: make CLK_MODE=1 NUM_OF_CHANNEL=2 LANES_PER_CHANNEL=4 CAPTURE_ZONE=2 DDR_EN=1 make CLK_MODE=1 NUM_OF_CHANNEL=2 LANES_PER_CHANNEL=4 CAPTURE_ZONE=2 DDR_EN=0 make CLK_MODE=0 NUM_OF_CHANNEL=2 LANES_PER_CHANNEL=4 CAPTURE_ZONE=2 DDR_EN=0

I already tried to put this register slice outside the "util_axis_fifo_asym", it does not work for timing issues. The issue is raised then there are several lanes, for example 2 channels with 4 sdi lanes each (8 sdi lanes in total). The problem does not happen everytime, our tests passed 30% of the time. The critical path involves the "util_axis_fifo_address_generator.v" (line 155) inside the "util_axis_fifo" and the "util_axis_fifo_asym" (for our case, line 169). We need to break this path inside the library, any external solution will not work.

Regarding the usage, I put a parameter SRC_REG_SLICE_EN that is disabled by default. So the other projects would not be using it unless it is required. I also updated the documentation for that in this PR: #2031. I just left the commit over here so the other could test the project without a timing failure.

@caosjr caosjr requested a review from IstvanZsSzekely April 14, 2026 17:09
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch from db7bc42 to 967ce34 Compare April 20, 2026 12:48
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch 2 times, most recently from a4b112b to a766578 Compare May 4, 2026 17:10
@machschmitt
Copy link
Copy Markdown

I see there might still be HDL issues to discuss. Just for the record, the related Linux kernel updates have been merged into ADI Linux main branch (analogdevicesinc/linux#3158). So, we can now also test HDL updates with the main kernel from ADI, if needed.

caosjr added 3 commits May 12, 2026 09:59
* Extend SDO support to 8 (symmetrical with SDI support);
* Update SDI to use asymmetrical FIFO;
* Insert symmetrical FIFO for the SDO;
* Insert SDI lane mask configuration instruction to reg 3'b011;
* Insert SDO lane mask configuration instruction to reg 3'b100;
* Insert offload active interface for interconnect and execution;
* Remove register 8'h3b from spi engine regmap;
* Improvements on the critical paths of the execution module.

Prefetching on offload work iff all lanes are active.

There is a different register for SDI lane mask and SDO
lane mask;
Update the NUM_OF_SDI parameter to NUM_OF_SDIO parameter to reflect
that both SDI and SDO are symmetrical. The control over them is
through the SDI/SDO lane masks.

Inserts a ready signal for when the valid_indices
has finished its inner logic. This avoid the possible
issue where the latency of the command is smaller than
this logic. This could only happen in the FIFO mode.

Introduces logic to keep track of the number of elements in
the SDI FIFO. This is due to the asymmetric FIFO implementation
not including the logic for this, and instead outputting the
level of one of its internal FIFOs.

The modifications performed in this library are not backwards compatible. So
this version is Spi Engine 2.0.

Signed-off-by: Laez Barbosa <[email protected]>
Signed-off-by: Carlos Souza <[email protected]>
* Update documentation to include the changes done
for supporting more than one SDO lane.
* Update the register map;
* Insert SDI/SDO lane mask registers;
* Update Configuration Write Instruction;
* Update parameter from NUM_OF_SDI to NUM_OF_SDIO.

Update NUM_OF_SDI to NUM_OF_SDIO in the projects documentations.
The variable was updated on the spi_engine library since SDI and
SDO have symmetrical sizes.

Signed-off-by: Carlos Souza <[email protected]>
Updates the projects to use SPI ENGINE 2.0.

Also adds optimization options for timing closure of
the AD4052 project. Removes wrong timing constraints
for the coraz7s carrier.

Signed-off-by: Carlos Souza <[email protected]>
@caosjr caosjr force-pushed the sdo_extension_spi_engine branch from a766578 to 4734cb3 Compare May 12, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants