📄 pci_exp_expect_tasks.v
字号:
$fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id); $fdisplay(error_file_ptr, "\t Tag: 0x%h", tag); $fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be); $fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be); $fdisplay(error_file_ptr, "\t Address: 0x%h", address); $fdisplay(error_file_ptr, "Received:"); $fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_); $fdisplay(error_file_ptr, "\t TD: %h", td_); $fdisplay(error_file_ptr, "\t EP: %h", ep_); $fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_); $fdisplay(error_file_ptr, "\t Length: 0x%h", length_); $fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_); $fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_); $fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be_); $fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be_); $fdisplay(error_file_ptr, "\t Address: 0x%h", address_); $fdisplay(error_file_ptr, ""); expect_status = 1'b0; end end end endendtask/************************************************************Task : TSK_EXPECT_MEMRD64Inputs : traffic_class, td, ep, attr, length, last_dw_be, first_dw_be, addressOutputs : status 0-Failed 1-SuccessfulDescription : Expecting a memory read (64-bit address) TLP from Rx side with matching header fields*************************************************************/task TSK_EXPECT_MEMRD64; input [2:0] traffic_class; input td; input ep; input [1:0] attr; input [9:0] length; input [15:0] requester_id; input [7:0] tag; input [3:0] last_dw_be; input [3:0] first_dw_be; input [61:0] address; output expect_status; reg [2:0] traffic_class_; reg td_; reg ep_; reg [1:0] attr_; reg [9:0] length_; reg [15:0] requester_id_; reg [7:0] tag_; reg [3:0] last_dw_be_; reg [3:0] first_dw_be_; reg [61:0] address_; integer i_; reg wait_for_next; begin wait_for_next = 1'b1; //haven't found any matching tag yet while(wait_for_next) begin @ rcvd_memrd64; //wait for a rcvd_memrd64 event traffic_class_ = frame_store_rx[1] >> 4; td_ = frame_store_rx[2] >> 7; ep_ = frame_store_rx[2] >> 6; attr_ = frame_store_rx[2] >> 4; length_ = frame_store_rx[2]; length_ = (length_ << 8) | (frame_store_rx[3]); requester_id_= {frame_store_rx[4], frame_store_rx[5]}; tag_= frame_store_rx[6]; last_dw_be_= frame_store_rx[7] >> 4; first_dw_be_= frame_store_rx[7]; address_[61:6] = {frame_store_rx[8], frame_store_rx[9], frame_store_rx[10], frame_store_rx[11], frame_store_rx[12], frame_store_rx[13], frame_store_rx[14]}; address_[5:0] = frame_store_rx[15] >> 2; $display("[%t] : Received MEMRD64 --- Tag 0x%h", $realtime, tag_); if(tag == tag_) //find matching tag begin wait_for_next = 1'b0; if((traffic_class == traffic_class_) && (td === td_) && (ep == ep_) && (attr == attr_) && (length == length_) && (requester_id == requester_id_) && (last_dw_be == last_dw_be_) && (first_dw_be == first_dw_be_) && (address == address_)) begin // header matches expect_status = 1'b1; end else // header mismatches, error out begin $fdisplay(error_file_ptr, "[%t] : Found header mismatch in received MEMRD64 - Tag 0x%h: \n", $time, tag_); $fdisplay(error_file_ptr, "Expected:"); $fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class); $fdisplay(error_file_ptr, "\t TD: %h", td); $fdisplay(error_file_ptr, "\t EP: %h", ep); $fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr); $fdisplay(error_file_ptr, "\t Length: 0x%h", length); $fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id); $fdisplay(error_file_ptr, "\t Tag: 0x%h", tag); $fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be); $fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be); $fdisplay(error_file_ptr, "\t Address: 0x%h", address); $fdisplay(error_file_ptr, "Received:"); $fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_); $fdisplay(error_file_ptr, "\t TD: %h", td_); $fdisplay(error_file_ptr, "\t EP: %h", ep_); $fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_); $fdisplay(error_file_ptr, "\t Length: 0x%h", length_); $fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_); $fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_); $fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be_); $fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be_); $fdisplay(error_file_ptr, "\t Address: 0x%h", address_); $fdisplay(error_file_ptr, ""); expect_status = 1'b0; end end end endendtask/************************************************************Task : TSK_EXPECT_MEMWRInputs : traffic_class, td, ep, attr, length, last_dw_be, first_dw_be, addressOutputs : status 0-Failed 1-SuccessfulDescription : Expecting a memory write (32-bit address) TLP from Rx side with matching header fields and payload*************************************************************/task TSK_EXPECT_MEMWR; input [2:0] traffic_class; input td; input ep; input [1:0] attr; input [9:0] length; input [15:0] requester_id; input [7:0] tag; input [3:0] last_dw_be; input [3:0] first_dw_be; input [29:0] address; output expect_status; reg [2:0] traffic_class_; reg td_; reg ep_; reg [1:0] attr_; reg [9:0] length_; reg [15:0] requester_id_; reg [7:0] tag_; reg [3:0] last_dw_be_; reg [3:0] first_dw_be_; reg [29:0] address_; integer payload_len; integer i_; reg wait_for_next; reg check_byte; begin wait_for_next = 1'b1; //haven't found any matching tag yet while(wait_for_next) begin @ rcvd_memwr; //wait for a rcvd_memwr event traffic_class_ = frame_store_rx[1] >> 4; td_ = frame_store_rx[2] >> 7; ep_ = frame_store_rx[2] >> 6; attr_ = frame_store_rx[2] >> 4; length_ = frame_store_rx[2]; length_ = (length_ << 8) | (frame_store_rx[3]); requester_id_= {frame_store_rx[4], frame_store_rx[5]}; tag_= frame_store_rx[6]; last_dw_be_= frame_store_rx[7] >> 4; first_dw_be_= frame_store_rx[7]; address_[29:6] = {frame_store_rx[8], frame_store_rx[9], frame_store_rx[10]}; address_[5:0] = frame_store_rx[11] >> 2; payload_len = (length << 2); if (payload_len==0) payload_len = 4096; $display("[%t] : Received MEMWR --- Tag 0x%h", $realtime, tag_); if(tag == tag_) //find matching tag begin wait_for_next = 1'b0; if((traffic_class == traffic_class_) && (td === td_) && (ep == ep_) && (attr == attr_) && (length == length_) && (requester_id == requester_id_) && (last_dw_be == last_dw_be_) && (first_dw_be == first_dw_be_) && (address == address_)) begin // find matching header then compare payload for (i_ = 0; i_ < payload_len; i_ = i_ + 1) begin check_byte = 1; if (i_ < 4) // apply first_dw_be begin if (first_dw_be[i_]) check_byte = 1; else check_byte = 0; end else if (i_ > (payload_len - 5)) // apply last_dw_be begin if (last_dw_be[4 - (payload_len - i_)]) check_byte = 1; else check_byte = 0; end if(check_byte && `EXPECT_MEMWR_PAYLOAD[i_] != frame_store_rx[12 + i_]) //find mismatch begin $fdisplay(error_file_ptr, "[%t] : Found payload mismatch in received MEMWR - Tag 0x%h: \n", $time, tag_); $fdisplay(error_file_ptr, "Expected:"); for (i_ = 0; i_ < payload_len; i_ = i_ + 1) $fdisplay(error_file_ptr,"\t %0x", `EXPECT_MEMWR_PAYLOAD[i_]); $fdisplay(error_file_ptr, "Received:"); for (i_ = 0; i_ < payload_len; i_ = i_ + 1) $fdisplay(error_file_ptr,"\t %0x", frame_store_rx[12+i_]); $fdisplay(error_file_ptr, ""); expect_status = 1'b0; i_ = 5000; end end //find matching frame if(i_ == payload_len) expect_status = 1'b1; end else // header mismatches, error out begin $fdisplay(error_file_ptr, "[%t] : Found header mismatch in received MEMWR - Tag 0x%h: \n", $time, tag_); $fdisplay(error_file_ptr, "Expected:"); $fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class); $fdisplay(error_file_ptr, "\t TD: %h", td); $fdisplay(error_file_ptr, "\t EP: %h", ep); $fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr); $fdisplay(error_file_ptr, "\t Length: 0x%h", length); $fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id); $fdisplay(error_file_ptr, "\t Tag: 0x%h", tag); $fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be); $fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be); $fdisplay(error_file_ptr, "\t Address: 0x%h", address); $fdisplay(error_file_ptr, "Received:"); $fdisplay(error_file_ptr, "\t Traffic Class: 0x%h", traffic_class_); $fdisplay(error_file_ptr, "\t TD: %h", td_); $fdisplay(error_file_ptr, "\t EP: %h", ep_); $fdisplay(error_file_ptr, "\t Attributes: 0x%h", attr_); $fdisplay(error_file_ptr, "\t Length: 0x%h", length_); $fdisplay(error_file_ptr, "\t Requester ID: 0x%h", requester_id_); $fdisplay(error_file_ptr, "\t Tag: 0x%h", tag_); $fdisplay(error_file_ptr, "\t Last DW byte-enable: 0x%h", last_dw_be_); $fdisplay(error_file_ptr, "\t First DW byte-enable: 0x%h", first_dw_be_); $fdisplay(error_file_ptr, "\t Address: 0x%h", address_); $fdisplay(error_file_ptr, ""); expect_status = 1'b0; end end end endendtask/************************************************************Task : TSK_EXPECT_MEMWR64Inputs : traffic_class, td, ep, attr, length, last_dw_be, first_dw_be, addressOutputs : status 0-Failed 1-SuccessfulDescription : Expecting a memory write (64-bit address) TLP from Rx side with matching header fields and payload*************************************************************/task TSK_EXPECT_MEMWR64; input [2:0] traffic_class; input td; input ep; input [1:0] attr; input [9:0] length; input [15:0] requester_id; input [7:0] tag; input [3:0] last_dw_be; input [3:0] first_dw_be; input [61:0] address; output expect_status; reg [2:0] traffic_class_; reg td_; reg ep_; reg [1:0] attr_; reg [9:0] length_; reg [15:0] requester_id_; reg [7:0] tag_; reg [3:0] last_dw_be_; reg [3:0] first_dw_be_; reg [61:0] address_; integer payload_len; integer i_; reg wait_for_next; reg check_byte; begin wait_for_next = 1'b1; //haven't found any matching tag yet while(wait_for_next) begin @ rcvd_memwr64; //wait for a rcvd_memwr64 event traffic_class_ = frame_store_rx[1] >> 4; td_ = frame_store_rx[2] >> 7; ep_ = frame_store_rx[2] >> 6; attr_ = frame_store_rx[2] >> 4; length_ = frame_store_rx[2]; length_ = (length_ << 8) | (frame_store_rx[3]); requester_id_= {frame_store_rx[4], frame_store_rx[5]}; tag_= frame_store_rx[6]; last_dw_be_= frame_store_rx[7] >> 4; first_dw_be_= frame_store_rx[7]; address_[61:6] = {frame_store_rx[8], frame_store_rx[9], frame_store_rx[10], frame_store_rx[11], frame_store_rx[12], frame_store_rx[13], frame_store_rx[14]}; address_[5:0] = frame_store_rx[15] >> 2; payload_len = (length << 2); if (payload_len==0) payload_len = 4096;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -