Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scoreboard #20712

Merged
merged 2 commits into from
Dec 22, 2023
Merged
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
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
28 changes: 18 additions & 10 deletions hw/ip/usbdev/dv/env/usbdev_packetiser.sv
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,38 @@ class usbdev_packetiser extends uvm_object;
bit data_pkt_arr[];
bit handshake_pkt_arr[];

// Handles to usb20_item and classes derived from usb20_item
usb20_item m_usb20_item;
token_pkt m_tpkt;
data_pkt m_dpkt;
handshake_pkt m_hpkt;
// Handles to classes derived from usb20_item
token_pkt m_tpkt;
data_pkt m_dpkt;
handshake_pkt m_hpkt;

function new(string name = "usbdev_packetiser");
super.new(name);
m_usb20_item = new("usb20_item");
m_tpkt = new("token_pkt");
m_dpkt = new("data_pkt");
m_hpkt = new("handshake_pkt");
m_tpkt = new("token_pkt");
m_dpkt = new("data_pkt");
m_hpkt = new("handshake_pkt");
endfunction

// pack_pkt task
// -------------------------------
task pack_pkt();
task pack_pkt(usb20_item m_usb20_item);
if (m_usb20_item.m_pkt_type == PktTypeToken) begin
m_tpkt.m_pid_type = pid_type_e'({<<4{m_tpkt.m_pid_type}});
m_tpkt.m_pid_type = pid_type_e'({<<{m_tpkt.m_pid_type}});
m_tpkt.address = {<<{m_tpkt.address}};
m_tpkt.endpoint = {<<{m_tpkt.endpoint}};
m_tpkt.crc5 = {<<{m_tpkt.crc5}};
m_tpkt.pack(token_pkt_arr);
end
else if (m_usb20_item.m_pkt_type == PktTypeData) begin
m_dpkt.m_pid_type = pid_type_e'({<<4{m_dpkt.m_pid_type}});
m_dpkt.m_pid_type = pid_type_e'({<<{m_dpkt.m_pid_type}});
m_dpkt.crc16 = {<<{m_dpkt.crc16}};
m_dpkt.pack(data_pkt_arr);
end
else if (m_usb20_item.m_pkt_type == PktTypeHandshake) begin
m_hpkt.m_pid_type = pid_type_e'({<<4{m_hpkt.m_pid_type}});
m_hpkt.m_pid_type = pid_type_e'({<<{m_hpkt.m_pid_type}});
m_hpkt.pack(handshake_pkt_arr);
end
else;
Expand Down
83 changes: 31 additions & 52 deletions hw/ip/usbdev/dv/env/usbdev_pkt_manager.sv
Original file line number Diff line number Diff line change
Expand Up @@ -21,54 +21,48 @@ class usbdev_pkt_manager extends uvm_object;
expected_pkt = exp_q.pop_back();
end
else
`uvm_info(get_type_name(),"QUEUE IS EMPTY",UVM_LOW);
`uvm_info(get_type_name(), "QUEUE IS EMPTY", UVM_LOW);
endtask

// push_packet task to push the expected packet
// -------------------------------
task push_packet(bit exp_pkt []);
task push_packet(bit exp_pkt[]);
exp_q.push_front(exp_pkt);
endtask
endclass

// Token_packet class
// -------------------------------
class token_packet extends usbdev_pkt_manager;
logic [7:0] sync;
logic [7:0] pid;
logic [6:0] addr;
logic [3:0] endp;
logic [4:0] crc5;
logic [2:0] eop;
logic [7:0] pid;
logic [6:0] addr;
logic [3:0] endp;
logic [4:0] crc5;
bit pack_token[];

`uvm_object_utils_begin (token_packet)
`uvm_field_int(sync, UVM_ALL_ON)
`uvm_field_int(pid, UVM_ALL_ON)
`uvm_object_utils_begin(token_packet)
`uvm_field_int(pid, UVM_ALL_ON)
`uvm_field_int(addr, UVM_ALL_ON)
`uvm_field_int(endp, UVM_ALL_ON)
`uvm_field_int(crc5, UVM_ALL_ON)
`uvm_field_int(eop, UVM_ALL_ON)
`uvm_object_utils_end

function new(string name = "token_packet");
super.new(name);
this.sync = 0;
this.pid = 0;
this.addr = 0;
this.endp = 0;
this.crc5 = 0;
this.eop = 0;
endfunction

// send_token_packet task : To get the fields of token packet and pack them and then send that
// packet into expected queue
// -------------------------------
task send_token_packet(bit[7:0] tpid,bit[6:0] taddress,bit[3:0] tendpoint);
task send_token_packet(bit [7:0] tpid, bit [6:0] taddress, bit [3:0] tendpoint);
bit [4:0] crc;
bit [10:0] data;
bit [4:0] polynomial = 5'b0_0101;
data = {tendpoint,taddress};
data = {tendpoint, taddress};

// Calculate crc5
crc = 5'b1_1111;
Expand All @@ -83,15 +77,13 @@ class token_packet extends usbdev_pkt_manager;
crc = ~crc;

// Bit streaming to send LSB first...
this.sync = 8'b0000_0001;
this.pid = {<<4{tpid}};
this.pid = {<<{this.pid}};
taddress = {<<{taddress}};
this.addr = taddress;
tendpoint = {<<{tendpoint}};
this.endp = tendpoint;
this.crc5 = crc;
this.eop = 3'b001;
// Pack the token packet
this.pack(pack_token);
super.push_packet(pack_token);
Expand All @@ -101,39 +93,33 @@ endclass
// data_packet class
// -------------------------------
class data_packet extends usbdev_pkt_manager;
logic [7:0] sync;
logic [7:0] pid;
logic data [];
logic [15:0] crc16;
logic [2:0] eop;
bit pack_data [];

`uvm_object_utils_begin (data_packet)
`uvm_field_int(sync, UVM_ALL_ON)
`uvm_field_int(pid, UVM_ALL_ON)
logic [7:0] pid;
logic data[];
logic [15:0] crc16;
bit pack_data[];

`uvm_object_utils_begin(data_packet)
`uvm_field_int(pid, UVM_ALL_ON)
`uvm_field_array_int(data, UVM_ALL_ON)
`uvm_field_int(crc16, UVM_ALL_ON)
`uvm_field_int(eop, UVM_ALL_ON)
`uvm_field_int(crc16, UVM_ALL_ON)
`uvm_object_utils_end

function new(string name = "data_packet");
super.new(name);
this.sync = 0;
this.pid = 0;
foreach(data[i])
this.data[i] = 0;
this.crc16 = 0;
this.eop = 0;
endfunction

// send_data_packet task : To get the fields of data packet and pack them and then send that
// packet into expected queue
// -------------------------------
task send_data_packet(bit[7:0] dpid,bit ddata []);
task send_data_packet(bit [7:0] dpid, bit ddata[]);
bit [15:0] crc;
bit [15:0] polynomial = 16'h8005;

// store the data bit by bit in dynamic array
// Store the data bit by bit in dynamic array
foreach(ddata[i]) begin
this.data = new[this.data.size() + 1](this.data);
this.data[this.data.size() - 1] = ddata[i];
Expand All @@ -155,11 +141,12 @@ class data_packet extends usbdev_pkt_manager;
end
crc = ~crc;

this.sync = 8'b0000_0001;
this.pid = {<<4{dpid}};
this.pid = {<<{this.pid}};
this.crc16 = crc;
this.eop = 3'b001;
this.pid = {<<4{dpid}};
this.pid = {<<{this.pid}};
this.data = {<<8{this.data}};
this.data = {<<{this.data}};
this.crc16 = {<<{crc}};

// Pack the data packet
this.pack(pack_data);
super.push_packet(pack_data);
Expand All @@ -170,31 +157,23 @@ endclass
// hand_shake_packet class
// -------------------------------
class hand_shake_packet extends usbdev_pkt_manager;
logic [7:0] sync;
logic [7:0] pid;
logic [2:0] eop;
bit pack_handshake[];

`uvm_object_utils_begin (hand_shake_packet)
`uvm_field_int(sync,UVM_ALL_ON)
`uvm_field_int(pid,UVM_ALL_ON)
`uvm_field_int(eop,UVM_ALL_ON)
`uvm_object_utils_begin(hand_shake_packet)
`uvm_field_int(pid, UVM_ALL_ON)
`uvm_object_utils_end

function new(string name = "hand_shake_packet");
super.new(name);
this.sync = 0;
this.pid = 0;
this.eop = 0;
endfunction

// send_handshake_packet task : To get the field of data packet and pack them and then send that
// packet into expected queue
task send_handshake_packet(bit[7:0] hpid);
this.sync = 8'b0000_0001;
this.pid = {<<4{hpid}};
this.pid = {<<{this.pid}};
this.eop = 3'b001;
task send_handshake_packet(bit [7:0] hpid);
this.pid = hpid;

// Pack the handshake packet
this.pack(pack_handshake);
super.push_packet(pack_handshake);
Expand Down
Loading
Loading