[spi_dev] Attempt to fix combo loop
A combo loop was observed through the following path
data_i -> dp_sel -> data_o, which then loops back to data_i.
The issue is because in cmdparse the upload case immediately
selects a new datapath because there are no more guaranteed clocks
for certain commands. However, this same combo selection does not
have to be used for the read return path, so the fix just flops the
read return on spi_clk_out (spi_clk_in might also be okay)
Signed-off-by: Timothy Chen <timothytim@google.com>
diff --git a/hw/ip/spi_device/rtl/spi_device.sv b/hw/ip/spi_device/rtl/spi_device.sv
index 949a287..b28e434 100644
--- a/hw/ip/spi_device/rtl/spi_device.sv
+++ b/hw/ip/spi_device/rtl/spi_device.sv
@@ -155,7 +155,7 @@
logic sub_p2s_sent[IoModeEnd];
// CMD interface
- sel_datapath_e cmd_dp_sel;
+ sel_datapath_e cmd_dp_sel, cmd_dp_sel_outclk;
spi_byte_t cmd_opcode;
@@ -496,6 +496,11 @@
else io_mode_outclk <= io_mode;
end
+ always_ff @(posedge clk_spi_out_buf or negedge rst_spi_n) begin
+ if (!rst_spi_n) cmd_dp_sel_outclk <= DpNone;
+ else cmd_dp_sel_outclk <= cmd_dp_sel;
+ end
+
always_comb begin
io_mode = SingleIO;
p2s_valid = 1'b 0;
@@ -530,7 +535,7 @@
end
FlashMode: begin
- unique case (cmd_dp_sel)
+ unique case (cmd_dp_sel_outclk)
DpNone: begin
io_mode = sub_iomode[IoModeCmdParse];