Skip to content

Commit f876e1c

Browse files
target: Align virtual_device_sel with other control signals
Fix for issue chipsalliance#184. This commit removes a 1-cycle delay from virtual_device_sel_o in the target FSM to align it with the related control signals around private read transactions. Co-authored-by: Florian Glaser <glaserf@lowrisc.org> Signed-off-by: Kacper Słomiński <kslominski@antmicro.com>
1 parent 4b5a030 commit f876e1c

1 file changed

Lines changed: 26 additions & 25 deletions

File tree

‎src/ctrl/i3c_target_fsm.sv‎

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ module i3c_target_fsm import i3c_pkg::*; (
152152
logic bus_addr_valid;
153153
logic bus_rnw_d, bus_rnw_q;
154154
i3c_addr_t bus_addr_d, bus_addr_q;
155+
logic virtual_device_sel_d, virtual_device_sel_q;
155156

156157
logic is_our_addr_match, is_virtual_addr_match, is_any_addr_match, is_rsvd_byte_match;
157158

@@ -451,7 +452,25 @@ module i3c_target_fsm import i3c_pkg::*; (
451452
endcase
452453
end
453454

455+
// Latching of virtual device selection
456+
always_comb begin
457+
virtual_device_sel_d = virtual_device_sel_q;
458+
virtual_device_sel_o = virtual_device_sel_q;
459+
460+
if (bus_any_start_det || bus_stop_det_i) begin
461+
// Clear on Start/Repeated Start/Stop - transaction boundary
462+
virtual_device_sel_d = 1'b0;
463+
end else if (state_q inside {CheckFByte, CheckSByte}) begin
464+
// Set on virtual address match with first or second byte address headers
465+
virtual_device_sel_d = is_virtual_addr_match;
466+
// Forward the next value of the flop to align with other bus framing control signals
467+
virtual_device_sel_o = is_virtual_addr_match;
468+
end
469+
end
470+
454471
// Main FSM
472+
assign target_idle_o = (state_q == Idle);
473+
455474
always_comb begin : fsm_target_main
456475
tx_pr_start_o = 1'b0;
457476
tx_pr_abort_o = 1'b0;
@@ -850,39 +869,21 @@ module i3c_target_fsm import i3c_pkg::*; (
850869
end
851870
end
852871

853-
// Synchronous state transition
872+
// Flops for state and control signals driven by always_comb processes
854873
always_ff @(posedge clk_i or negedge rst_ni) begin : state_transition
855874
if (!rst_ni) begin
856875
state_q <= Idle;
857-
ibi_retry_cnt_q <= 3'd0;
858-
ibi_inhibit_q <= InhibitNone;
876+
ibi_retry_cnt_q <= 3'd0;
877+
ibi_inhibit_q <= InhibitNone;
878+
virtual_device_sel_q <= 1'b0;
859879
end else begin
860880
state_q <= state_d;
861-
ibi_retry_cnt_q <= ibi_retry_cnt_d;
862-
ibi_inhibit_q <= ibi_inhibit_d;
881+
ibi_retry_cnt_q <= ibi_retry_cnt_d;
882+
ibi_inhibit_q <= ibi_inhibit_d;
883+
virtual_device_sel_q <= virtual_device_sel_d;
863884
end
864885
end
865886

866-
assign target_idle_o = (state_q == Idle);
867-
868-
always_ff @(posedge clk_i or negedge rst_ni) begin : virtual_device_sel_latch
869-
if (!rst_ni) begin
870-
virtual_device_sel_o <= '0;
871-
end else if (bus_any_start_det || bus_stop_det_i) begin
872-
// Clear on Start/Repeated Start/Stop - transaction boundary
873-
virtual_device_sel_o <= '0;
874-
end else unique case(state_q)
875-
CheckFByte:
876-
if (!is_rsvd_byte_match && virtual_device_sel_o != is_virtual_addr_match)
877-
virtual_device_sel_o <= is_virtual_addr_match;
878-
CheckSByte:
879-
if (!is_rsvd_byte_match && virtual_device_sel_o != is_virtual_addr_match)
880-
virtual_device_sel_o <= is_virtual_addr_match;
881-
default:
882-
virtual_device_sel_o <= virtual_device_sel_o;
883-
endcase
884-
end
885-
886887
always_ff @(posedge clk_i or negedge rst_ni) begin
887888
if (!rst_ni) begin
888889
xfer_in_progress_o <= '0;

0 commit comments

Comments
 (0)