Skip to content

Commit

Permalink
[usbdev] scoreboard of usbdev
Browse files Browse the repository at this point in the history
this request contains integration of predictor in usbdev scoreboard
class.

Signed-off-by: Saad Anees <[email protected]>
  • Loading branch information
Saad-Anees1 committed Dec 22, 2023
1 parent 2cd6648 commit 7d4225b
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hw/dv/sv/usb20_agent/usb20_item.sv
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef enum bit [7:0] {PidTypeOutToken=8'b0001_1110, PidTypeInToken=8'b1001_011
PidTypeAck=8'b0010_1101, PidTypeNak=8'b1010_0101, PidTypeStall=8'b1110_0001,
PidTypeNyet=8'b0110_1001} pid_type_e;

virtual class usb20_item extends uvm_sequence_item;
class usb20_item extends uvm_sequence_item;
pid_type_e m_pid_type;
pkt_type_e m_pkt_type;

Expand Down
5 changes: 5 additions & 0 deletions hw/ip/usbdev/dv/env/usbdev_env.core
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ filesets:
- usbdev_env_cfg.sv: {is_include_file: true}
- usbdev_env_cov.sv: {is_include_file: true}
- usbdev_virtual_sequencer.sv: {is_include_file: true}
- usbdev_packetiser.sv: {is_include_file: true}
- usbdev_packet_classifier.sv: {is_include_file: true}
- usbdev_data_integrity.sv: {is_include_file: true}
- usbdev_pkt_manager.sv: {is_include_file: true}
- usbdev_TransactionManager.sv: {is_include_file: true}
- usbdev_scoreboard.sv: {is_include_file: true}
- usbdev_env.sv: {is_include_file: true}
- seq_lib/usbdev_vseq_list.sv: {is_include_file: true}
Expand Down
5 changes: 5 additions & 0 deletions hw/ip/usbdev/dv/env/usbdev_env_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ package usbdev_env_pkg;
`include "usbdev_env_cfg.sv"
`include "usbdev_env_cov.sv"
`include "usbdev_virtual_sequencer.sv"
`include "usbdev_packetiser.sv"
`include "usbdev_packet_classifier.sv"
`include "usbdev_data_integrity.sv"
`include "usbdev_pkt_manager.sv"
`include "usbdev_TransactionManager.sv"
`include "usbdev_scoreboard.sv"
`include "usbdev_env.sv"
`include "usbdev_vseq_list.sv"
Expand Down
108 changes: 104 additions & 4 deletions hw/ip/usbdev/dv/env/usbdev_scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ class usbdev_scoreboard extends cip_base_scoreboard #(
);
`uvm_component_utils(usbdev_scoreboard)

// local variables
usbdev_packetiser m_packetiser;
usbdev_TransactionManager m_usbdev_trans;
usbdev_pkt_manager m_pkt_manager;
usb20_item m_usb20_item;

// Arrays to store actual packet and expected packet
bit expected_pkt[];
bit actual_pkt[];

// TLM agent fifos
uvm_tlm_analysis_fifo #(usb20_item) usb20_fifo;
Expand All @@ -25,6 +32,10 @@ class usbdev_scoreboard extends cip_base_scoreboard #(

function void build_phase(uvm_phase phase);
super.build_phase(phase);
m_packetiser = new();
m_pkt_manager = new();
m_usbdev_trans = new();
m_usb20_item = new();
usb20_fifo = new("usb20_fifo", this);
endfunction

Expand All @@ -42,11 +53,27 @@ class usbdev_scoreboard extends cip_base_scoreboard #(
virtual task process_usb20_fifo();
usb20_item item;
forever begin
usbdev_expected_pkt();
usb20_fifo.get(item);
`uvm_info(`gfn, $sformatf("received usb20 item:\n%0s", item.sprint()), UVM_HIGH)
item.pack(actual_pkt);
`uvm_info(`gfn, $sformatf("received usb20 item :\n%0s", item.sprint()), UVM_DEBUG)
`uvm_info(`gfn, $sformatf("ACTUAL PACKET : %p", actual_pkt), UVM_DEBUG)
end
endtask

// usbdev_expected_pkt task : To run the predictor
// and compare the actual pkt with expected pkt
// -------------------------------
virtual task usbdev_expected_pkt();
m_packetiser.pack_pkt(m_usb20_item);
m_usbdev_trans.transaction_manager(m_packetiser.token_pkt_arr, m_packetiser.data_pkt_arr,
m_packetiser.handshake_pkt_arr);
m_pkt_manager.pop_packet(expected_pkt);
`uvm_info(`gfn, $sformatf("EXPECTED PACKET : %p", expected_pkt), UVM_DEBUG)
foreach(actual_pkt[i])
`DV_CHECK_EQ(actual_pkt[i], expected_pkt[i]);
endtask

virtual task process_tl_access(tl_seq_item item, tl_channels_e channel, string ral_name);
uvm_reg csr;
bit do_read_check = 1'b1;
Expand All @@ -72,6 +99,7 @@ class usbdev_scoreboard extends cip_base_scoreboard #(
// process the csr req
// for write, update local variable and fifo at address phase
// for read, update predication at address phase and compare at data phase

case (csr.get_name())
// add individual case item for each csr
"usbctrl": begin
Expand Down Expand Up @@ -114,6 +142,72 @@ class usbdev_scoreboard extends cip_base_scoreboard #(
end
end // read & data phase
end
"alert_test": begin
// TODO
end
"ep_out_enable": begin
// TODO
end
"ep_in_enable": begin
// TODO
end
"usbstat": begin
do_read_check = 1'b0;
end
"avbuffer": begin
// TODO
end
"rxfifo": begin
do_read_check = 1'b0;
end
"rxenable_setup": begin
// TODO
end
"rxenable_out": begin
// TODO
end
"set_nak_out": begin
// TODO
end
"in_sent": begin
// TODO
end
"out_stall": begin
// TODO
end
"in_stall": begin
// TODO
end
"configin": begin
// TODO
end
"out_iso": begin
// TODO
end
"in_iso": begin
// TODO
end
"data_toggle_clear": begin
// TODO
end
"phy_pins_sense": begin
// TODO
end
"phy_pin_drive": begin
// TODO
end
"phy_config": begin
// TODO
end
"wake_control": begin
// TODO
end
"wake_events": begin
// TODO
end
"buffer": begin
// TODO
end
default: begin
`uvm_fatal(`gfn, $sformatf("invalid csr: %0s", csr.get_full_name()))
end
Expand All @@ -131,12 +225,18 @@ class usbdev_scoreboard extends cip_base_scoreboard #(

virtual function void reset(string kind = "HARD");
super.reset(kind);
// reset local fifos queues and variables
// Reset local fifos queues and variables
usb20_fifo.flush();
usb20_q.delete();
intr_exp = 0;
intr_exp_at_addr_phase = 0;
endfunction

function void check_phase(uvm_phase phase);
super.check_phase(phase);
// post test checks - ensure that all local fifos and queues are empty
// Post test checks to ensure that all local fifos and queues are empty
`DV_EOT_PRINT_TLM_FIFO_CONTENTS(usb20_item, usb20_fifo)
`DV_EOT_PRINT_Q_CONTENTS(usb20_item, usb20_q)
endfunction

endclass

0 comments on commit 7d4225b

Please sign in to comment.