Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions hw/dv/sv/i2c_agent/seq_lib/i2c_base_seq.sv
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,21 @@ class i2c_base_seq extends dv_base_seq #(
endtask : send_device_mode_txn


virtual task drive_addr_byte_ack();
local task drive_ack(input drv_type_e drv_type = DevAck);
`uvm_create_obj(REQ, req);
start_item(req);
req.drv_type = DevAck;
`uvm_info(`gfn,
$sformatf("%sing the byte!", ((drv_type == DevAck) ? "ACK" : "NACK")),
UVM_LOW)
Copy link
Copy Markdown
Contributor Author

@KinzaQamar KinzaQamar May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now notices that this uvm_info will create alot of noise

req.drv_type = drv_type;
finish_item(req);
endtask : drive_ack

virtual task drive_addr_byte_ack(input drv_type_e drv_type = DevAck);
drive_ack(drv_type);
`uvm_info(`gfn, "drive_addr_byte_ack()::finish_item()", UVM_DEBUG)
endtask : drive_addr_byte_ack


virtual task drive_read_byte(bit [7:0] rdata);
`uvm_create_obj(REQ, req);
start_item(req);
Expand All @@ -156,12 +162,8 @@ class i2c_base_seq extends dv_base_seq #(
`uvm_info(`gfn, "drive_read_byte()::finish_item()", UVM_DEBUG)
endtask : drive_read_byte


virtual task drive_write_byte_ack();
`uvm_create_obj(REQ, req);
start_item(req);
req.drv_type = DevAck;
finish_item(req);
virtual task drive_write_byte_ack(input drv_type_e drv_type = DevAck);
drive_ack(drv_type);
`uvm_info(`gfn, "drive_write_byte_ack()::finish_item()", UVM_DEBUG)
endtask : drive_write_byte_ack

Expand Down
4 changes: 2 additions & 2 deletions hw/dv/sv/i2c_agent/seq_lib/i2c_device_response_seq.sv
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class i2c_device_response_seq extends i2c_base_seq;

// This method hooks the end of every data byte in an in-progress WRITE transfer.
// Store the data byte into the local memory, for recall by the next read operation.
virtual task drive_write_byte_ack();
virtual task drive_write_byte_ack(input drv_type_e drv_type = DevAck);
bit[Addr7BitMode-1:0] xfer_addr = inp_xfer.addr[Addr7BitMode-1:0];

response_mem[xfer_addr].push_back(inp_xfer.data_q[$]);
Expand All @@ -71,7 +71,7 @@ class i2c_device_response_seq extends i2c_base_seq;

// Drive the ACK to this write byte.
// This sequence will always ACK all write bytes.
super.drive_write_byte_ack();
super.drive_write_byte_ack(drv_type);
endtask : drive_write_byte_ack


Expand Down
38 changes: 8 additions & 30 deletions hw/dv/sv/i2c_agent/seq_lib/i2c_target_may_nack_seq.sv
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,17 @@ class i2c_target_may_nack_seq extends i2c_base_seq;
/////////////
// METHODS //
/////////////


virtual function void randomize_ack();
`DV_CHECK_STD_RANDOMIZE_FATAL(acknack);
case (acknack)
i2c_pkg::ACK: req.drv_type = DevAck;
i2c_pkg::NACK: req.drv_type = DevNack;
default: `uvm_fatal(`gfn, "Shouldn't get here!")
endcase
endfunction : randomize_ack


virtual task drive_addr_byte_ack();
`uvm_create_obj(REQ, req);
start_item(req);

// The base class / default behaviour is to ACK all address bytes.
// Here, choose randomly between ACK and NACK.
randomize_ack();
if (req.drv_type == DevNack) `uvm_info(`gfn, "NACKing the address byte!", UVM_LOW)

finish_item(req);
virtual task drive_addr_byte_ack(input drv_type_e drv_type = DevAck);
// Choose to Ack and Nack 50% of the time
drv_type = ($urandom_range(0,1)) ? DevAck : DevNack;
super.drive_addr_byte_ack(drv_type);
endtask : drive_addr_byte_ack


virtual task drive_write_byte_ack();
`uvm_create_obj(REQ, req);
start_item(req);

randomize_ack();
if (req.drv_type == DevNack) `uvm_info(`gfn, "NACKing a data byte!", UVM_LOW)

finish_item(req);
virtual task drive_write_byte_ack(input drv_type_e drv_type = DevAck);
// Choose to Ack and Nack 50% of the time
drv_type = ($urandom_range(0,1)) ? DevAck : DevNack;
super.drive_write_byte_ack(drv_type);
endtask : drive_write_byte_ack


Expand Down
Loading