-
Notifications
You must be signed in to change notification settings - Fork 1.6k
library/spi_engine: SDO Extension upgrade #1808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
@@ -69,7 +70,7 @@ module spi_engine_execution #( | |||
|
|||
input echo_sclk, | |||
output reg sclk, | |||
output reg sdo, | |||
output reg [NUM_OF_SDI-1:0] sdo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since now this applies to both sdi and sdo, please rename it to reflect the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my other comment, does it make sense to always have NUM_OF_SDI and NUM_OF_SDO the same? There are chips that have multiple SDO lines (so multiple SPI on the SPI Engine) but only one SDI line (so only one SDO line on the SPI Engine).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I talked to Sergiu and he agreed that having a single parameter for the number of lanes of SDI/SDO is better. The number of active lanes for SDI/SDO could be controlled on the software side by changing its respective lane mask, I am implementing a new register to have a separate mask for the SDI and SDO.
library/spi_engine/spi_engine_execution/spi_engine_execution_shiftreg.v
Outdated
Show resolved
Hide resolved
library/spi_engine/spi_engine_execution/spi_engine_execution_shiftreg.v
Outdated
Show resolved
Hide resolved
library/spi_engine/spi_engine_execution/spi_engine_execution_shiftreg_data_assemble.v
Outdated
Show resolved
Hide resolved
8a2552e
to
15eaefd
Compare
4300d4c
to
6d23286
Compare
@@ -69,7 +70,7 @@ module spi_engine_execution #( | |||
|
|||
input echo_sclk, | |||
output reg sclk, | |||
output reg sdo, | |||
output reg [NUM_OF_SDI-1:0] sdo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my other comment, does it make sense to always have NUM_OF_SDI and NUM_OF_SDO the same? There are chips that have multiple SDO lines (so multiple SPI on the SPI Engine) but only one SDI line (so only one SDO line on the SPI Engine).
df039b8
to
ce44e94
Compare
149396a
to
ab91a18
Compare
cb4785c
to
0ff6ae5
Compare
644dbe7
to
1d4f513
Compare
* 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. 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. Signed-off-by: Carlos Souza <[email protected]>
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. Signed-off-by: Carlos Souza <[email protected]>
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]>
Updated the projects to use NUM_OF_SDIO parameter. It is the same project, no functionality has changed. Signed-off-by: Carlos Souza <[email protected]>
f1c8844
to
15deab1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried testing this with the ad738x_fmc/zed project. It worked with the default NUM_OF_SDI=1 but trying to use FIFO mode fails waiting for the SYNC command when I build with NUM_OF_SDI=4. I might need some help troubleshooting the HDL for that.
|
||
.. _spi_engine sdi-lane-mask-register: | ||
|
||
SDI Lane Mask Register |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this implemented yet? It looks like only SDO Lane mask is implemented so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested the ad738x_fmc with these modifications on my testbench and it is working fine. I just need to set the SDO_LANE_MASK to 8'b1. The testbench is here: https://github.com/analogdevicesinc/testbenches/tree/spi_n_lanes. Could you take a look on it? I hope it helps you out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timeout from writing to this register (0x3) is fixed with the latest update.
clk_div <= DEFAULT_CLK_DIV; | ||
word_length <= DATA_WIDTH; | ||
left_aligned <= 0; | ||
sdo_lane_mask <= ALL_ACTIVE_LANE_MASK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we are going to be able to make this work without it being a breaking change. Setting the default sdo_lane_mask
to ALL_ACTIVE_LANE_MASK
basically breaks all FIFO mode transfers for existing users since before FIFO mode only ever used one lane. But setting it to 1 would break existing users that used multiple lanes with the offload. If we call this v2.0, then the old drivers will fail to load with a useful error message and the updated driver can be made to always program the number of lanes so that we don't have to set a default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this discussion with Laez (@LBFFilho) and Sergiu, it was still on debate if that would break or not. ALL_ACTIVE_LANE_MASK is ((2^NUM_OF_SDIO) - 1). That would only be a problem for situations where the number of active lanes in the beginning is different from the NUM_OF_SDIO. @sarpadi what do you think about that?
SDO Lane Mask Register | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
This register configures the SDO mask that defines which lanes are active |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is SDO from the point of view of the SPI controller or from the peripheral?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is from the SPI controller view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to match how it is implemented. I was testing with AD7386-6 which has 4 SDO lines on the ADC. so from the controller point of view, I would be expecting to enable 4 SDI lines on the controller.
In the driver, I am doing a write command to register 0x4 rather than 0x3 to enable the multiple SDI (controller)/SDO (peripheral) lanes at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a previous commit those addresses were reversed, that is what may have happened. This has been fixed for a while, could you update your branch to the latest commit, please?
I rebuilt the ad738x_fmc/zed project with NUM_OF_SDIO=4 again today (with a change to bump the version to 2.0.0) and changed the driver init to not try to use the unimplemented SDI mask register and made it a bit farther (didn't hit the timeout waiting for SYNC). But the DMA buffer isn't getting filled correctly. I'm guessing this has to do with the SDI mask not being implemented yet? I though maybe the SDO mask was for reading from an ADC, but maybe you are just using it for a DAC so far? |
I continued to refine the software today and apparently changed something that made it a bit happier. The glitch went away, but now I've noticed that I'm not getting any data on 2 out of the 4 SDOs for some reason. Still investigating if this is an issue with the software, the eval board wiring or an HDL problem. Also the data on the FIFO doesn't seem to be coming out in the expected order. Still investigating that as well. |
end | ||
end | ||
|
||
//the current logic is considering that there is only one active lane in the set of lanes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand right that FIFO mode only supports one active lane currently? In other words, we can only enable multiple lanes when using the offload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation allows the programmer to use a single active lane or all active lanes. According to @sarpadi , there is no use case for other masks for the SDO lanes. When in OFFLOAD mode, we are considering that the programmer is activating all lanes for the SDO lanes.
This limitation is not affecting the SDI side for FIFO or OFFLOAD modes. You just need to be careful for not changing the lane mask while executing the OFFLOAD mode.
fix DATA_WIDTH register. Signed-off-by: Carlos Souza <[email protected]>
It was missing the sdi_lane_mask register. That was not affecting execution because the only logic requiring this register is on the axi_spi_engine.v Signed-off-by: Carlos Souza <[email protected]>
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
PR Checklist