Skip to content

Commit

Permalink
[jtag,dv] Handle trst_n at start of time in jtag_driver.sv
Browse files Browse the repository at this point in the history
The existing code worked as long as the get_and_drive() task started
after we had driven trst_n to zero AND we didn't ever want to drive it
to zero afterwards.

It turns out that this wasn't the situation I was seeing in my
simulations and the result was that the driver thought the JTAG FSM
was in the RTI state, but it was actually in Test-Logic-Reset and
everything got rather confused.

With this change, we will always notice if we see a trst_n reset, and
the driver and bus shouldn't get out of sync in the same way.

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
  • Loading branch information
rswarbrick committed May 30, 2024
1 parent 9f033e4 commit a2a3227
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions hw/dv/sv/jtag_agent/jtag_driver.sv
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,35 @@ class jtag_driver extends dv_base_driver #(jtag_item, jtag_agent_cfg);
`DV_CHECK_FATAL(cfg.if_mode == Host, "Only Host mode is supported", "jtag_driver")

forever begin
// Wait until we either go into reset or we get an item to drive.
fork : isolation_fork
begin
fork
wait (! cfg.vif.trst_n);
seq_item_port.get_next_item(req);
join_any
disable fork;
end
join

if (!cfg.vif.trst_n) begin
`DV_WAIT(cfg.vif.trst_n)
cfg.vif.wait_tck(1);
drive_jtag_test_logic_reset();
end else begin
// Since trst_n is not 0, the get_next_item() task must have completed and has written the
// request to req
$cast(rsp, req.clone());
rsp.set_id_info(req);

`uvm_info(`gfn, req.sprint(uvm_default_line_printer), UVM_HIGH)
`DV_SPINWAIT_EXIT(drive_jtag_req(req, rsp);,
wait (!cfg.vif.trst_n);)

// Mark the item as having been handled. This passes the response (rsp) back to the
// sequencer, and also pops the request that we have been handling.
seq_item_port.item_done(rsp);
end
seq_item_port.get_next_item(req);
$cast(rsp, req.clone());
rsp.set_id_info(req);
`uvm_info(`gfn, req.sprint(uvm_default_line_printer), UVM_HIGH)
`DV_SPINWAIT_EXIT(drive_jtag_req(req, rsp);,
wait (!cfg.vif.trst_n);)
seq_item_port.item_done(rsp);
end
endtask

Expand Down

0 comments on commit a2a3227

Please sign in to comment.