Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / common / vera / niu_ippktgen / pcg_pack_gen.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: pcg_pack_gen.vr
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35#define PG_WAIT_TO 6000 // Number of cycles to wait for time out
36
37task pkt_gen( flow_desc flow, integer data_length, integer ttl, var integer token,
38 bit[63:0] options=0) {
39
40 integer time_out = 0;
41
42 integer current_flow_num;
43 integer flow_id;
44
45
46 current_flow_num = flow.flow_no;
47
48 if(my_port > 4 ) {
49 printf("WARNING: PG: Port %0d is invalid (only used to satisfy fflp testsuite).\n",my_port);
50 printf(" No action is taken.\n");
51 return;
52 }
53
54 pckt_num++;
55
56 if (flow.fl_state.tcp_flags == 6'h02)
57 new_flow++;
58
59
60 case({ check_option(options, O_ORDER_START),
61 check_option(options, O_ORDER_CONT),
62 check_option(options, O_ORDER_END) }) {
63 3'b100: order_seq = 0;
64 3'b010: order_seq++;
65 3'b001: order_seq++;
66 }
67
68 if(flow.src_node.src_port[my_port] != 1) {
69 print_warn();
70 printf("PG: Specified src_node may not be used as source for this port. Continuing anyway ...\n");
71 }
72
73
74
75 token = pack_db_add_entry( my_port, flow, flow.frame, flow.src_node, flow.dst_node, flow.tup, flow.rx_param, flow.tx_param, flow.fl_state, data_length,ttl, options, order_seq,
76 pckt_num, ifedx_control);
77
78 pack_db[token].port_type = port_type;
79
80
81 if( pack_db[token].fl_state.tcp_flags == 2'h02 ) {
82
83 flow_db_add_entry( my_port, data_length, flow, flow.tup, flow.rx_param, flow.tx_param, flow.fl_state, options, current_flow_num );
84
85}
86
87/***********************************
88 // If port 19 specify HTP descriptor control bits
89 if (pack_db[token].org_port== 8) {
90 pack_db[token].htp.forward_dec = htp_forward_dec;
91 pack_db[token].htp.priority = htp_priority;
92 pack_db[token].htp.dont_tag = htp_dont_tag;
93 pack_db[token].htp.no_crc_ins = htp_no_crc_ins;
94 pack_db[token].htp.ortagin = htp_ortagin;
95 }
96*****************************************/
97
98 if(debug_db_in) display_db(token);
99 wait_send_fake=0;
100
101 mailbox_put(mb_q, token);
102
103printf("Waiting for packet to go out ...(port type: %h), token# %0d\n",port_type, token);
104//printf("options fake out: %d\n",check_option( pack_db[token].options, O_FAKE_OUT) );
105
106 if( check_option( pack_db[token].options, O_WAIT_SEND_FAKE) ) {
107 while(wait_send_fake==0) @(posedge CLOCK);
108 }
109
110
111
112 if( check_option( pack_db[token].options, O_WAIT_SEND) ) {
113
114 fork
115 while(time_out<PG_WAIT_TO) {
116 wait_rx_clk(1);
117 time_out++;
118 }
119
120 while(pack_db[token].pg_done!=1) @(posedge CLOCK);
121 join any
122
123 terminate;
124
125
126 if(pack_db[token].pg_done!=1) {
127 pack_db[token].pg_done=1;
128 print_warn();
129 printf("PG: Timed out waiting for done bit (waited %0d cycles)...\n",time_out);
130 printf(" This only happens with fake ports when we wait for someone\n");
131 printf(" to acknowladge that the packet was processed (Port: %0d).\n",my_port);
132 printf(" Token: %0d, Time: %0d\n",token,{get_time(HI),get_time(LO)});
133 }
134
135 }
136
137
138
139//printf("Packet went out ...\n");
140 }
141
142task pkt_auto_tx() {
143 integer len; // buffer length
144 byte_array buf; // Frame buffer
145 integer token; // Read from the queue
146
147 buf = new; // Allocate new buffer
148
149
150 while(1) {
151 mailbox_get(WAIT, mb_q, token);
152 if(debug_db_out) display_db(token);
153
154 gen_buf( token, buf, len );
155 if(debug_fa) display_buf( buf, len, INTER_FEDX );
156 wait_send_fake=1;
157
158 if( !check_option( pack_db[token].options, O_NO_OUT_TOKEN) ) {
159 if(debug_out_token)
160 printf("INFO: PG[%0d]: Sending token (%0d) to outgoing mailbox. (Time: %d)\n",
161 my_port, token, {get_time(HI),get_time(LO)} );
162 mailbox_put(mbox_id.pg_mb[my_port], token);
163 }
164
165 printf("pg[%0d]: Transmitting packet ...\n",my_port);
166 printf("options fake out: %d\n",check_option( pack_db[token].options, O_FAKE_OUT) );
167 if( !(check_option( pack_db[token].options, O_FAKE_OUT )) & !port_type[2] ) {
168 //printf("pg[%0d]: Setting done bit ...\n",my_port);
169 //if(verbose_on)
170 printf("INFO: PG[%0d]: Sending out packet token:%0d at time %0d \n",my_port, token,
171 {get_time(HI),get_time(LO)});
172 send_packet(port_type, buf, len, pack_db[token].options);
173
174
175 pack_db[token].pg_done = 1;
176 //if(verbose_on)
177 printf("INFO: PG[%0d]: Packet token %0d sent done at time=%0d \n",my_port, token,
178 {get_time(HI),get_time(LO)});
179 }
180 printf("pg[%0d]: Done Transmitting packet ...\n",my_port);
181 }
182 }
183
184
185