From fb8ea031af42ffb266628d577dfa27d7320d2d7e Mon Sep 17 00:00:00 2001 From: Saad Anees Date: Wed, 14 Feb 2024 17:41:52 +0500 Subject: [PATCH] [usbdev] usbdev scoreboard PR This PR contains usbdev scoreboard with little amendments. Signed-off-by: Saad Anees --- .../dv/env/usbdev_TransactionManager.sv | 17 ++++-- hw/ip/usbdev/dv/env/usbdev_scoreboard.sv | 52 ++++++++++++++++--- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/hw/ip/usbdev/dv/env/usbdev_TransactionManager.sv b/hw/ip/usbdev/dv/env/usbdev_TransactionManager.sv index a659f2c55f45a..c5121daf87df0 100644 --- a/hw/ip/usbdev/dv/env/usbdev_TransactionManager.sv +++ b/hw/ip/usbdev/dv/env/usbdev_TransactionManager.sv @@ -13,6 +13,7 @@ class usbdev_transaction_manager extends uvm_object; data_packet m_data_pkt; hand_shake_packet m_handshake_pkt; usbdev_handshake_pkt_e m_usbdev_handshake_pkt; + usb_transfer_e m_usb_transfer; logic [1:0] state; logic [6:0] address; @@ -99,13 +100,21 @@ class usbdev_transaction_manager extends uvm_object; address = m_usbdev_packet_classifier.address; endpoint = m_usbdev_packet_classifier.endpoint; m_token_pkt.send_token_packet(pid, address, endpoint); - state = 1; + if (m_usbdev_handshake_pkt == STALL) begin + m_usbdev_packet_classifier.pid = PidTypeStall; + pid = m_usbdev_packet_classifier.pid; + m_handshake_pkt.send_handshake_packet(pid); + state = 0; + end + else state = 1; end end 1 : begin // Getting data from data integrity m_usbdev_data_integrity.read(pid, address, endpoint, data); m_data_pkt.send_data_packet(pid, data); - state = 2; + if (m_usb_transfer == IsoTrans) + state = 0; + else state = 2; end 2 : begin m_usbdev_packet_classifier.checkPacket(h_pkt); @@ -148,7 +157,9 @@ class usbdev_transaction_manager extends uvm_object; data = m_usbdev_packet_classifier.data; m_data_pkt.send_data_packet(pid, data); m_usbdev_data_integrity.write(pid, address, endpoint, data); - state = 2; + if (m_usb_transfer == IsoTrans) + state = 0; + else state = 2; end end 2 : begin diff --git a/hw/ip/usbdev/dv/env/usbdev_scoreboard.sv b/hw/ip/usbdev/dv/env/usbdev_scoreboard.sv index 53d0d50205314..3b38c9fe1fcd1 100644 --- a/hw/ip/usbdev/dv/env/usbdev_scoreboard.sv +++ b/hw/ip/usbdev/dv/env/usbdev_scoreboard.sv @@ -39,11 +39,16 @@ class usbdev_scoreboard extends cip_base_scoreboard #( local bit pkt_stall; local bit pkt_sent; local bit stall; + local bit iso_trans; local bit [31:0] ep_out_enable_reg; + local bit [31:0] ep_in_enable_reg; local bit [31:0] rx_enable_setup_reg; local bit [31:0] rx_enable_out_reg; local bit [31:0] out_stall_reg; - local bit [3:0] endp_index; + local bit [31:0] in_stall_reg; + local bit [31:0] out_iso_reg; + local bit [31:0] in_iso_reg; + local bit [3:0] endp_index; `uvm_component_new @@ -110,10 +115,8 @@ class usbdev_scoreboard extends cip_base_scoreboard #( // ------------------------------- virtual task compare_usb20_pkt(); if (actual_pkt_q.size() > 0) begin - repeat(actual_pkt_q.size()) begin - `DV_CHECK_EQ(actual_pkt_q.pop_front(), expected_pkt_q.pop_front()); - `uvm_info(`gfn,"item match",UVM_DEBUG) - end + `DV_CHECK_EQ(actual_pkt_q.pop_front(), expected_pkt_q.pop_front()); + `uvm_info(`gfn,"item match",UVM_DEBUG) end endtask @@ -204,7 +207,7 @@ class usbdev_scoreboard extends cip_base_scoreboard #( end ep_out_enable_reg = ral.ep_out_enable[0].get_mirrored_value(); foreach(ep_out_enable_reg[i]) begin - if (ep_out_enable_reg[i]==1'b1) begin + if (ep_out_enable_reg[i] == 1'b1) begin ep_out_enable = 1'b1; endp_index = i; break; @@ -216,6 +219,13 @@ class usbdev_scoreboard extends cip_base_scoreboard #( if (!write && channel == DataChannel) begin do_read_check = 1'b0; end + ep_in_enable_reg = ral.ep_in_enable[0].get_mirrored_value(); + foreach(ep_in_enable_reg[i]) begin + if (ep_in_enable_reg[i] == 1'b1) begin + endp_index = i; + break; + end + end end "usbstat": begin if (!write && channel == DataChannel) begin @@ -263,15 +273,24 @@ class usbdev_scoreboard extends cip_base_scoreboard #( end end "out_stall": begin + if (!write && channel == DataChannel) begin + do_read_check = 1'b0; + end out_stall_reg = ral.out_stall[0].get_mirrored_value(); if (out_stall_reg[endp_index]) begin stall = 1'b1; end + else stall = 1'b0; end "in_stall": begin if (!write && channel == DataChannel) begin do_read_check = 1'b0; end + in_stall_reg = ral.in_stall[0].get_mirrored_value(); + if (in_stall_reg[endp_index]) begin + stall = 1'b1; + end + else stall = 1'b0; end "configin_0": begin if (!write && channel == DataChannel) begin @@ -337,11 +356,22 @@ class usbdev_scoreboard extends cip_base_scoreboard #( if (!write && channel == DataChannel) begin do_read_check = 1'b0; end + out_iso_reg = ral.out_iso[0].get_mirrored_value(); + if (out_iso_reg[endp_index]) begin + iso_trans = 1'b1; + end + else iso_trans = 1'b0; end "in_iso": begin if (!write && channel == DataChannel) begin do_read_check = 1'b0; - end end + end + in_iso_reg = ral.in_iso[0].get_mirrored_value(); + if (in_iso_reg[endp_index]) begin + iso_trans = 1'b1; + end + else iso_trans = 1'b0; + end "data_toggle_clear": begin // TODO end @@ -390,6 +420,14 @@ class usbdev_scoreboard extends cip_base_scoreboard #( end else if(stall) begin m_usbdev_trans.m_usbdev_handshake_pkt = STALL; end + + // Check weather transfer type is isochoronus or not + if (iso_trans) begin + m_usbdev_trans.m_usb_transfer = IsoTrans; + end + else begin + m_usbdev_trans.m_usb_transfer = CtrlTrans; + end endtask virtual function void reset(string kind = "HARD");