OpenCores
URL https://opencores.org/ocsvn/rio/rio/trunk

Subversion Repositories rio

[/] [rio/] [trunk/] [sw/] [stack/] [test_riostack.c] - Blame information for rev 49

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 49 magro732
/*******************************************************************************
2
 *
3
 * RapidIO IP Library Core
4
 *
5
 * This file is part of the RapidIO IP library project
6
 * http://www.opencores.org/cores/rio/
7
 *
8
 * Description:
9
 * This file contains automatic regression tests for riopacket. Compile and
10
 * run it by using:
11
 * gcc -o testriostack test_riostack.c riopacket.c -fprofile-arcs -ftest-coverage
12
 * ./testriostack
13
 * gcov test_riostack.c
14
 *
15
 * To Do:
16
 * -
17
 *
18
 * Author(s):
19
 * - Magnus Rosenius, magro732@opencores.org
20
 *
21
 *******************************************************************************
22
 *
23
 * Copyright (C) 2015 Authors and OPENCORES.ORG
24
 *
25
 * This source file may be used and distributed without
26
 * restriction provided that this copyright statement is not
27
 * removed from the file and that any derivative work contains
28
 * the original copyright notice and the associated disclaimer.
29
 *
30
 * This source file is free software; you can redistribute it
31
 * and/or modify it under the terms of the GNU Lesser General
32
 * Public License as published by the Free Software Foundation;
33
 * either version 2.1 of the License, or (at your option) any
34
 * later version.
35
 *
36
 * This source is distributed in the hope that it will be
37
 * useful, but WITHOUT ANY WARRANTY; without even the implied
38
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
39
 * PURPOSE. See the GNU Lesser General Public License for more
40
 * details.
41
 *
42
 * You should have received a copy of the GNU Lesser General
43
 * Public License along with this source; if not, download it
44
 * from http://www.opencores.org/lgpl.shtml
45
 *
46
 *******************************************************************************/
47
 
48
#include <stdio.h>
49
#include <stdlib.h>
50
 
51
#define MODULE_TEST
52
#include "riostack.c"
53
 
54
#define PrintS(s)                               \
55
  {                                             \
56
    FILE *fd;                                   \
57
    fd=fopen("testspec.txt", "a");              \
58
    fputs(s "\n", fd);                          \
59
    fclose(fd);                                 \
60
  }
61
 
62
#define TESTSTART(s) printf(s)
63
#define TESTEND printf(" passed.\n");
64
 
65
#define TESTCOND(got)                                   \
66
  if (!(got))                                           \
67
  {                                                     \
68
    printf("\nERROR at line %u:%s=%u (0x%08x)\n",       \
69
           __LINE__, #got, (got), (got));               \
70
    exit(1);                                            \
71
  }
72
 
73
#define TESTEXPR(got, expected)                                         \
74
  if ((got)!=(expected))                                                \
75
  {                                                                     \
76
    printf("\nERROR at line %u:%s=%u (0x%08x) expected=%u (0x%08x)\n",  \
77
           __LINE__, #got, (got), (got), (expected), (expected));       \
78
    exit(1);                                                            \
79
  }
80
 
81
#define TESTSYMBOL(got, expected) testSymbol(__LINE__, #got, (got), (expected))
82
 
83
void testSymbol(uint32_t line, char *expression, RioSymbol_t got, RioSymbol_t expected)
84
{
85
  if ((got).type==(expected).type)
86
  {
87
    switch ((got).type)
88
    {
89
      case RIOSTACK_SYMBOL_TYPE_ERROR:
90
      case RIOSTACK_SYMBOL_TYPE_IDLE:
91
        break;
92
      case RIOSTACK_SYMBOL_TYPE_CONTROL:
93
        if((got).data != (expected).data)
94
        {
95
          if(STYPE0_GET((got).data) != STYPE0_GET((expected).data))
96
          {
97
            printf("\nERROR at line %u:STYPE0=0x%02x expected=0x%02x\n",
98
                   line, STYPE0_GET((got).data), STYPE0_GET((expected).data));
99
          }
100
          if(PARAMETER0_GET((got).data) != PARAMETER0_GET((expected).data))
101
          {
102
            printf("\nERROR at line %u:PARAMETER0=0x%02x expected=0x%02x\n",
103
                   line, PARAMETER0_GET((got).data), PARAMETER0_GET((expected).data));
104
          }
105
          if(PARAMETER1_GET((got).data) != PARAMETER1_GET((expected).data))
106
          {
107
            printf("\nERROR at line %u:PARAMETER1=0x%02x expected=0x%02x\n",
108
                   line, PARAMETER1_GET((got).data), PARAMETER1_GET((expected).data));
109
          }
110
          if(STYPE1_GET((got).data) != STYPE1_GET((expected).data))
111
          {
112
            printf("\nERROR at line %u:STYPE1=0x%02x expected=0x%02x\n",
113
                   line, STYPE1_GET((got).data), STYPE1_GET((expected).data));
114
          }
115
          if(CMD_GET((got).data) != CMD_GET((expected).data))
116
          {
117
            printf("\nERROR at line %u:CMD=0x%02x expected=0x%02x\n",
118
                   line, CMD_GET((got).data), CMD_GET((expected).data));
119
          }
120
          if(CRC5_GET((got).data) != CRC5_GET((expected).data))
121
          {
122
            printf("\nERROR at line %u:CRC5=0x%02x expected=0x%02x\n",
123
                   line, CRC5_GET((got).data), CRC5_GET((expected).data));
124
          }
125
          exit(1);
126
        }
127
        break;
128
      case RIOSTACK_SYMBOL_TYPE_DATA:
129
        if((got).data != (expected).data)
130
        {
131
          printf("\nERROR at line %u:%s=%u (0x%08x) expected=%u (0x%08x)\n",
132
                 line, expression, (got).data, (got).data, (expected).data, (expected).data);
133
          exit(1);
134
        }
135
        break;
136
    }
137
  }
138
  else
139
  {
140
    printf("\nERROR at line %u:%s=%u (0x%08x) expected=%u (0x%08x)\n",
141
           line, expression, (got).type, (got).type, (expected).type, (expected).type);
142
    exit(1);
143
  }
144
}
145
 
146
 
147
 
148
uint8_t createDoorbell(uint32_t *doorbell, uint8_t ackId, uint16_t destid, uint16_t srcId, uint8_t tid, uint16_t info)
149
{
150
  uint16_t crc;
151
  uint32_t content;
152
 
153
  /* ackId(4:0)|0|vc|crf|prio(1:0)|tt(1:0)|ftype(3:0)|destinationId(15:0) */
154
  /* ackId is set when the packet is transmitted. */
155
  content = 0x001aul << 16;
156
  content |= (uint32_t) destid;
157
  crc = RIOPACKET_Crc32(content, 0xffffu);
158
  doorbell[0] = (((uint32_t) ackId) << 27) | content;
159
 
160
  /* sourceId(15:0)|rsrv(7:0)|srcTID(7:0) */
161
  content = ((uint32_t) srcId) << 16;
162
  content |= (uint32_t) tid;
163
  crc = RIOPACKET_Crc32(content, crc);
164
  doorbell[1] = content;
165
 
166
  /* infoMSB(7:0)|infoLSB(7:0)|crc(15:0) */
167
  content = ((uint32_t) info) << 16;
168
  crc = RIOPACKET_Crc16(info, crc);
169
  content |= ((uint32_t) crc);
170
  doorbell[2] = content;
171
 
172
  return 3;
173
 
174
}
175
 
176
/*******************************************************************************
177
 * Module test for this file.
178
 *******************************************************************************/
179
int32_t main(void)
180
{
181
  RioStack_t stack;
182
  uint32_t rxPacketBuffer[RIOSTACK_BUFFER_SIZE*8], txPacketBuffer[RIOSTACK_BUFFER_SIZE*8];
183
  RioPacket_t rioPacket;
184
  uint32_t packet[69];
185
  RioSymbol_t s, c, d;
186
  int i, j, k;
187
  uint16_t length;
188
  uint16_t dstid;
189
  uint16_t srcid;
190
  uint8_t tid;
191
  uint8_t hop;
192
  uint8_t mailbox;
193
  uint16_t info;
194
  uint32_t address;
195
  uint32_t data;
196
  uint8_t payload8[256];
197
  uint8_t payload8Expected[256];
198
  uint32_t packetLength;
199
 
200
 
201
  /*************************************************************************
202
   * Test prelude.
203
   * Setup the RIO stack for operation.
204
   *************************************************************************/
205
 
206
  /* Open the stack and set the port status to initialized. */
207
  RIOSTACK_open(&stack, NULL,
208
                RIOSTACK_BUFFER_SIZE*8, &rxPacketBuffer[0],
209
                RIOSTACK_BUFFER_SIZE*8, &txPacketBuffer[0]);
210
 
211
  /* Set the port timeout. */
212
  RIOSTACK_portSetTimeout(&stack, 1);
213
 
214
  /* Set the current port time. */
215
  RIOSTACK_portSetTime(&stack, 0);
216
 
217
  /******************************************************************************/
218
  PrintS("----------------------------------------------------------------------");
219
  PrintS("TG_riostack");
220
  PrintS("----------------------------------------------------------------------");
221
  PrintS("TG_riostack-TC1");
222
  PrintS("Description: Test link initialization and normal packet exchange.");
223
  PrintS("Requirement: XXXXX");
224
  PrintS("----------------------------------------------------------------------");
225
  PrintS("Step 1:");
226
  PrintS("Action: Send packets when port is uninitialized.");
227
  PrintS("Result: All packets should be ignored during initialization.");
228
  PrintS("----------------------------------------------------------------------");
229
  /******************************************************************************/
230
  TESTSTART("TG_riostack-TC1-Step1");
231
  /******************************************************************************/
232
 
233
  /* Place a packet in the outbound queue to check that it is received once
234
     the transmitter is placed in the correct state. */
235
  RIOPACKET_setDoorbell(&rioPacket, 1, 0xffff, 0, 0xdeaf);
236
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
237
 
238
  /* Check that only idle symbols are transmitted when the port has not been
239
     initialied even if statuses are received. */
240
  for(i = 0; i < 1024; i++)
241
  {
242
    RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 0, 1, STYPE1_NOP, 0));
243
    s = RIOSTACK_portGetSymbol(&stack);
244
    TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
245
  }
246
 
247
  /******************************************************************************/
248
  TESTEND;
249
  /*****************************************************************************/
250
  PrintS("----------------------------------------------------------------------");
251
  PrintS("Step 2:");
252
  PrintS("Action: Set port initialized and get symbols from the stack.");
253
  PrintS("Result: Status-control-symbols should be generated each 256 symbol.");
254
  PrintS("----------------------------------------------------------------------");
255
  /*****************************************************************************/
256
  TESTSTART("TG_riostack-TC1-Step2");
257
  /*****************************************************************************/
258
 
259
  /* Set the port status to intialized. */
260
  RIOSTACK_portSetStatus(&stack, 1);
261
 
262
  /* Set port time. */
263
  RIOSTACK_portSetTime(&stack, 1);
264
 
265
  /* Check that status-control-symbols are transmitted once every 256 symbol. */
266
  for(j = 0; j < 15; j++)
267
  {
268
    for(i = 0; i < 255; i++)
269
    {
270
      s = RIOSTACK_portGetSymbol(&stack);
271
      TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
272
    }
273
    s = RIOSTACK_portGetSymbol(&stack);
274
    c = CreateControlSymbol(STYPE0_STATUS, 0, 8, STYPE1_NOP, 0);
275
    TESTEXPR(s.type, c.type);
276
    TESTEXPR(s.data, c.data);
277
  }
278
 
279
  /******************************************************************************/
280
  TESTEND;
281
  /******************************************************************************/
282
  PrintS("----------------------------------------------------------------------");
283
  PrintS("Step 3:");
284
  PrintS("Action: Add a status-control-symbol to the receiver.");
285
  PrintS("Result: Status-control-symbols should be generated each 15 symbol.");
286
  PrintS("----------------------------------------------------------------------");
287
  /******************************************************************************/
288
  TESTSTART("TG_riostack-TC1-Step3");
289
  /*****************************************************************************/
290
 
291
  /* Insert a status-control-symbol in the receive. */
292
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 0, 1, STYPE1_NOP, 0));
293
 
294
  /* Check that status-control-symbols are transmitted once every 16 symbol. */
295
  for(i = 0; i < 15; i++)
296
  {
297
    s = RIOSTACK_portGetSymbol(&stack);
298
    TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
299
  }
300
  s = RIOSTACK_portGetSymbol(&stack);
301
  c = CreateControlSymbol(STYPE0_STATUS, 0, 8, STYPE1_NOP, 0);
302
  TESTEXPR(s.type, c.type);
303
  TESTEXPR(s.data, c.data);
304
 
305
  /******************************************************************************/
306
  TESTEND;
307
  /******************************************************************************/
308
  PrintS("----------------------------------------------------------------------");
309
  PrintS("Step 4:");
310
  PrintS("Action: Add a packet to the receiver.");
311
  PrintS("Result: Packet should be ignored until the link is initialized.");
312
  PrintS("----------------------------------------------------------------------");
313
  /******************************************************************************/
314
  TESTSTART("TG_riostack-TC1-Step4");
315
  /*****************************************************************************/
316
 
317
  /* Send a packet. Note that the start and end of the packet contains a status. */
318
  packetLength = createDoorbell(packet, 0, 0, 0, 0, 0);
319
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 0, 8, STYPE1_START_OF_PACKET, 0));
320
  for(i = 0; i < packetLength; i++)
321
  {
322
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
323
    d.data = packet[i];
324
    RIOSTACK_portAddSymbol(&stack, d);
325
  }
326
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 0, 8, STYPE1_END_OF_PACKET, 0));
327
 
328
  /* Check that packet was not received. */
329
  TESTEXPR(RIOSTACK_getInboundQueueLength(&stack), 0);
330
 
331
  /******************************************************************************/
332
  TESTEND;
333
  /******************************************************************************/
334
  PrintS("----------------------------------------------------------------------");
335
  PrintS("Step 5:");
336
  PrintS("Action: Add four more status-control-symbols followed by one with error in ");
337
  PrintS("        CRC5. Then send a packet.");
338
  PrintS("Result: The receiver should remain in port initialized and packet should ");
339
  PrintS("        still be ignored.");
340
  PrintS("----------------------------------------------------------------------");
341
  /******************************************************************************/
342
  TESTSTART("TG_riostack-TC1-Step5");
343
  /*****************************************************************************/
344
 
345
  /* Send 4 more status-control-symbols followed by one erronous. */
346
  for(i = 0; i < 4; i++)
347
  {
348
    RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 0, 1, STYPE1_NOP, 0));
349
  }
350
  c = CreateControlSymbol(STYPE0_STATUS, 0, 1, STYPE1_NOP, 0);
351
  c.data ^= 1;
352
  RIOSTACK_portAddSymbol(&stack, c);
353
 
354
  /* Send a packet. Note that the start and end of the packet contains status. */
355
  packetLength = createDoorbell(packet, 0, 0, 0, 0, 0);
356
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 0, 8, STYPE1_START_OF_PACKET, 0));
357
  for(i = 0; i < packetLength; i++)
358
  {
359
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
360
    d.data = packet[i];
361
    RIOSTACK_portAddSymbol(&stack, d);
362
  }
363
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 0, 8, STYPE1_END_OF_PACKET, 0));
364
 
365
  /* Check that the packet was ignored. */
366
  TESTEXPR(RIOSTACK_getInboundQueueLength(&stack), 0);
367
 
368
  /******************************************************************************/
369
  TESTEND;
370
  /******************************************************************************/
371
  PrintS("----------------------------------------------------------------------");
372
  PrintS("Step 6:");
373
  PrintS("Action: Add six more status-control-symbols. Then send a packet.");
374
  PrintS("Result: The receiver should enter link initialized and the packet should ");
375
  PrintS("        be received.");
376
  PrintS("----------------------------------------------------------------------");
377
  /******************************************************************************/
378
  TESTSTART("TG_riostack-TC1-Step6");
379
  /*****************************************************************************/
380
 
381
  /* Send 6 more status-control-symbols. */
382
  for(i = 0; i < 6; i++)
383
  {
384
    RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 0, 1, STYPE1_NOP, 0));
385
  }
386
 
387
  /* Send a packet and check that it is accepted. */
388
  /* The ackId on receiver in testobject is updated when this has been transmitted. */
389
  packetLength = createDoorbell(packet, 0, 0, 0, 0, 0);
390
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 0, 8, STYPE1_START_OF_PACKET, 0));
391
  for(i = 0; i < packetLength; i++)
392
  {
393
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
394
    d.data = packet[i];
395
    RIOSTACK_portAddSymbol(&stack, d);
396
  }
397
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 0, 8, STYPE1_END_OF_PACKET, 0));
398
 
399
  /* Check that the packet is received. */
400
  TESTEXPR(RIOSTACK_getInboundQueueLength(&stack), 1);
401
 
402
  /******************************************************************************/
403
  TESTEND;
404
  /******************************************************************************/
405
  PrintS("----------------------------------------------------------------------");
406
  PrintS("Step 7:");
407
  PrintS("Action: Get symbols from transmitter.");
408
  PrintS("Result: Status-control-symbols should still be generated each 15 symbol ");
409
  PrintS("until a total of 15 status-control-symbols has been transmitted. Once these ");
410
  PrintS("has been transmitted, the transmitter will be link initialized.");
411
  PrintS("----------------------------------------------------------------------");
412
  /******************************************************************************/
413
  TESTSTART("TG_riostack-TC1-Step7");
414
  /*****************************************************************************/
415
 
416
  /* Note that the available buffers in the receiver should have decremented once
417
     since the previously received packet has not been read from the application
418
     side of the stack yet. */
419
  for(j = 0; j < 14; j++)
420
  {
421
    for(i = 0; i < 15; i++)
422
    {
423
      s = RIOSTACK_portGetSymbol(&stack);
424
      TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
425
    }
426
    s = RIOSTACK_portGetSymbol(&stack);
427
    c = CreateControlSymbol(STYPE0_STATUS, 1, 7, STYPE1_NOP, 0);
428
    TESTEXPR(s.type, c.type);
429
    TESTEXPR(s.data, c.data);
430
  }
431
 
432
  /******************************************************************************/
433
  TESTEND;
434
  /******************************************************************************/
435
  PrintS("----------------------------------------------------------------------");
436
  PrintS("Step 8:");
437
  PrintS("Action: Get the first symbol from the transmitter once the link-intialized ");
438
  PrintS("        state has been entered.");
439
  PrintS("Result: A packet-accepted-symbol should be received for the newly received ");
440
  PrintS("        packet.");
441
  PrintS("----------------------------------------------------------------------");
442
  /******************************************************************************/
443
  TESTSTART("TG_riostack-TC1-Step8");
444
  /*****************************************************************************/
445
 
446
  c = CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 0, 7, STYPE1_NOP, 0);
447
  s = RIOSTACK_portGetSymbol(&stack);
448
  TESTEXPR(s.type, c.type);
449
  TESTEXPR(s.data, c.data);
450
 
451
  /******************************************************************************/
452
  TESTEND;
453
  /******************************************************************************/
454
  PrintS("----------------------------------------------------------------------");
455
  PrintS("Step 9:");
456
  PrintS("Action: Get the next symbols from the transmitter.");
457
  PrintS("Result: The packet placed in the outbound queue at startup should be ");
458
  PrintS("        received. Dont acknowledge the packet yet.");
459
  PrintS("----------------------------------------------------------------------");
460
  /******************************************************************************/
461
  TESTSTART("TG_riostack-TC1-Step9");
462
  /*****************************************************************************/
463
 
464
  /* Create a packet. */
465
  packetLength = createDoorbell(packet, 0, 1, 0xffff, 0, 0xdeaf);
466
 
467
  /* Receive the start of the frame. */
468
  c = CreateControlSymbol(STYPE0_STATUS, 1, 7, STYPE1_START_OF_PACKET, 0);
469
  s = RIOSTACK_portGetSymbol(&stack);
470
  TESTEXPR(s.type, c.type);
471
  TESTEXPR(s.data, c.data);
472
 
473
  /* Receive the data of the frame. */
474
  for(i = 0; i < packetLength; i++)
475
  {
476
    s = RIOSTACK_portGetSymbol(&stack);
477
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
478
    d.data = packet[i];
479
    TESTEXPR(s.type, d.type);
480
    TESTEXPR(s.data, d.data);
481
  }
482
 
483
  /* Receive the end of the frame. */
484
  c = CreateControlSymbol(STYPE0_STATUS, 1, 7, STYPE1_END_OF_PACKET, 0);
485
  s = RIOSTACK_portGetSymbol(&stack);
486
  TESTSYMBOL(s, c);
487
 
488
  /******************************************************************************/
489
  TESTEND;
490
  /******************************************************************************/
491
  PrintS("----------------------------------------------------------------------");
492
  PrintS("Step 10:");
493
  PrintS("Action: Remove the packet from the inbound queue. Dont acknowledge the");
494
  PrintS("        transmitted packet yet.");
495
  PrintS("Result: Check that status-control-symbols are sent each 256 symbol and that ");
496
  PrintS("        the buffer count is updated when the inbound packet has been read.");
497
  PrintS("----------------------------------------------------------------------");
498
  /******************************************************************************/
499
  TESTSTART("TG_riostack-TC1-Step10");
500
  /*****************************************************************************/
501
 
502
  /* Simulate the application reading the received packet to free one reception
503
     buffer. */
504
  RIOSTACK_getInboundPacket(&stack, &rioPacket);
505
 
506
  /* Check that the status-control-symbols are generated each 256 symbol. */
507
  for(i = 0; i < 255; i++)
508
  {
509
    s = RIOSTACK_portGetSymbol(&stack);
510
    TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
511
  }
512
 
513
  /* Check that the buffer status has been updated. */
514
  s = RIOSTACK_portGetSymbol(&stack);
515
  c = CreateControlSymbol(STYPE0_STATUS, 1, 8, STYPE1_NOP, 0);
516
  TESTEXPR(s.type, c.type);
517
  TESTEXPR(s.data, c.data);
518
 
519
  /******************************************************************************/
520
  TESTEND;
521
  /******************************************************************************/
522
  PrintS("----------------------------------------------------------------------");
523
  PrintS("Step 11:");
524
  PrintS("Action: Send a packet when an acknowledge has not been received.");
525
  PrintS("Result: Only idle and status control symbols should be transmitted until ");
526
  PrintS("        the packet-accepted symbol has been received.");
527
  PrintS("----------------------------------------------------------------------");
528
  /******************************************************************************/
529
  TESTSTART("TG_riostack-TC1-Step11");
530
  /*****************************************************************************/
531
 
532
  /* Place a packet in the outbound queue. */
533
  RIOPACKET_setDoorbell(&rioPacket, 2, 0xffff, 1, 0xc0de);
534
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
535
 
536
  packetLength = createDoorbell(packet, 1, 2, 0xffff, 1, 0xc0de);
537
 
538
  /* Receive the start of the frame. */
539
  c = CreateControlSymbol(STYPE0_STATUS, 1, 8, STYPE1_START_OF_PACKET, 0);
540
  s = RIOSTACK_portGetSymbol(&stack);
541
  TESTEXPR(s.type, c.type);
542
  TESTEXPR(s.data, c.data);
543
 
544
  /* Receive the data of the frame. */
545
  for(i = 0; i < packetLength; i++)
546
  {
547
    s = RIOSTACK_portGetSymbol(&stack);
548
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
549
    d.data = packet[i];
550
    TESTEXPR(s.type, d.type);
551
    TESTEXPR(s.data, d.data);
552
  }
553
 
554
  /* Receive the end of the frame. */
555
  c = CreateControlSymbol(STYPE0_STATUS, 1, 8, STYPE1_END_OF_PACKET, 0);
556
  s = RIOSTACK_portGetSymbol(&stack);
557
  TESTSYMBOL(s, c);
558
 
559
  /******************************************************************************/
560
  TESTEND;
561
  /******************************************************************************/
562
  PrintS("----------------------------------------------------------------------");
563
  PrintS("Step 12:");
564
  PrintS("Action: Send a packet-accepted symbol.");
565
  PrintS("Result: Check that the new packet is transmitted.");
566
  PrintS("----------------------------------------------------------------------");
567
  /******************************************************************************/
568
  TESTSTART("TG_riostack-TC1-Step12");
569
  /*****************************************************************************/
570
 
571
  /* Send acknowledge for the first frame. */
572
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 0, 1, STYPE1_NOP, 0));
573
 
574
  /* Check that status-control-symbols are transmitted once every 256 symbol with
575
     updated ackId. */
576
  for(i = 0; i < 255; i++)
577
  {
578
    s = RIOSTACK_portGetSymbol(&stack);
579
    TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
580
  }
581
  s = RIOSTACK_portGetSymbol(&stack);
582
  c = CreateControlSymbol(STYPE0_STATUS, 1, 8, STYPE1_NOP, 0);
583
  TESTEXPR(s.type, c.type);
584
  TESTEXPR(s.data, c.data);
585
 
586
  /******************************************************************************/
587
  TESTEND;
588
  /******************************************************************************/
589
  PrintS("----------------------------------------------------------------------");
590
  PrintS("Step 13:");
591
  PrintS("Action: Send a packet-accepted symbol.");
592
  PrintS("Result: Check that only idle and status-control-symbols are transmitted ");
593
  PrintS("----------------------------------------------------------------------");
594
  /******************************************************************************/
595
  TESTSTART("TG_riostack-TC1-Step13");
596
  /*****************************************************************************/
597
 
598
  /* Acknowledge the second frame. */
599
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 1, 1, STYPE1_NOP, 0));
600
 
601
  /* Check that status-control-symbols are transmitted once every 256 symbol with
602
     updated ackId. */
603
  for(i = 0; i < 255; i++)
604
  {
605
    s = RIOSTACK_portGetSymbol(&stack);
606
    TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
607
  }
608
  s = RIOSTACK_portGetSymbol(&stack);
609
  c = CreateControlSymbol(STYPE0_STATUS, 1, 8, STYPE1_NOP, 0);
610
  TESTEXPR(s.type, c.type);
611
  TESTEXPR(s.data, c.data);
612
 
613
  /******************************************************************************/
614
  TESTEND;
615
  /******************************************************************************/
616
  PrintS("----------------------------------------------------------------------");
617
  PrintS("TG_riostack-TC2");
618
  PrintS("Description: Test flow control.");
619
  PrintS("Requirement: XXXXX");
620
  PrintS("----------------------------------------------------------------------");
621
  PrintS("Step 1:");
622
  PrintS("Action: Send packets to receiver but don't acknowledge them.");
623
  PrintS("Result: The reception queue of the stack is full.");
624
  PrintS("----------------------------------------------------------------------");
625
  /******************************************************************************/
626
  TESTSTART("TG_riostack-TC2-Step1");
627
  /******************************************************************************/
628
 
629
  /* Fill input queue in receiver. */
630
  for(j = 0; j < 8; j++)
631
  {
632
    packetLength = createDoorbell(packet, 1+j, 0, 0, 1+j, 0);
633
 
634
    RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_START_OF_PACKET, 0));
635
    for(i = 0; i < packetLength; i++)
636
    {
637
      d.type = RIOSTACK_SYMBOL_TYPE_DATA;
638
      d.data = packet[i];
639
      RIOSTACK_portAddSymbol(&stack, d);
640
    }
641
    RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_END_OF_PACKET, 0));
642
 
643
    c = CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 1+j, 7-j, STYPE1_NOP, 0);
644
    s = RIOSTACK_portGetSymbol(&stack);
645
    TESTEXPR(s.type, c.type);
646
    TESTEXPR(s.data, c.data);
647
  }
648
 
649
  /******************************************************************************/
650
  TESTEND;
651
  /******************************************************************************/
652
  PrintS("----------------------------------------------------------------------");
653
  PrintS("Step 2:");
654
  PrintS("Action: Send a packet when the inbound queue of the stack is full.");
655
  PrintS("Result: The stack sends a packet-retry symbol. The receiver will end up in ");
656
  PrintS("input-retry-stopped state.");
657
  PrintS("----------------------------------------------------------------------");
658
  /******************************************************************************/
659
  TESTSTART("TG_riostack-TC2-Step2");
660
  /******************************************************************************/
661
 
662
  /* Send another packet. */
663
  packetLength = createDoorbell(packet, 9, 0, 0, 9, 0);
664
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_START_OF_PACKET, 0));
665
  for(i = 0; i < packetLength; i++)
666
  {
667
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
668
    d.data = packet[i];
669
    RIOSTACK_portAddSymbol(&stack, d);
670
  }
671
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_END_OF_PACKET, 0));
672
 
673
  /* Receive indication from stack that the packet must be retried. */
674
  c = CreateControlSymbol(STYPE0_PACKET_RETRY, 9, 0, STYPE1_NOP, 0);
675
  s = RIOSTACK_portGetSymbol(&stack);
676
  TESTEXPR(s.type, c.type);
677
  TESTEXPR(s.data, c.data);
678
 
679
  /******************************************************************************/
680
  TESTEND;
681
  /******************************************************************************/
682
  PrintS("----------------------------------------------------------------------");
683
  PrintS("Step 3:");
684
  PrintS("Action: Send a packet when the receiver is in input-retry-stopped.");
685
  PrintS("Result: The receiver should ignore the new packet.");
686
  PrintS("----------------------------------------------------------------------");
687
  /******************************************************************************/
688
  TESTSTART("TG_riostack-TC2-Step3");
689
  /******************************************************************************/
690
 
691
  /* Resend the packet. */
692
  packetLength = createDoorbell(packet, 9, 0, 0, 9, 0);
693
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_START_OF_PACKET, 0));
694
  for(i = 0; i < packetLength; i++)
695
  {
696
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
697
    d.data = packet[i];
698
    RIOSTACK_portAddSymbol(&stack, d);
699
  }
700
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_END_OF_PACKET, 0));
701
  s = RIOSTACK_portGetSymbol(&stack);
702
 
703
  /* Check that nothing is transmitted. */
704
  TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
705
 
706
  /* REMARK: Send other symbols here to check that they are handled as expected... */
707
 
708
  /******************************************************************************/
709
  TESTEND;
710
  /******************************************************************************/
711
  PrintS("----------------------------------------------------------------------");
712
  PrintS("Step 4:");
713
  PrintS("Action: Send restart-from-retry and resend the previous packet.");
714
  PrintS("Result: The receiver should leave the input-retry-stopped state and receive ");
715
  PrintS("        the new frame.");
716
  PrintS("----------------------------------------------------------------------");
717
  /******************************************************************************/
718
  TESTSTART("TG_riostack-TC2-Step4");
719
  /******************************************************************************/
720
 
721
  /* Send restart-from-retry. */
722
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_RESTART_FROM_RETRY, 0));
723
 
724
  /* Check that the transaction id is correct and remove a packet from the inbound
725
     queue. One entry in the inbound queue will be empty. */
726
  RIOSTACK_getInboundPacket(&stack, &rioPacket);
727
  RIOPACKET_getDoorbell(&rioPacket, &dstid, &srcid, &tid, &info);
728
  TESTEXPR(tid, 1);
729
 
730
  /* Check that the buffer status has changed to show that a buffer is available. */
731
  s = RIOSTACK_portGetSymbol(&stack);
732
  while(s.type == RIOSTACK_SYMBOL_TYPE_IDLE)
733
  {
734
    s = RIOSTACK_portGetSymbol(&stack);
735
  }
736
  c = CreateControlSymbol(STYPE0_STATUS, 9, 1, STYPE1_NOP, 0);
737
  TESTEXPR(s.type, c.type);
738
  TESTEXPR(s.data, c.data);
739
 
740
  /* Resend the packet and check that it is received. */
741
  packetLength = createDoorbell(packet, 9, 0, 0, 9, 0);
742
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_START_OF_PACKET, 0));
743
  for(i = 0; i < packetLength; i++)
744
  {
745
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
746
    d.data = packet[i];
747
    RIOSTACK_portAddSymbol(&stack, d);
748
  }
749
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_END_OF_PACKET, 0));
750
  c = CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 9, 0, STYPE1_NOP, 0);
751
  s = RIOSTACK_portGetSymbol(&stack);
752
  TESTEXPR(s.type, c.type);
753
  TESTEXPR(s.data, c.data);
754
 
755
  /******************************************************************************/
756
  TESTEND;
757
  /******************************************************************************/
758
  PrintS("----------------------------------------------------------------------");
759
  PrintS("Step 5:");
760
  PrintS("Action: Place receiver in input-retry-stopped state.");
761
  PrintS("Result: Check that packets may be transmitted normally.");
762
  PrintS("----------------------------------------------------------------------");
763
  /******************************************************************************/
764
  TESTSTART("TG_riostack-TC2-Step5");
765
  /******************************************************************************/
766
 
767
  /* Send another packet and check that the receiver indicates that it should be retried. */
768
  packetLength = createDoorbell(packet, 10, 0, 0, 10, 0);
769
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_START_OF_PACKET, 0));
770
  for(i = 0; i < packetLength; i++)
771
  {
772
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
773
    d.data = packet[i];
774
    RIOSTACK_portAddSymbol(&stack, d);
775
  }
776
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 2, 1, STYPE1_END_OF_PACKET, 0));
777
  c = CreateControlSymbol(STYPE0_PACKET_RETRY, 10, 0, STYPE1_NOP, 0);
778
  s = RIOSTACK_portGetSymbol(&stack);
779
  TESTEXPR(s.type, c.type);
780
  TESTEXPR(s.data, c.data);
781
 
782
  /* Send two packets to see that the first acknowledge has been processed. */
783
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 2, 0xfeed);
784
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
785
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 3, 0xdeed);
786
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
787
 
788
  /* Get the first packet. */
789
  packetLength = createDoorbell(packet, 2, 0, 0xffff, 2, 0xfeed);
790
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_START_OF_PACKET, 0);
791
  s = RIOSTACK_portGetSymbol(&stack);
792
  TESTEXPR(s.type, c.type);
793
  TESTEXPR(s.data, c.data);
794
  for(i = 0; i < packetLength; i++)
795
  {
796
    s = RIOSTACK_portGetSymbol(&stack);
797
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
798
    d.data = packet[i];
799
    TESTEXPR(s.type, d.type);
800
    TESTEXPR(s.data, d.data);
801
  }
802
 
803
  /* Get the second packet. */
804
  packetLength = createDoorbell(packet, 3, 0, 0xffff, 3, 0xdeed);
805
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_START_OF_PACKET, 0);
806
  s = RIOSTACK_portGetSymbol(&stack);
807
  TESTSYMBOL(s, c);
808
  for(i = 0; i < packetLength; i++)
809
  {
810
    s = RIOSTACK_portGetSymbol(&stack);
811
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
812
    d.data = packet[i];
813
    TESTEXPR(s.type, d.type);
814
    TESTEXPR(s.data, d.data);
815
  }
816
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_END_OF_PACKET, 0);
817
  s = RIOSTACK_portGetSymbol(&stack);
818
  TESTEXPR(s.type, c.type);
819
  TESTEXPR(s.data, c.data);
820
 
821
  /* Indicate the packets must be retransmitted. */
822
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_RETRY, 2, 1, STYPE1_NOP, 0));
823
 
824
  /* Receive confirmation that the packet will be retransmitted. */
825
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_RESTART_FROM_RETRY, 0);
826
  s = RIOSTACK_portGetSymbol(&stack);
827
  TESTSYMBOL(s, c);
828
 
829
  /* Get the retransmission of the first packet. */
830
  packetLength = createDoorbell(packet, 2, 0, 0xffff, 2, 0xfeed);
831
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_START_OF_PACKET, 0);
832
  s = RIOSTACK_portGetSymbol(&stack);
833
  TESTEXPR(s.type, c.type);
834
  TESTEXPR(s.data, c.data);
835
  for(i = 0; i < packetLength; i++)
836
  {
837
    s = RIOSTACK_portGetSymbol(&stack);
838
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
839
    d.data = packet[i];
840
    TESTEXPR(s.type, d.type);
841
    TESTEXPR(s.data, d.data);
842
  }
843
 
844
  /* Get the retransmission of the second packet. */
845
  packetLength = createDoorbell(packet, 3, 0, 0xffff, 3, 0xdeed);
846
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_START_OF_PACKET, 0);
847
  s = RIOSTACK_portGetSymbol(&stack);
848
  TESTSYMBOL(s, c);
849
  for(i = 0; i < packetLength; i++)
850
  {
851
    s = RIOSTACK_portGetSymbol(&stack);
852
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
853
    d.data = packet[i];
854
    TESTEXPR(s.type, d.type);
855
    TESTEXPR(s.data, d.data);
856
  }
857
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_END_OF_PACKET, 0);
858
  s = RIOSTACK_portGetSymbol(&stack);
859
  TESTEXPR(s.type, c.type);
860
  TESTEXPR(s.data, c.data);
861
 
862
  /* Confirm the reception of the packets. */
863
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 2, 1, STYPE1_NOP, 0));
864
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 3, 1, STYPE1_NOP, 0));
865
 
866
  /******************************************************************************/
867
  TESTEND;
868
  /******************************************************************************/
869
  PrintS("----------------------------------------------------------------------");
870
  PrintS("Step 6:");
871
  PrintS("Action: Send status-control-symbol to show that no packets can be ");
872
  PrintS("        transmitted.");
873
  PrintS("Result: No packets should be transmitted.");
874
  PrintS("----------------------------------------------------------------------");
875
  /******************************************************************************/
876
  TESTSTART("TG_riostack-TC2-Step6");
877
  /******************************************************************************/
878
 
879
  /* Send status with bufferStatus set to zero. */
880
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 4, 0, STYPE1_NOP, 0));
881
 
882
  /* Send a packet. */
883
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 4, 0xf00d);
884
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
885
 
886
  /* Check that nothing is transmitted but status-control-symbols. */
887
  for(i = 0; i < 255; i++)
888
  {
889
    s = RIOSTACK_portGetSymbol(&stack);
890
    TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
891
  }
892
  s = RIOSTACK_portGetSymbol(&stack);
893
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_NOP, 0);
894
  TESTEXPR(s.type, c.type);
895
  TESTEXPR(s.data, c.data);
896
 
897
  /******************************************************************************/
898
  TESTEND;
899
  /******************************************************************************/
900
  PrintS("----------------------------------------------------------------------");
901
  PrintS("Step 7:");
902
  PrintS("Action: Indicate free buffers and receive a frame, then request it to be ");
903
  PrintS("retried.");
904
  PrintS("Result: The packet should be retransmitted.");
905
  PrintS("----------------------------------------------------------------------");
906
  /******************************************************************************/
907
  TESTSTART("TG_riostack-TC2-Step7");
908
  /******************************************************************************/
909
 
910
  /* Send status with bufferStatus set to available. */
911
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 4, 1, STYPE1_NOP, 0));
912
 
913
  /* Get the packet but request it to be retried. */
914
  packetLength = createDoorbell(packet, 4, 0, 0xffff, 4, 0xf00d);
915
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_START_OF_PACKET, 0);
916
  s = RIOSTACK_portGetSymbol(&stack);
917
  TESTEXPR(s.type, c.type);
918
  TESTEXPR(s.data, c.data);
919
  for(i = 0; i < packetLength; i++)
920
  {
921
    s = RIOSTACK_portGetSymbol(&stack);
922
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
923
    d.data = packet[i];
924
    TESTEXPR(s.type, d.type);
925
    TESTEXPR(s.data, d.data);
926
  }
927
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_END_OF_PACKET, 0);
928
  s = RIOSTACK_portGetSymbol(&stack);
929
  TESTEXPR(s.type, c.type);
930
  TESTEXPR(s.data, c.data);
931
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_RETRY, 4, 1, STYPE1_NOP, 0));
932
 
933
  /* Check the acknowledge of the retransmission. */
934
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_RESTART_FROM_RETRY, 0);
935
  s = RIOSTACK_portGetSymbol(&stack);
936
  TESTEXPR(s.type, c.type);
937
  TESTEXPR(s.data, c.data);
938
 
939
  /* Get the packet and acknowledge it. */
940
  packetLength = createDoorbell(packet, 4, 0, 0xffff, 4, 0xf00d);
941
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_START_OF_PACKET, 0);
942
  s = RIOSTACK_portGetSymbol(&stack);
943
  TESTEXPR(s.type, c.type);
944
  TESTEXPR(s.data, c.data);
945
  for(i = 0; i < packetLength; i++)
946
  {
947
    s = RIOSTACK_portGetSymbol(&stack);
948
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
949
    d.data = packet[i];
950
    TESTEXPR(s.type, d.type);
951
    TESTEXPR(s.data, d.data);
952
  }
953
  c = CreateControlSymbol(STYPE0_STATUS, 10, 0, STYPE1_END_OF_PACKET, 0);
954
  s = RIOSTACK_portGetSymbol(&stack);
955
  TESTEXPR(s.type, c.type);
956
  TESTEXPR(s.data, c.data);
957
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 4, 1, STYPE1_NOP, 0));
958
 
959
  /******************************************************************************/
960
  TESTEND;
961
  /******************************************************************************/
962
  PrintS("----------------------------------------------------------------------");
963
  PrintS("Step 8:");
964
  PrintS("Action: Read all inbound packets from the reception queue.");
965
  PrintS("Result: The buffer status should be updated.");
966
  PrintS("----------------------------------------------------------------------");
967
  /******************************************************************************/
968
  TESTSTART("TG_riostack-TC2-Step8");
969
  /******************************************************************************/
970
 
971
  for(j = 0; j < 8; j++)
972
  {
973
    RIOSTACK_getInboundPacket(&stack, &rioPacket);
974
    RIOPACKET_getDoorbell(&rioPacket, &dstid, &srcid, &tid, &info);
975
    TESTEXPR(tid, j+2);
976
 
977
    for(i = 0; i < 255; i++)
978
    {
979
      s = RIOSTACK_portGetSymbol(&stack);
980
      TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
981
    }
982
    s = RIOSTACK_portGetSymbol(&stack);
983
    c = CreateControlSymbol(STYPE0_STATUS, 10, j+1, STYPE1_NOP, 0);
984
    TESTEXPR(s.type, c.type);
985
    TESTEXPR(s.data, c.data);
986
  }
987
 
988
  /******************************************************************************/
989
  TESTEND;
990
  /******************************************************************************/
991
  PrintS("----------------------------------------------------------------------");
992
  PrintS("Step 9:");
993
  PrintS("Action: Send a restart-from-retry to make the receiver leave the ");
994
  PrintS("        input-retry-stopped state.");
995
  PrintS("Result: New packets should be received again.");
996
  PrintS("----------------------------------------------------------------------");
997
  /******************************************************************************/
998
  TESTSTART("TG_riostack-TC2-Step9");
999
  /******************************************************************************/
1000
 
1001
  /* Send restart-from-retry. */
1002
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1, STYPE1_RESTART_FROM_RETRY, 0));
1003
 
1004
 
1005
  /******************************************************************************/
1006
  TESTEND;
1007
  /******************************************************************************/
1008
  PrintS("----------------------------------------------------------------------");
1009
  PrintS("TG_riostack-TC3");
1010
  PrintS("Description: Test receiver error handling.");
1011
  PrintS("Requirement: XXXXX");
1012
  PrintS("----------------------------------------------------------------------");
1013
  PrintS("Step 1:");
1014
  PrintS("Action: Send invalid ack id in packet.");
1015
  PrintS("Result: Input-error-stopped state should be entered and link-response ");
1016
  PrintS("        should indicate an ackId error.");
1017
  PrintS("----------------------------------------------------------------------");
1018
  /******************************************************************************/
1019
  TESTSTART("TG_riostack-TC3-Step1");
1020
  /******************************************************************************/
1021
 
1022
  /* Send packet with invalid ackId, same as sent previously. */
1023
  packetLength = createDoorbell(packet, 9, 0, 0, 10, 0);
1024
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1, STYPE1_START_OF_PACKET, 0));
1025
  for(i = 0; i < packetLength; i++)
1026
  {
1027
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1028
    d.data = packet[i];
1029
    RIOSTACK_portAddSymbol(&stack, d);
1030
  }
1031
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1, STYPE1_END_OF_PACKET, 0));
1032
 
1033
  /* Check that the packet is not accepted with cause error in ackId. */
1034
  c = CreateControlSymbol(STYPE0_PACKET_NOT_ACCEPTED, 0, 1, STYPE1_NOP, 0);
1035
  s = RIOSTACK_portGetSymbol(&stack);
1036
  TESTEXPR(s.type, c.type);
1037
  TESTEXPR(s.data, c.data);
1038
 
1039
  /* Send a link-request. */
1040
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1,
1041
                                                     STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS));
1042
 
1043
  /* Check that a link-response is returned. */
1044
  /* Note that the status of the input-port will be reported as ok since a
1045
     link-request has been received. */
1046
  c = CreateControlSymbol(STYPE0_LINK_RESPONSE, 10, 16, STYPE1_NOP, 0);
1047
  s = RIOSTACK_portGetSymbol(&stack);
1048
  TESTEXPR(s.type, c.type);
1049
  TESTEXPR(s.data, c.data);
1050
 
1051
  /* Check that a status is transmitted directly after the link-response. */
1052
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_NOP, 0);
1053
  s = RIOSTACK_portGetSymbol(&stack);
1054
  TESTEXPR(s.type, c.type);
1055
  TESTEXPR(s.data, c.data);
1056
 
1057
  /******************************************************************************/
1058
  TESTEND;
1059
  /******************************************************************************/
1060
  PrintS("----------------------------------------------------------------------");
1061
  PrintS("Step 2:");
1062
  PrintS("Action: Send packet with invalid CRC.");
1063
  PrintS("Result: Input-error-stopped state should be entered and link-response ");
1064
  PrintS("        should indicate a CRC error.");
1065
  PrintS("----------------------------------------------------------------------");
1066
  /******************************************************************************/
1067
  TESTSTART("TG_riostack-TC3-Step2");
1068
  /******************************************************************************/
1069
 
1070
  /* Send packet with invalid crc. */
1071
  packetLength = createDoorbell(packet, 10, 0, 0, 10, 0);
1072
  packet[0] ^= 0x00000001;
1073
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1, STYPE1_START_OF_PACKET, 0));
1074
  for(i = 0; i < packetLength; i++)
1075
  {
1076
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1077
    d.data = packet[i];
1078
    RIOSTACK_portAddSymbol(&stack, d);
1079
  }
1080
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1, STYPE1_END_OF_PACKET, 0));
1081
 
1082
  /* Check that the packet is not accepted with cause error in ackId. */
1083
  c = CreateControlSymbol(STYPE0_PACKET_NOT_ACCEPTED, 0, 4, STYPE1_NOP, 0);
1084
  s = RIOSTACK_portGetSymbol(&stack);
1085
  TESTEXPR(s.type, c.type);
1086
  TESTEXPR(s.data, c.data);
1087
 
1088
  /* Send a link-request. */
1089
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1,
1090
                                                     STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS));
1091
 
1092
  /* Check that a link-response is returned. */
1093
  /* Note that the status of the input-port will be reported as ok since a
1094
     link-request has been received. */
1095
  c = CreateControlSymbol(STYPE0_LINK_RESPONSE, 10, 16, STYPE1_NOP, 0);
1096
  s = RIOSTACK_portGetSymbol(&stack);
1097
  TESTEXPR(s.type, c.type);
1098
  TESTEXPR(s.data, c.data);
1099
 
1100
  /* Check that a status is transmitted directly after the link-response. */
1101
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_NOP, 0);
1102
  s = RIOSTACK_portGetSymbol(&stack);
1103
  TESTEXPR(s.type, c.type);
1104
  TESTEXPR(s.data, c.data);
1105
 
1106
  /******************************************************************************/
1107
  TESTEND;
1108
  /******************************************************************************/
1109
  PrintS("----------------------------------------------------------------------");
1110
  PrintS("Step 3:");
1111
  PrintS("Action: Send a packet that is too short.");
1112
  PrintS("Result: Input-error-stopped state should be entered and link-response ");
1113
  PrintS("        should indicate a packet error.");
1114
  PrintS("----------------------------------------------------------------------");
1115
  /******************************************************************************/
1116
  TESTSTART("TG_riostack-TC3-Step3");
1117
  /******************************************************************************/
1118
 
1119
  /* Send packet with valid ackid and crc but too short. */
1120
  packetLength = createDoorbell(packet, 10, 0, 0, 10, 0);
1121
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1, STYPE1_START_OF_PACKET, 0));
1122
  d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1123
  d.data = packet[0];
1124
  RIOSTACK_portAddSymbol(&stack, d);
1125
  d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1126
  d.data = ((uint32_t) RIOPACKET_Crc32(packet[0] & 0x07ffffff, 0xffff)) << 16;
1127
  RIOSTACK_portAddSymbol(&stack, d);
1128
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1, STYPE1_END_OF_PACKET, 0));
1129
 
1130
  /* Check that the packet is not accepted with cause error in ackId. */
1131
  c = CreateControlSymbol(STYPE0_PACKET_NOT_ACCEPTED, 0, 31, STYPE1_NOP, 0);
1132
  s = RIOSTACK_portGetSymbol(&stack);
1133
  TESTEXPR(s.type, c.type);
1134
  TESTEXPR(s.data, c.data);
1135
 
1136
  /* Send a link-request. */
1137
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1,
1138
                                                     STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS));
1139
 
1140
  /* Check that a link-response is returned. */
1141
  /* Note that the status of the input-port will be reported as ok since a
1142
     link-request has been received. */
1143
  c = CreateControlSymbol(STYPE0_LINK_RESPONSE, 10, 16, STYPE1_NOP, 0);
1144
  s = RIOSTACK_portGetSymbol(&stack);
1145
  TESTEXPR(s.type, c.type);
1146
  TESTEXPR(s.data, c.data);
1147
 
1148
  /* Check that a status is transmitted directly after the link-response. */
1149
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_NOP, 0);
1150
  s = RIOSTACK_portGetSymbol(&stack);
1151
  TESTEXPR(s.type, c.type);
1152
  TESTEXPR(s.data, c.data);
1153
 
1154
  /******************************************************************************/
1155
  TESTEND;
1156
  /******************************************************************************/
1157
  PrintS("----------------------------------------------------------------------");
1158
  PrintS("Step 4:");
1159
  PrintS("Action: Send a packet that is too long.");
1160
  PrintS("Result: Input-error-stopped state should be entered and link-response ");
1161
  PrintS("        should indicate a packet error.");
1162
  PrintS("----------------------------------------------------------------------");
1163
  /******************************************************************************/
1164
  TESTSTART("TG_riostack-TC3-Step4");
1165
  /******************************************************************************/
1166
 
1167
  /* Send packet with too many data symbols and without a end-of-packet. */
1168
  packetLength = createDoorbell(packet, 10, 0, 0, 10, 0);
1169
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1, STYPE1_START_OF_PACKET, 0));
1170
  for(i = 0; i < packetLength; i++)
1171
  {
1172
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1173
    d.data = packet[i];
1174
    RIOSTACK_portAddSymbol(&stack, d);
1175
  }
1176
  for(; i < 70; i++)
1177
  {
1178
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1179
    d.data = i;
1180
    RIOSTACK_portAddSymbol(&stack, d);
1181
  }
1182
 
1183
  /* Check that the packet is not accepted with cause error in ackId. */
1184
  c = CreateControlSymbol(STYPE0_PACKET_NOT_ACCEPTED, 0, 31, STYPE1_NOP, 0);
1185
  s = RIOSTACK_portGetSymbol(&stack);
1186
  TESTEXPR(s.type, c.type);
1187
  TESTEXPR(s.data, c.data);
1188
 
1189
  /* Send a link-request. */
1190
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1,
1191
                                                     STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS));
1192
 
1193
  /* Check that a link-response is returned. */
1194
  /* Note that the status of the input-port will be reported as ok since a
1195
     link-request has been received. */
1196
  c = CreateControlSymbol(STYPE0_LINK_RESPONSE, 10, 16, STYPE1_NOP, 0);
1197
  s = RIOSTACK_portGetSymbol(&stack);
1198
  TESTEXPR(s.type, c.type);
1199
  TESTEXPR(s.data, c.data);
1200
 
1201
  /* Check that a status is transmitted directly after the link-response. */
1202
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_NOP, 0);
1203
  s = RIOSTACK_portGetSymbol(&stack);
1204
  TESTEXPR(s.type, c.type);
1205
  TESTEXPR(s.data, c.data);
1206
 
1207
  /******************************************************************************/
1208
  TESTEND;
1209
  /******************************************************************************/
1210
  PrintS("----------------------------------------------------------------------");
1211
  PrintS("Step 5:");
1212
  PrintS("Action: Send a data symbol without starting a packet.");
1213
  PrintS("Result: Input-error-stopped state should be entered and link-response ");
1214
  PrintS("        should indicate a packet error.");
1215
  PrintS("----------------------------------------------------------------------");
1216
  /******************************************************************************/
1217
  TESTSTART("TG_riostack-TC3-Step5");
1218
  /******************************************************************************/
1219
 
1220
  /* Send a data symbol. */
1221
  packetLength = createDoorbell(packet, 10, 0, 0, 10, 0);
1222
  d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1223
  d.data = packet[0];
1224
  RIOSTACK_portAddSymbol(&stack, d);
1225
 
1226
  /* Check that the packet is not accepted with cause error in ackId. */
1227
  c = CreateControlSymbol(STYPE0_PACKET_NOT_ACCEPTED, 0, 31, STYPE1_NOP, 0);
1228
  s = RIOSTACK_portGetSymbol(&stack);
1229
  TESTEXPR(s.type, c.type);
1230
  TESTEXPR(s.data, c.data);
1231
 
1232
  /* Send a link-request. */
1233
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1,
1234
                                                     STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS));
1235
 
1236
  /* Check that a link-response is returned. */
1237
  /* Note that the status of the input-port will be reported as ok since a
1238
     link-request has been received. */
1239
  c = CreateControlSymbol(STYPE0_LINK_RESPONSE, 10, 16, STYPE1_NOP, 0);
1240
  s = RIOSTACK_portGetSymbol(&stack);
1241
  TESTEXPR(s.type, c.type);
1242
  TESTEXPR(s.data, c.data);
1243
 
1244
  /* Check that a status is transmitted directly after the link-response. */
1245
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_NOP, 0);
1246
  s = RIOSTACK_portGetSymbol(&stack);
1247
  TESTEXPR(s.type, c.type);
1248
  TESTEXPR(s.data, c.data);
1249
 
1250
  /******************************************************************************/
1251
  TESTEND;
1252
  /******************************************************************************/
1253
  PrintS("----------------------------------------------------------------------");
1254
  PrintS("Step 6:");
1255
  PrintS("Action: Send end-of-packet without matching start.");
1256
  PrintS("Result: Input-error-stopped state should be entered and link-response ");
1257
  PrintS("        should indicate a packet error.");
1258
  PrintS("----------------------------------------------------------------------");
1259
  /******************************************************************************/
1260
  TESTSTART("TG_riostack-TC3-Step6");
1261
  /******************************************************************************/
1262
 
1263
  /* Send end-of-packet. */
1264
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1, STYPE1_END_OF_PACKET, 0));
1265
 
1266
  /* Check that the packet is not accepted with cause error in ackId. */
1267
  c = CreateControlSymbol(STYPE0_PACKET_NOT_ACCEPTED, 0, 4, STYPE1_NOP, 0);
1268
  s = RIOSTACK_portGetSymbol(&stack);
1269
  TESTSYMBOL(s, c);
1270
 
1271
  /* Send a link-request. */
1272
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1,
1273
                                                     STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS));
1274
 
1275
  /* Check that a link-response is returned. */
1276
  /* Note that the status of the input-port will be reported as ok since a
1277
     link-request has been received. */
1278
  c = CreateControlSymbol(STYPE0_LINK_RESPONSE, 10, 16, STYPE1_NOP, 0);
1279
  s = RIOSTACK_portGetSymbol(&stack);
1280
  TESTEXPR(s.type, c.type);
1281
  TESTEXPR(s.data, c.data);
1282
 
1283
  /* Check that a status is transmitted directly after the link-response. */
1284
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_NOP, 0);
1285
  s = RIOSTACK_portGetSymbol(&stack);
1286
  TESTEXPR(s.type, c.type);
1287
  TESTEXPR(s.data, c.data);
1288
 
1289
  /******************************************************************************/
1290
  TESTEND;
1291
  /******************************************************************************/
1292
  PrintS("----------------------------------------------------------------------");
1293
  PrintS("Step 7:");
1294
  PrintS("Action: Send a symbol indicating a codec error.");
1295
  PrintS("Result: Input-error-stopped state should be entered and link-response ");
1296
  PrintS("        should indicate a symbol error.");
1297
  PrintS("----------------------------------------------------------------------");
1298
  /******************************************************************************/
1299
  TESTSTART("TG_riostack-TC3-Step7");
1300
  /******************************************************************************/
1301
 
1302
  /* Send error-symbol. */
1303
  s.type = RIOSTACK_SYMBOL_TYPE_ERROR;
1304
  RIOSTACK_portAddSymbol(&stack, s);
1305
 
1306
  /* Check that the packet is not accepted with cause error in ackId. */
1307
  c = CreateControlSymbol(STYPE0_PACKET_NOT_ACCEPTED, 0, 5, STYPE1_NOP, 0);
1308
  s = RIOSTACK_portGetSymbol(&stack);
1309
  TESTEXPR(s.type, c.type);
1310
  TESTEXPR(s.data, c.data);
1311
 
1312
  /* Send a link-request. */
1313
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1,
1314
                                                     STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS));
1315
 
1316
  /* Check that a link-response is returned. */
1317
  /* Note that the status of the input-port will be reported as ok since a
1318
     link-request has been received. */
1319
  c = CreateControlSymbol(STYPE0_LINK_RESPONSE, 10, 16, STYPE1_NOP, 0);
1320
  s = RIOSTACK_portGetSymbol(&stack);
1321
  TESTEXPR(s.type, c.type);
1322
  TESTEXPR(s.data, c.data);
1323
 
1324
  /* Check that a status is transmitted directly after the link-response. */
1325
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_NOP, 0);
1326
  s = RIOSTACK_portGetSymbol(&stack);
1327
  TESTEXPR(s.type, c.type);
1328
  TESTEXPR(s.data, c.data);
1329
 
1330
  /******************************************************************************/
1331
  TESTEND;
1332
  /******************************************************************************/
1333
  PrintS("----------------------------------------------------------------------");
1334
  PrintS("TG_riostack-TC4");
1335
  PrintS("Description: Test transmitter error handling.");
1336
  PrintS("Requirement: XXXXX");
1337
  PrintS("----------------------------------------------------------------------");
1338
  PrintS("Step 1:");
1339
  PrintS("Action: Send acknowledge for a frame that has not been transmitted and ");
1340
  PrintS("        without any frame being expected.");
1341
  PrintS("Result: The transmitter should enter output-error-stopped and send ");
1342
  PrintS("        link-request.");
1343
  PrintS("----------------------------------------------------------------------");
1344
  /******************************************************************************/
1345
  TESTSTART("TG_riostack-TC4-Step1");
1346
  /******************************************************************************/
1347
 
1348
  /* Packet acknowledge for unsent frame. */
1349
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 5, 1, STYPE1_NOP, 0));
1350
 
1351
  /* Check that a link-request is received as the transmitter enters
1352
     output-error-stopped state. */
1353
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8,
1354
                          STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS);
1355
  s = RIOSTACK_portGetSymbol(&stack);
1356
  TESTEXPR(s.type, c.type);
1357
  TESTEXPR(s.data, c.data);
1358
 
1359
  /* Send link-response with expected ackId. */
1360
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_LINK_RESPONSE, 5, 16, STYPE1_NOP, 0));
1361
 
1362
  /* Send a status directly afterwards. */
1363
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 5, 1, STYPE1_NOP, 0));
1364
 
1365
  /* Check that packets are relayed after this. */
1366
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 5, 2);
1367
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1368
  packetLength = createDoorbell(packet, 5, 0, 0xffff, 5, 2);
1369
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1370
  s = RIOSTACK_portGetSymbol(&stack);
1371
  TESTEXPR(s.type, c.type);
1372
  TESTEXPR(s.data, c.data);
1373
  for(i = 0; i < packetLength; i++)
1374
  {
1375
    s = RIOSTACK_portGetSymbol(&stack);
1376
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1377
    d.data = packet[i];
1378
    TESTEXPR(s.type, d.type);
1379
    TESTEXPR(s.data, d.data);
1380
  }
1381
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_END_OF_PACKET, 0);
1382
  s = RIOSTACK_portGetSymbol(&stack);
1383
  TESTEXPR(s.type, c.type);
1384
  TESTEXPR(s.data, c.data);
1385
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 5, 1, STYPE1_NOP, 0));
1386
 
1387
  /******************************************************************************/
1388
  TESTEND;
1389
  /******************************************************************************/
1390
  PrintS("----------------------------------------------------------------------");
1391
  PrintS("Step 2:");
1392
  PrintS("Action: Send a packet and send acknowledge for a previous frame. Then send ");
1393
  PrintS("        a link-response indicating that the packet was received (accepted ");
1394
  PrintS("        but reply corrupted).");
1395
  PrintS("Result: The transmitter should enter output-error-stopped state and send ");
1396
  PrintS("        link-request and proceed with the next packet.");
1397
  PrintS("----------------------------------------------------------------------");
1398
  /******************************************************************************/
1399
  TESTSTART("TG_riostack-TC4-Step2");
1400
  /******************************************************************************/
1401
 
1402
  /* Send a packet. */
1403
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 6, 2);
1404
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1405
  packetLength = createDoorbell(packet, 6, 0, 0xffff, 6, 2);
1406
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1407
  s = RIOSTACK_portGetSymbol(&stack);
1408
  TESTEXPR(s.type, c.type);
1409
  TESTEXPR(s.data, c.data);
1410
  for(i = 0; i < packetLength; i++)
1411
  {
1412
    s = RIOSTACK_portGetSymbol(&stack);
1413
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1414
    d.data = packet[i];
1415
    TESTEXPR(s.type, d.type);
1416
    TESTEXPR(s.data, d.data);
1417
  }
1418
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_END_OF_PACKET, 0);
1419
  s = RIOSTACK_portGetSymbol(&stack);
1420
  TESTEXPR(s.type, c.type);
1421
  TESTEXPR(s.data, c.data);
1422
 
1423
  /* Send acknowledge for another packet. */
1424
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 5, 1, STYPE1_NOP, 0));
1425
 
1426
  /* Check that a link-request is received as the transmitter enters
1427
     output-error-stopped state. */
1428
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8,
1429
                          STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS);
1430
  s = RIOSTACK_portGetSymbol(&stack);
1431
  TESTEXPR(s.type, c.type);
1432
  TESTEXPR(s.data, c.data);
1433
 
1434
  /* Send link-response with expected ackId. */
1435
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_LINK_RESPONSE, 7, 16, STYPE1_NOP, 0));
1436
 
1437
  /* Send a status directly afterwards. */
1438
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 7, 1, STYPE1_NOP, 0));
1439
 
1440
  /******************************************************************************/
1441
  TESTEND;
1442
  /******************************************************************************/
1443
  PrintS("----------------------------------------------------------------------");
1444
  PrintS("Step 3:");
1445
  PrintS("Action: Send a packet and let the packet-accepted time out. Then send a ");
1446
  PrintS("        link-response indicating that the packet was not received.");
1447
  PrintS("Result: The transmitter should enter output-error-stopped state, send a");
1448
  PrintS("        link-request and then resend the packet.");
1449
  PrintS("----------------------------------------------------------------------");
1450
  /******************************************************************************/
1451
  TESTSTART("TG_riostack-TC4-Step3");
1452
  /******************************************************************************/
1453
 
1454
  /* Set the time at frame transmission. */
1455
  RIOSTACK_portSetTime(&stack, 2);
1456
 
1457
  /* Send an output packet. */
1458
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 7, 2);
1459
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1460
 
1461
  /* Receive the transmitted packet. */
1462
  packetLength = createDoorbell(packet, 7, 0, 0xffff, 7, 2);
1463
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1464
  s = RIOSTACK_portGetSymbol(&stack);
1465
  TESTEXPR(s.type, c.type);
1466
  TESTEXPR(s.data, c.data);
1467
  for(i = 0; i < packetLength; i++)
1468
  {
1469
    s = RIOSTACK_portGetSymbol(&stack);
1470
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1471
    d.data = packet[i];
1472
    TESTEXPR(s.type, d.type);
1473
    TESTEXPR(s.data, d.data);
1474
  }
1475
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_END_OF_PACKET, 0);
1476
  s = RIOSTACK_portGetSymbol(&stack);
1477
  TESTEXPR(s.type, c.type);
1478
  TESTEXPR(s.data, c.data);
1479
 
1480
  /* Indicate that time has passed to trigger a timeout. */
1481
  RIOSTACK_portSetTime(&stack, 3);
1482
 
1483
  /* Check that a link-request is received as the transmitter enters
1484
     output-error-stopped state. */
1485
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8,
1486
                          STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS);
1487
  s = RIOSTACK_portGetSymbol(&stack);
1488
  TESTEXPR(s.type, c.type);
1489
  TESTEXPR(s.data, c.data);
1490
 
1491
  /* Send link-response with expected ackId. */
1492
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_LINK_RESPONSE, 7, 16, STYPE1_NOP, 0));
1493
 
1494
  /* Send a status directly afterwards. */
1495
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 7, 1, STYPE1_NOP, 0));
1496
 
1497
  /* Receive retransmitted packet. */
1498
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1499
  s = RIOSTACK_portGetSymbol(&stack);
1500
  TESTEXPR(s.type, c.type);
1501
  TESTEXPR(s.data, c.data);
1502
  for(i = 0; i < packetLength; i++)
1503
  {
1504
    s = RIOSTACK_portGetSymbol(&stack);
1505
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1506
    d.data = packet[i];
1507
    TESTEXPR(s.type, d.type);
1508
    TESTEXPR(s.data, d.data);
1509
  }
1510
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_END_OF_PACKET, 0);
1511
  s = RIOSTACK_portGetSymbol(&stack);
1512
  TESTEXPR(s.type, c.type);
1513
  TESTEXPR(s.data, c.data);
1514
 
1515
  /* Send acknowledge for the retransmitted packet. */
1516
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 7, 1, STYPE1_NOP, 0));
1517
 
1518
  /******************************************************************************/
1519
  TESTEND;
1520
  /******************************************************************************/
1521
  PrintS("----------------------------------------------------------------------");
1522
  PrintS("Step 4:");
1523
  PrintS("Action: Send a packet and then indicate that the packet was not accepted. ");
1524
  PrintS("        Then send a link-response indicating that the packet was not received.");
1525
  PrintS("Result: The transmitter should enter output-error-stopped state, send a");
1526
  PrintS("        link-request and then resend the packet.");
1527
  PrintS("----------------------------------------------------------------------");
1528
  /******************************************************************************/
1529
  TESTSTART("TG_riostack-TC4-Step4");
1530
  /******************************************************************************/
1531
 
1532
  /* Send an output packet. */
1533
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 8, 3);
1534
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1535
 
1536
  /* Receive the transmitted packet. */
1537
  packetLength = createDoorbell(packet, 8, 0, 0xffff, 8, 3);
1538
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1539
  s = RIOSTACK_portGetSymbol(&stack);
1540
  TESTEXPR(s.type, c.type);
1541
  TESTEXPR(s.data, c.data);
1542
  for(i = 0; i < packetLength; i++)
1543
  {
1544
    s = RIOSTACK_portGetSymbol(&stack);
1545
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1546
    d.data = packet[i];
1547
    TESTEXPR(s.type, d.type);
1548
    TESTEXPR(s.data, d.data);
1549
  }
1550
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_END_OF_PACKET, 0);
1551
  s = RIOSTACK_portGetSymbol(&stack);
1552
  TESTEXPR(s.type, c.type);
1553
  TESTEXPR(s.data, c.data);
1554
 
1555
  /* Send packet-not-accepted indicating CRC error. */
1556
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_NOT_ACCEPTED, 0, 4, STYPE1_NOP, 0));
1557
 
1558
  /* Check that a link-request is received as the transmitter enters
1559
     output-error-stopped state. */
1560
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8,
1561
                          STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS);
1562
  s = RIOSTACK_portGetSymbol(&stack);
1563
  TESTEXPR(s.type, c.type);
1564
  TESTEXPR(s.data, c.data);
1565
 
1566
  /* Send link-response with expected ackId. */
1567
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_LINK_RESPONSE, 8, 16, STYPE1_NOP, 0));
1568
 
1569
  /* Send a status directly afterwards. */
1570
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 8, 1, STYPE1_NOP, 0));
1571
 
1572
  /* Receive retransmitted packet. */
1573
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1574
  s = RIOSTACK_portGetSymbol(&stack);
1575
  TESTEXPR(s.type, c.type);
1576
  TESTEXPR(s.data, c.data);
1577
  for(i = 0; i < packetLength; i++)
1578
  {
1579
    s = RIOSTACK_portGetSymbol(&stack);
1580
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1581
    d.data = packet[i];
1582
    TESTEXPR(s.type, d.type);
1583
    TESTEXPR(s.data, d.data);
1584
  }
1585
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_END_OF_PACKET, 0);
1586
  s = RIOSTACK_portGetSymbol(&stack);
1587
  TESTEXPR(s.type, c.type);
1588
  TESTEXPR(s.data, c.data);
1589
 
1590
  /* Send acknowledge for the retransmitted packet. */
1591
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 8, 1, STYPE1_NOP, 0));
1592
 
1593
  /******************************************************************************/
1594
  TESTEND;
1595
  /******************************************************************************/
1596
  PrintS("----------------------------------------------------------------------");
1597
  PrintS("Step 5:");
1598
  PrintS("Action: Send a packet-retry for an unexpected packet. Then send a");
1599
  PrintS("        link-response indicating the expected ackId and a normal packet.");
1600
  PrintS("Result: The transmitter should enter output-error-stopped state, send a");
1601
  PrintS("        link-request and then the normal packet.");
1602
  PrintS("----------------------------------------------------------------------");
1603
  /******************************************************************************/
1604
  TESTSTART("TG_riostack-TC4-Step5");
1605
  /******************************************************************************/
1606
 
1607
  /* Send packet-retry indicating that a packet should be retransmitted. */
1608
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_RETRY, 8, 1, STYPE1_NOP, 0));
1609
 
1610
  /* Check that a link-request is received as the transmitter enters
1611
     output-error-stopped state. */
1612
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8,
1613
                          STYPE1_LINK_REQUEST, LINK_REQUEST_INPUT_STATUS);
1614
  s = RIOSTACK_portGetSymbol(&stack);
1615
  TESTEXPR(s.type, c.type);
1616
  TESTEXPR(s.data, c.data);
1617
 
1618
  /* Send link-response with expected ackId. */
1619
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_LINK_RESPONSE, 9, 16, STYPE1_NOP, 0));
1620
 
1621
  /* Send a status directly afterwards. */
1622
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_STATUS, 9, 1, STYPE1_NOP, 0));
1623
 
1624
  /* Send an output packet. */
1625
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 9, 4);
1626
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1627
 
1628
  /* Receive retransmitted packet. */
1629
  packetLength = createDoorbell(packet, 9, 0, 0xffff, 9, 4);
1630
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1631
  s = RIOSTACK_portGetSymbol(&stack);
1632
  TESTEXPR(s.type, c.type);
1633
  TESTEXPR(s.data, c.data);
1634
  for(i = 0; i < packetLength; i++)
1635
  {
1636
    s = RIOSTACK_portGetSymbol(&stack);
1637
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1638
    d.data = packet[i];
1639
    TESTEXPR(s.type, d.type);
1640
    TESTEXPR(s.data, d.data);
1641
  }
1642
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_END_OF_PACKET, 0);
1643
  s = RIOSTACK_portGetSymbol(&stack);
1644
  TESTEXPR(s.type, c.type);
1645
  TESTEXPR(s.data, c.data);
1646
 
1647
  /* Send acknowledge for the retransmitted packet. */
1648
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 9, 1, STYPE1_NOP, 0));
1649
 
1650
  /******************************************************************************/
1651
  TESTEND;
1652
  /******************************************************************************/
1653
  PrintS("----------------------------------------------------------------------");
1654
  PrintS("Step 6:");
1655
  PrintS("Action: Fill outbound queue with packets, then check retransmission when ");
1656
  PrintS("        packet-retry is encountered. ");
1657
  PrintS("Result: Packets should be retried until packet-accepted is received.");
1658
  PrintS("----------------------------------------------------------------------");
1659
  /******************************************************************************/
1660
  TESTSTART("TG_riostack-TC4-Step6");
1661
  /******************************************************************************/
1662
 
1663
  TESTCOND(RIOSTACK_getOutboundQueueAvailable(&stack) > 0);
1664
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 20, 0xbabe);
1665
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1666
 
1667
  TESTCOND(RIOSTACK_getOutboundQueueAvailable(&stack) > 0);
1668
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 21, 0xbabe);
1669
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1670
 
1671
  TESTCOND(RIOSTACK_getOutboundQueueAvailable(&stack) > 0);
1672
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 22, 0xbabe);
1673
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1674
 
1675
  TESTCOND(RIOSTACK_getOutboundQueueAvailable(&stack) > 0);
1676
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 23, 0xbabe);
1677
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1678
 
1679
  TESTCOND(RIOSTACK_getOutboundQueueAvailable(&stack) > 0);
1680
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 24, 0xbabe);
1681
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1682
 
1683
  TESTCOND(RIOSTACK_getOutboundQueueAvailable(&stack) > 0);
1684
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 25, 0xbabe);
1685
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1686
 
1687
  TESTCOND(RIOSTACK_getOutboundQueueAvailable(&stack) > 0);
1688
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 26, 0xbabe);
1689
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1690
 
1691
  TESTCOND(RIOSTACK_getOutboundQueueAvailable(&stack) > 0);
1692
  RIOPACKET_setDoorbell(&rioPacket, 0, 0xffff, 27, 0xbabe);
1693
  RIOSTACK_setOutboundPacket(&stack, &rioPacket);
1694
 
1695
  TESTCOND(RIOSTACK_getOutboundQueueAvailable(&stack) == 0);
1696
 
1697
  /* Receive transmitted packet. */
1698
  packetLength = createDoorbell(packet, 10, 0, 0xffff, 20, 0xbabe);
1699
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1700
  s = RIOSTACK_portGetSymbol(&stack);
1701
  TESTEXPR(s.type, c.type);
1702
  TESTEXPR(s.data, c.data);
1703
  for(i = 0; i < packetLength; i++)
1704
  {
1705
    s = RIOSTACK_portGetSymbol(&stack);
1706
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1707
    d.data = packet[i];
1708
    TESTEXPR(s.type, d.type);
1709
    TESTEXPR(s.data, d.data);
1710
  }
1711
  packetLength = createDoorbell(packet, 11, 0, 0xffff, 21, 0xbabe);
1712
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1713
  s = RIOSTACK_portGetSymbol(&stack);
1714
  TESTEXPR(s.type, c.type);
1715
  TESTEXPR(s.data, c.data);
1716
  for(i = 0; i < packetLength; i++)
1717
  {
1718
    s = RIOSTACK_portGetSymbol(&stack);
1719
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1720
    d.data = packet[i];
1721
    TESTEXPR(s.type, d.type);
1722
    TESTEXPR(s.data, d.data);
1723
  }
1724
  packetLength = createDoorbell(packet, 12, 0, 0xffff, 22, 0xbabe);
1725
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1726
  s = RIOSTACK_portGetSymbol(&stack);
1727
  TESTEXPR(s.type, c.type);
1728
  TESTEXPR(s.data, c.data);
1729
  for(i = 0; i < packetLength; i++)
1730
  {
1731
    s = RIOSTACK_portGetSymbol(&stack);
1732
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1733
    d.data = packet[i];
1734
    TESTEXPR(s.type, d.type);
1735
    TESTEXPR(s.data, d.data);
1736
  }
1737
  packetLength = createDoorbell(packet, 13, 0, 0xffff, 23, 0xbabe);
1738
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1739
  s = RIOSTACK_portGetSymbol(&stack);
1740
  TESTEXPR(s.type, c.type);
1741
  TESTEXPR(s.data, c.data);
1742
  for(i = 0; i < packetLength; i++)
1743
  {
1744
    s = RIOSTACK_portGetSymbol(&stack);
1745
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1746
    d.data = packet[i];
1747
    TESTEXPR(s.type, d.type);
1748
    TESTEXPR(s.data, d.data);
1749
  }
1750
  packetLength = createDoorbell(packet, 14, 0, 0xffff, 24, 0xbabe);
1751
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1752
  s = RIOSTACK_portGetSymbol(&stack);
1753
  TESTEXPR(s.type, c.type);
1754
  TESTEXPR(s.data, c.data);
1755
  for(i = 0; i < packetLength; i++)
1756
  {
1757
    s = RIOSTACK_portGetSymbol(&stack);
1758
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1759
    d.data = packet[i];
1760
    TESTEXPR(s.type, d.type);
1761
    TESTEXPR(s.data, d.data);
1762
  }
1763
  packetLength = createDoorbell(packet, 15, 0, 0xffff, 25, 0xbabe);
1764
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1765
  s = RIOSTACK_portGetSymbol(&stack);
1766
  TESTEXPR(s.type, c.type);
1767
  TESTEXPR(s.data, c.data);
1768
  for(i = 0; i < packetLength; i++)
1769
  {
1770
    s = RIOSTACK_portGetSymbol(&stack);
1771
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1772
    d.data = packet[i];
1773
    TESTEXPR(s.type, d.type);
1774
    TESTEXPR(s.data, d.data);
1775
  }
1776
  packetLength = createDoorbell(packet, 16, 0, 0xffff, 26, 0xbabe);
1777
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1778
  s = RIOSTACK_portGetSymbol(&stack);
1779
  TESTEXPR(s.type, c.type);
1780
  TESTEXPR(s.data, c.data);
1781
  for(i = 0; i < packetLength; i++)
1782
  {
1783
    s = RIOSTACK_portGetSymbol(&stack);
1784
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1785
    d.data = packet[i];
1786
    TESTEXPR(s.type, d.type);
1787
    TESTEXPR(s.data, d.data);
1788
  }
1789
  packetLength = createDoorbell(packet, 17, 0, 0xffff, 27, 0xbabe);
1790
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1791
  s = RIOSTACK_portGetSymbol(&stack);
1792
  TESTEXPR(s.type, c.type);
1793
  TESTEXPR(s.data, c.data);
1794
  for(i = 0; i < packetLength; i++)
1795
  {
1796
    s = RIOSTACK_portGetSymbol(&stack);
1797
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1798
    d.data = packet[i];
1799
    TESTEXPR(s.type, d.type);
1800
    TESTEXPR(s.data, d.data);
1801
  }
1802
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_END_OF_PACKET, 0);
1803
  s = RIOSTACK_portGetSymbol(&stack);
1804
  TESTEXPR(s.type, c.type);
1805
  TESTEXPR(s.data, c.data);
1806
 
1807
  for(i = 0; i < 10; i++)
1808
  {
1809
    s = RIOSTACK_portGetSymbol(&stack);
1810
    TESTEXPR(s.type, RIOSTACK_SYMBOL_TYPE_IDLE);
1811
  }
1812
 
1813
  /* Request retransmission. */
1814
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_RETRY, 10, 1, STYPE1_NOP, 0));
1815
 
1816
  /* Acknowledge retransmission. */
1817
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_RESTART_FROM_RETRY, 0);
1818
  s = RIOSTACK_portGetSymbol(&stack);
1819
  TESTEXPR(s.type, c.type);
1820
  TESTEXPR(s.data, c.data);
1821
 
1822
  /* Check retransmitted packets. */
1823
  packetLength = createDoorbell(packet, 10, 0, 0xffff, 20, 0xbabe);
1824
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1825
  s = RIOSTACK_portGetSymbol(&stack);
1826
  TESTEXPR(s.type, c.type);
1827
  TESTEXPR(s.data, c.data);
1828
  for(i = 0; i < packetLength; i++)
1829
  {
1830
    s = RIOSTACK_portGetSymbol(&stack);
1831
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1832
    d.data = packet[i];
1833
    TESTEXPR(s.type, d.type);
1834
    TESTEXPR(s.data, d.data);
1835
  }
1836
  packetLength = createDoorbell(packet, 11, 0, 0xffff, 21, 0xbabe);
1837
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1838
  s = RIOSTACK_portGetSymbol(&stack);
1839
  TESTEXPR(s.type, c.type);
1840
  TESTEXPR(s.data, c.data);
1841
  for(i = 0; i < packetLength; i++)
1842
  {
1843
    s = RIOSTACK_portGetSymbol(&stack);
1844
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1845
    d.data = packet[i];
1846
    TESTEXPR(s.type, d.type);
1847
    TESTEXPR(s.data, d.data);
1848
  }
1849
  packetLength = createDoorbell(packet, 12, 0, 0xffff, 22, 0xbabe);
1850
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1851
  s = RIOSTACK_portGetSymbol(&stack);
1852
  TESTEXPR(s.type, c.type);
1853
  TESTEXPR(s.data, c.data);
1854
  for(i = 0; i < packetLength; i++)
1855
  {
1856
    s = RIOSTACK_portGetSymbol(&stack);
1857
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1858
    d.data = packet[i];
1859
    TESTEXPR(s.type, d.type);
1860
    TESTEXPR(s.data, d.data);
1861
  }
1862
 
1863
  /* Acknowledge. */
1864
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 10, 1, STYPE1_NOP, 0));
1865
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 11, 1, STYPE1_NOP, 0));
1866
 
1867
  packetLength = createDoorbell(packet, 13, 0, 0xffff, 23, 0xbabe);
1868
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1869
  s = RIOSTACK_portGetSymbol(&stack);
1870
  TESTEXPR(s.type, c.type);
1871
  TESTEXPR(s.data, c.data);
1872
  for(i = 0; i < packetLength; i++)
1873
  {
1874
    s = RIOSTACK_portGetSymbol(&stack);
1875
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1876
    d.data = packet[i];
1877
    TESTEXPR(s.type, d.type);
1878
    TESTEXPR(s.data, d.data);
1879
  }
1880
  packetLength = createDoorbell(packet, 14, 0, 0xffff, 24, 0xbabe);
1881
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1882
  s = RIOSTACK_portGetSymbol(&stack);
1883
  TESTEXPR(s.type, c.type);
1884
  TESTEXPR(s.data, c.data);
1885
  for(i = 0; i < packetLength; i++)
1886
  {
1887
    s = RIOSTACK_portGetSymbol(&stack);
1888
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1889
    d.data = packet[i];
1890
    TESTEXPR(s.type, d.type);
1891
    TESTEXPR(s.data, d.data);
1892
  }
1893
 
1894
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 12, 1, STYPE1_NOP, 0));
1895
 
1896
  packetLength = createDoorbell(packet, 15, 0, 0xffff, 25, 0xbabe);
1897
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1898
  s = RIOSTACK_portGetSymbol(&stack);
1899
  TESTEXPR(s.type, c.type);
1900
  TESTEXPR(s.data, c.data);
1901
  for(i = 0; i < packetLength; i++)
1902
  {
1903
    s = RIOSTACK_portGetSymbol(&stack);
1904
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1905
    d.data = packet[i];
1906
    TESTEXPR(s.type, d.type);
1907
    TESTEXPR(s.data, d.data);
1908
  }
1909
 
1910
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 13, 1, STYPE1_NOP, 0));
1911
 
1912
  packetLength = createDoorbell(packet, 16, 0, 0xffff, 26, 0xbabe);
1913
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1914
  s = RIOSTACK_portGetSymbol(&stack);
1915
  TESTEXPR(s.type, c.type);
1916
  TESTEXPR(s.data, c.data);
1917
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 14, 1, STYPE1_NOP, 0));
1918
  for(i = 0; i < packetLength; i++)
1919
  {
1920
    s = RIOSTACK_portGetSymbol(&stack);
1921
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1922
    d.data = packet[i];
1923
    TESTEXPR(s.type, d.type);
1924
    TESTEXPR(s.data, d.data);
1925
  }
1926
  packetLength = createDoorbell(packet, 17, 0, 0xffff, 27, 0xbabe);
1927
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_START_OF_PACKET, 0);
1928
  s = RIOSTACK_portGetSymbol(&stack);
1929
  TESTEXPR(s.type, c.type);
1930
  TESTEXPR(s.data, c.data);
1931
  for(i = 0; i < packetLength; i++)
1932
  {
1933
    s = RIOSTACK_portGetSymbol(&stack);
1934
    d.type = RIOSTACK_SYMBOL_TYPE_DATA;
1935
    d.data = packet[i];
1936
    TESTEXPR(s.type, d.type);
1937
    TESTEXPR(s.data, d.data);
1938
  }
1939
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 15, 1, STYPE1_NOP, 0));
1940
  c = CreateControlSymbol(STYPE0_STATUS, 10, 8, STYPE1_END_OF_PACKET, 0);
1941
  s = RIOSTACK_portGetSymbol(&stack);
1942
  TESTEXPR(s.type, c.type);
1943
  TESTEXPR(s.data, c.data);
1944
 
1945
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 16, 1, STYPE1_NOP, 0));
1946
  RIOSTACK_portAddSymbol(&stack, CreateControlSymbol(STYPE0_PACKET_ACCEPTED, 17, 1, STYPE1_NOP, 0));
1947
 
1948
  /******************************************************************************/
1949
  TESTEND;
1950
  /******************************************************************************/
1951
 
1952
  return 0;
1953
}
1954
 
1955
/*************************** end of file **************************************/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.