From 5016628363e5694a1cbfb4f02a99a52a0a0ae981 Mon Sep 17 00:00:00 2001 From: Rupert Swarbrick Date: Mon, 13 May 2024 18:32:21 +0100 Subject: [PATCH] [jtag,dv] Sync up with TCK before calling drive_jtag_req This fixes the occasional seed for rv_dm_stress_all. The seq_item_port that get_and_drive samples from isn't always full. It normally gets a new item on a clock edge, but the clock edge is probably for the main clock in the testbench: not the jtag TCK. The result is that we enter drive_jtag_req at some undetermined point in the TCK cycle, and that clock might happen to be running, so the code that was at the start of tms_tdi_step() doesn't necessarily trigger to get us back in sync. This change will sort that out, jumping to the next HOST_CB event at the start of get_and_drive(). Signed-off-by: Rupert Swarbrick --- hw/dv/sv/jtag_agent/jtag_driver.sv | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/dv/sv/jtag_agent/jtag_driver.sv b/hw/dv/sv/jtag_agent/jtag_driver.sv index 4dfba9d7b249a..a51438b8da249 100644 --- a/hw/dv/sv/jtag_agent/jtag_driver.sv +++ b/hw/dv/sv/jtag_agent/jtag_driver.sv @@ -95,6 +95,12 @@ class jtag_driver extends dv_base_driver #(jtag_item, jtag_agent_cfg); $cast(rsp, req.clone()); rsp.set_id_info(req); + // Make sure that we're aligned to HOST_CB (on the negedge of TCK). If we have just finished + // the previous item, this delay is going to add a cycle of TCK, but we're in RunTest/IDLE, + // so it won't cause any harm. + cfg.vif.tck_en <= 1'b1; + @(`HOST_CB); + `uvm_info(`gfn, req.sprint(uvm_default_line_printer), UVM_HIGH) `DV_SPINWAIT_EXIT(drive_jtag_req(req, rsp);, wait (!cfg.vif.trst_n);)