[spi_device] Update flip/ watermark ONLY when active

This commit revises the readbuffer module behavior. The module updates
and reports the flip/ watermark events only when active.
The active signal represents the exact time the buffer needs to be
updated. The signal comes from the upper module `readcmd`. It is a pulse
signal that represents the last beat of a byte. (e.g the second beat in
Quad mode).

Signed-off-by: Eunchan Kim <eunchan@opentitan.org>
diff --git a/hw/ip/spi_device/rtl/spid_readbuffer.sv b/hw/ip/spi_device/rtl/spid_readbuffer.sv
index f3f7aba..c912bab 100644
--- a/hw/ip/spi_device/rtl/spid_readbuffer.sv
+++ b/hw/ip/spi_device/rtl/spid_readbuffer.sv
@@ -66,10 +66,6 @@
   output logic event_flip_o
 );
 
-  // FIXME: Update logic
-  logic unused_address_update;
-  assign unused_address_update = address_update_i;
-
   ////////////////
   // Definition //
   ////////////////
@@ -102,9 +98,6 @@
   // Datapath //
   //////////////
 
-  assign active = (st_q == StActive)
-                && (spi_mode_i == spi_device_pkg::FlashMode);
-
   // Flip event handling
   always_ff @(posedge clk_i or negedge sys_rst_ni) begin
     if (!sys_rst_ni) begin
@@ -165,16 +158,23 @@
   always_comb begin
     st_d = st_q;
 
+    active = 1'b 0;
+
     unique case (st_q)
       StIdle: begin
-        if (start_i && !sfdp_hit_i && !(mailbox_en_i && mailbox_hit_i)) begin
+        if (start_i && (spi_mode_i == spi_device_pkg::FlashMode)
+           && !sfdp_hit_i && !(mailbox_en_i && mailbox_hit_i)) begin
           st_d = StActive;
+
+          active = 1'b 1; // Assume address_update_i is high
         end
       end
 
       StActive: begin
         // Deadend waiting CSb de-assertion
         st_d = StActive;
+
+        active = address_update_i;
       end
 
       default: begin
@@ -183,4 +183,6 @@
     endcase
   end
 
+  `ASSERT(StartWithAddressUpdate_A, start_i |-> address_update_i)
+
 endmodule : spid_readbuffer