Skip to content

Commit

Permalink
[usbdev] Usbdev DV environment PR
Browse files Browse the repository at this point in the history
Adds updates in usb20_driver to support Isochronous transactions and
also SoF packets.

Adds small changes in item class and usb_agent_pkg class to supports
above change.

Signed-off-by: Mubashir Saleem <[email protected]>
  • Loading branch information
MubashirSaleem775 authored and jdonjdon committed Feb 12, 2024
1 parent 2d0e611 commit f544ba4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions hw/dv/sv/usb20_agent/usb20_agent_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ package usb20_agent_pkg;
bRequestSET_DESCRIPTOR = 8'h07, bRequestGET_CONFIGURATION = 8'h08,
bRequestSET_CONFIGURATION = 8'h09, bRequestGET_INTERFACE = 8'h0A,
bRequestSET_INTERFACE = 8'h0B, bRequestSYNCH_FRAME = 8'h0C} brequest_e;
typedef enum bit [2:0] {CtrlTrans, IsoTrans, IntrptTrans, BulkTrans} usb_transfer_e;
// local types
// forward declare classes to allow typedefs below
typedef class usb20_item;
Expand Down
34 changes: 31 additions & 3 deletions hw/dv/sv/usb20_agent/usb20_driver.sv
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class usb20_driver extends dv_base_driver #(usb20_item, usb20_agent_cfg);
token_pkt m_token_pkt;
data_pkt m_data_pkt ;
handshake_pkt m_handshake_pkt;
sof_pkt m_sof_pkt;

function void build_phase(uvm_phase phase);
super.build_phase(phase);
Expand Down Expand Up @@ -107,8 +108,15 @@ class usb20_driver extends dv_base_driver #(usb20_item, usb20_agent_cfg);
end
`uvm_info(`gfn, $sformatf("Complete Data_Packet = %p", comp_data_pkt), UVM_DEBUG)
drive_pkt(comp_data_pkt);
get_dut_response(rsp_item);
seq_item_port.item_done(rsp_item);
`uvm_info(`gfn, $sformatf("\n\nTransfer Type = %s", seq_item.m_usb_transfer), UVM_HIGH)
if (seq_item.m_usb_transfer == IsoTrans) begin
seq_item_port.item_done();
`uvm_info(`gfn, $sformatf("\n\nTransfer Type = %s", seq_item.m_usb_transfer), UVM_HIGH)
end else begin
`uvm_info(`gfn, $sformatf("\n\nTransfer Type = %s", seq_item.m_usb_transfer), UVM_HIGH)
get_dut_response(rsp_item);
seq_item_port.item_done(rsp_item);
end
endtask

task prepare_handshake_packet(usb20_item seq_item, usb20_item rsp_item);
Expand All @@ -133,7 +141,27 @@ class usb20_driver extends dv_base_driver #(usb20_item, usb20_agent_cfg);
endtask

task prepare_sof_packet( usb20_item seq_item, usb20_item rsp_item);
// TODO: Drive method to drive SOF packet
bit driver_sof_pkt[];
bit comp_sof_pkt[];
$cast(m_sof_pkt, seq_item);
m_sof_pkt.print();
// Modified each field of the packet to start with the Least Significant Bit (LSB)
m_sof_pkt.m_pid_type = {<<4{m_sof_pkt.m_pid_type}};
m_sof_pkt.m_pid_type = {<<{m_sof_pkt.m_pid_type}};
m_sof_pkt.framecnt = {<<{m_sof_pkt.framecnt}};
m_sof_pkt.crc5 = {<<{m_sof_pkt.crc5}};
m_sof_pkt.pack(driver_sof_pkt);
// to make complete packet need to attach SYNC at start of packet
comp_sof_pkt = new[driver_sof_pkt.size() + 8];
for (int i = 0; i < 8; i++) begin
comp_sof_pkt[i] = SYNC_PATTERN[i];
end
for (int i = 0; i < driver_sof_pkt.size(); i++) begin
comp_sof_pkt[i + 8] = driver_sof_pkt[i];
end
`uvm_info(`gfn, $sformatf("Complete Sof_Packet = %p", comp_sof_pkt), UVM_HIGH)
drive_pkt(comp_sof_pkt);
seq_item_port.item_done();
endtask

task drive_pkt(bit comp_pkt[]);
Expand Down
1 change: 1 addition & 0 deletions hw/dv/sv/usb20_agent/usb20_item.sv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class usb20_item extends uvm_sequence_item;
pkt_type_e m_pkt_type;
bmrequesttype_e m_bmRT;
brequest_e m_bR;
usb_transfer_e m_usb_transfer;

`uvm_object_new

Expand Down

0 comments on commit f544ba4

Please sign in to comment.