Skip to content

library/spi_engine: fix cs sleep duration for clk_div=0 #1665

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/regmap/adi_regmap_spi_engine.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RO
ENDFIELD

FIELD
[7:0] 0x00000000
[7:0] 0x00000001
VERSION_PATCH
RO
ENDFIELD
Expand Down
2 changes: 1 addition & 1 deletion library/spi_engine/axi_spi_engine/axi_spi_engine.v
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ module axi_spi_engine #(
input [7:0] offload_sync_data
);

localparam PCORE_VERSION = 'h010500;
localparam PCORE_VERSION = 'h010501;
localparam S_AXI = 0;
localparam UP_FIFO = 1;

Expand Down
29 changes: 17 additions & 12 deletions library/spi_engine/spi_engine_execution/spi_engine_execution.v
Original file line number Diff line number Diff line change
Expand Up @@ -309,26 +309,31 @@ module spi_engine_execution #(
end

always @(posedge clk) begin
if (idle == 1'b1 || (cs_sleep_counter_compare && !cs_sleep_repeat && inst_d1 == CMD_CHIPSELECT)) begin
if (idle == 1'b1) begin
bit_counter <= 'h0;
transfer_counter <= 'h0;
sleep_counter <= 'h0;
ntx_rx <= 1'b0;
sleep_counter_increment <= 1'b0;
end else if (clk_div_last == 1'b1 && wait_for_io == 1'b0) begin
if (last_bit && transfer_active && ntx_rx) begin
bit_counter <= 'h0;
transfer_counter <= transfer_counter + 1;
ntx_rx <= ~ntx_rx;
end else begin
if (transfer_active) begin
bit_counter <= bit_counter + ntx_rx;
sleep_counter <= 'h0;
end else begin
if (clk_div_last == 1'b1 && wait_for_io == 1'b0) begin
if (last_bit && transfer_active && ntx_rx) begin
bit_counter <= 'h0;
transfer_counter <= transfer_counter + 1;
ntx_rx <= ~ntx_rx;
end else begin
sleep_counter_increment <= ~sleep_counter_increment;
sleep_counter <= sleep_counter + sleep_counter_increment;
if (transfer_active) begin
bit_counter <= bit_counter + ntx_rx;
ntx_rx <= ~ntx_rx;
end else begin
sleep_counter_increment <= ~sleep_counter_increment;
sleep_counter <= sleep_counter + sleep_counter_increment;
end
end
end
if (cs_sleep_counter_compare && !cs_sleep_repeat && inst_d1 == CMD_CHIPSELECT) begin
sleep_counter <= 'h0;
end
end
end

Expand Down
Loading