Skip to content

Commit

Permalink
[jtag,dv] Sync up with TCK before calling drive_jtag_req
Browse files Browse the repository at this point in the history
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 <rswarbrick@lowrisc.org>
  • Loading branch information
rswarbrick committed May 30, 2024
1 parent a2a3227 commit 5016628
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hw/dv/sv/jtag_agent/jtag_driver.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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);)
Expand Down

0 comments on commit 5016628

Please sign in to comment.