URL
https://opencores.org/ocsvn/pcie_vera_tb/pcie_vera_tb/trunk
Subversion Repositories pcie_vera_tb
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 5 to Rev 6
- ↔ Reverse comparison
Rev 5 → Rev 6
/trunk/receive_packet.vri
9,12 → 9,15
// |
// =========================================================================== |
// |
// $Id: receive_packet.vri,v 1.1.1.1 2007-12-05 18:37:06 cmagleby Exp $ |
// $Id: receive_packet.vri,v 1.2 2007-12-07 20:16:29 cmagleby Exp $ |
// |
// =========================================================================== |
// |
// $Log: not supported by cvs2svn $ |
// Revision 1.1.1.1 2007/12/05 18:37:06 cmagleby |
// importing tb files |
// |
// |
// =========================================================================== |
// Function : This file processes all packets received from the 16 tx interface |
// |
50,6 → 53,7
bit [15:0] expected_seq_id = 0; |
bit [15:0] recv_seq_id = 0; |
bit [9:0] recv_length = 0; |
bit [11:0] byte_length = 0; |
bit [31:0] recv_lcrc = 0; |
bit td = 0; |
integer kstart = 0; |
203,48 → 207,44
sync (ALL,tlp_start); |
printf ("sync into tlp packet\n"); |
@(posedge CLOCK); |
//4 dw header + seq. |
for (k = 0; k < 18; k++) { |
//3 dw header + seq. |
for (k = 0; k < 14; k++) { |
//printf("debug1 %0d\n",debug++); |
ret4 = mailbox_get (WAIT,tx_data_mailbox,tx_pkt,CHECK); |
tlp_pkt[k] = tx_pkt; |
} |
//dword 4 |
if (tlp_pkt[2][5] == 1'b1) { |
for (k=14;k<18;k++) { |
ret4 = mailbox_get (WAIT,tx_data_mailbox,tx_pkt,CHECK); |
tlp_pkt[k] = tx_pkt; |
} |
} |
|
//**************************************************************************************** |
//Check sequence ID and send ACK |
recv_seq_id = {tlp_pkt[0],tlp_pkt[1]}; |
if (recv_seq_id != expected_seq_id) printf ("ERROR ->>>>>>> TLP BAD SEQUENCE ID of %0h\n",recv_seq_id); |
//ack packet |
else { |
if (!semaphore_get(WAIT,my_semaphore,1)) |
error ("Semaphore_get returned 0\n"); |
ack_seq_num = new(recv_seq_id[7:0],{4'b0,recv_seq_id[11:8]},8'b0,8'b0); |
ack_seq_num.build_packet("ack"); |
ack_seq_num.build_packet("ack"); |
printf("ACK PACKET Sequence Number (%0h)\n",recv_seq_id); |
for(m=0; m <= 3; m ++) { |
@ (posedge CLOCK); |
printf("ACK PACKET Sequence Number (%0h)\n",recv_seq_id); |
if(m==0){ |
//ti_phy_top.rxdatak16 = 2'b01; |
//ti_phy_top.rxdata16 = {flowcntrl_1.temp_packet[0][7:0],8'h5C}; |
//adding mailbox |
mailbox_put (rx_data_mailbox, {2'b01,ack_seq_num.temp_packet[0][7:0],8'h5C}); |
printf("DLLP bytes SDB & DLL_TYPE %h%h.\n",ack_seq_num.temp_packet[0][7:0],8'h5C); |
} |
else if(m==1){ |
//ti_phy_top.rxdatak16 = 2'b00; |
//ti_phy_top.rxdata16 = {ack_packet.temp_packet[0][23:16],ack_packet.temp_packet[0][15:8]}; |
//adding mailbox |
mailbox_put (rx_data_mailbox, {2'b00,ack_seq_num.temp_packet[0][23:16],ack_seq_num.temp_packet[0][15:8]}); |
printf("DLLP bytes 2 & 1 %h%h.\n",ack_seq_num.temp_packet[0][23:16],ack_seq_num.temp_packet[0][15:8]); |
} |
else if(m==2){ |
//ti_phy_top.rxdatak16 = 2'b00; |
//ti_phy_top.rxdata16 = {ack_packet.temp_packet[1][7:0],ack_packet.temp_packet[0][31:24]}; |
//adding mailbox |
mailbox_put (rx_data_mailbox, {2'b00,ack_seq_num.temp_packet[1][7:0],ack_seq_num.temp_packet[0][31:24]}); |
printf("DLLP CRC and byte 3 %h%h.\n",ack_seq_num.temp_packet[1][7:0],ack_seq_num.temp_packet[0][31:24]); |
} |
else if(m==3){ |
//ti_phy_top.rxdatak16 = 2'b10; |
//ti_phy_top.rxdata16 = {8'hFD,ack_packet.temp_packet[1][15:8]}; |
//adding mailbox |
mailbox_put (rx_data_mailbox, {2'b10,8'hFD,ack_seq_num.temp_packet[1][15:8]}); |
printf("DLLP STP and CRC %h%h.\n",8'hFD,ack_seq_num.temp_packet[1][15:8]); |
} |
252,49 → 252,50
semaphore_put (my_semaphore, 1); |
} |
expected_seq_id++; |
//**************************************************************************************** |
//build tlp get all header information |
build_tlp_header = {tlp_pkt[17],tlp_pkt[16],tlp_pkt[15],tlp_pkt[14], |
tlp_pkt[13],tlp_pkt[12],tlp_pkt[11],tlp_pkt[10], |
tlp_pkt[9],tlp_pkt[8],tlp_pkt[7],tlp_pkt[6], |
tlp_pkt[5],tlp_pkt[4],tlp_pkt[3],tlp_pkt[2]}; |
|
if (build_tlp_header[5] == 1'b0) { |
if (build_tlp_header[6] == 0) recv_lcrc = {tlp_pkt[17],tlp_pkt[16],tlp_pkt[15],tlp_pkt[14]}; |
build_tlp_header[127:96] = 32'b0; |
} |
//**************************************************************************************** |
//put header in mailbox |
mailbox_put (tlp_header_mailbox, build_tlp_header); |
printf ("Recieved TLP PACKET (%0h) added to tlp header mailbox\n",build_tlp_header); |
//**************************************************************************************** |
//check for data and put into mailbox |
if (build_tlp_header[6] == 1) { |
td = build_tlp_header[23]; |
recv_length = {build_tlp_header[17:16],build_tlp_header[31:24]}; |
kstart = 0; |
if (build_tlp_header[5] == 1'b0) { |
mailbox_put (tlp_data_mailbox, {tlp_pkt[17],tlp_pkt[16],tlp_pkt[15],tlp_pkt[14]}); |
printf ("Recieved TLP DATA (%0h) added to tlp data mailbox\n",{tlp_pkt[17],tlp_pkt[16],tlp_pkt[15],tlp_pkt[14]}); |
kstart = 5; |
} |
|
for (k=kstart;k<=((recv_length*4)+(td*4));k++) { |
byte_length = (recv_length*4) + (td*4); |
printf ("TLP PACKET Receive Length dw(%0d) byte(%0d)\n",recv_length,byte_length); |
for (k=1;k<=byte_length;k++) { |
ret4 = mailbox_get (WAIT,tx_data_mailbox,tx_pkt,CHECK); |
//printf("debug2 %0d\n",debug++); |
tlp_pkt[k] = tx_pkt; |
if (k%4) { |
if (k%4 ==0) { |
mailbox_put (tlp_data_mailbox, {tlp_pkt[k],tlp_pkt[k-1],tlp_pkt[k-2],tlp_pkt[k-3]}); |
printf ("k = (%0d)\n",k); |
printf ("Recieved TLP DATA (%0h) added to tlp data mailbox\n",{tlp_pkt[k],tlp_pkt[k-1],tlp_pkt[k-2],tlp_pkt[k-3]}); |
} |
|
} |
} |
if (build_tlp_header[5] == 0 & build_tlp_header[6] == 0) printf ("tlp lcrc value = %0h \n",recv_lcrc); |
else { |
for (k=0;k<=3;k++) { |
ret4 = mailbox_get (WAIT,tx_data_mailbox,tx_pkt,CHECK); |
//printf("debug3 %0d\n",debug++); |
tlp_pkt[k] = tx_pkt; |
} |
printf ("tlp lcrc value = %0h \n",{tlp_pkt[3],tlp_pkt[2],tlp_pkt[1],tlp_pkt[0]}); |
//**************************************************************************************** |
//Read out the LCRC |
for (k=0;k<=3;k++) { |
ret4 = mailbox_get (WAIT,tx_data_mailbox,tx_pkt,CHECK); |
//printf("debug3 %0d\n",debug++); |
tlp_pkt[k] = tx_pkt; |
} |
|
printf ("tlp lcrc value = %0h \n",{tlp_pkt[3],tlp_pkt[2],tlp_pkt[1],tlp_pkt[0]}); |
|
//**************************************************************************************** |
//READ out the END VALUE |
ret4 = mailbox_get (WAIT,tx_data_mailbox,tx_pkt,CHECK); |
//printf("debug4 %0d\n",debug++); |
if (tx_pkt != {1'b1,END_s}) printf ("ERROR ->>>>>>> TLP malformed no END(%0h)\n",tx_pkt); |
|
|