source: branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/main.c @ 934

Last change on this file since 934 was 934, checked in by cfuguet, 10 years ago

reconf: add unitary test for the segment migration mechanism in the
dspin router.

File size: 2.7 KB
Line 
1#include "stdio.h"
2#include "cpu.h"
3#include "hard_config.h"
4#include "io.h"
5#include "simhelper.h"
6#include "cpu_registers.h"
7#include "xcu.h"
8#include "soclib/dspin_router_config.h"
9#include "assert.h"
10
11void exception_handler()
12{
13    printf("exception_handler(): failure / pid %d\n", cpu_procid());
14    simh_stop_simulation();
15}
16
17void main(void)
18{
19    printf("main(): pid %d\n", cpu_procid());
20
21    /* set the watchdog timer threshold to detect an error during the
22     * reconfiguration of the NoC */
23    cpu_set_wdt_max(5000);
24
25    /* configure the routers around the blackhole (1, 1) to define a cycle-free
26     * contour */
27    printf("router(0, 2): configuring as NW\n");
28    assert(xcu_get_config(0, 2, 0) == BH_NONE);
29    xcu_set_config(0, 2, 0, (REQ_SOUTH << 4) | BH_NW);     /* configure NW */
30
31    printf("router(0, 1): configuring as W\n");
32    assert(xcu_get_config(0, 1, 0) == BH_NONE);
33    xcu_set_config(0, 1, 0, (REQ_LOCAL << 4) | BH_W);      /* configure W */
34
35    printf("router(0, 0): configuring as SW\n");
36    assert(xcu_get_config(0, 0, 0) == BH_NONE);
37    xcu_set_config(0, 0, 0, (REQ_NORTH << 4) | BH_SW);     /* configure SW */
38
39    printf("router(1, 2): configuring as N\n");
40    assert(xcu_get_config(1, 2, 0) == BH_NONE);
41    xcu_set_config(1, 2, 0, (REQ_WEST << 4) | BH_N);       /* configure N */
42
43    printf("router(2, 2): configuring as NE\n");
44    assert(xcu_get_config(2, 2, 0) == BH_NONE);
45    xcu_set_config(2, 2, 0, (REQ_WEST << 4) | BH_NE);      /* configure NE */
46
47    printf("router(2, 1): configuring as E\n");
48    assert(xcu_get_config(2, 1, 0) == BH_NONE);
49    xcu_set_config(2, 1, 0, (REQ_SOUTH << 4) | BH_E);      /* configure E */
50
51    printf("router(2, 0): configuring as SE\n");
52    assert(xcu_get_config(2, 0, 0) == BH_NONE);
53    xcu_set_config(2, 0, 0, (REQ_WEST << 4) | BH_SE);      /* configure SE */
54
55    printf("router(1, 0): configuring as S\n");
56    assert(xcu_get_config(1, 0, 0) == BH_NONE);
57    xcu_set_config(1, 0, 0, (REQ_WEST << 4) | BH_S);       /* configure S */
58
59    assert((xcu_get_config(0, 2, 0) & 0xF) == BH_NW);
60    assert((xcu_get_config(0, 1, 0) & 0xF) == BH_W);
61    assert((xcu_get_config(0, 0, 0) & 0xF) == BH_SW);
62    assert((xcu_get_config(1, 2, 0) & 0xF) == BH_N);
63    assert((xcu_get_config(2, 2, 0) & 0xF) == BH_NE);
64    assert((xcu_get_config(2, 1, 0) & 0xF) == BH_E);
65    assert((xcu_get_config(2, 0, 0) & 0xF) == BH_SE);
66    assert((xcu_get_config(1, 0, 0) & 0xF) == BH_S);
67
68    /* Test the recovered segment that has been migrated to the EAST cluster */
69    ioread32(CLUSTER_BASE(1, 1) | SEG_RAM_BASE);
70
71    printf("main(): success\n");
72    simh_stop_simulation();
73}
74
75/*
76 * vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
77 */
Note: See TracBrowser for help on using the repository browser.