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

Last change on this file since 942 was 942, checked in by cfuguet, 9 years ago

reconf: improve unitary tests for dspin_router

File size: 3.2 KB
RevLine 
[934]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 */
[942]27    uint32_t val;
28
[934]29    printf("router(0, 2): configuring as NW\n");
[942]30    assert(xcu_get_register(0, 2, XICU_CFG_REG, 0) == BH_NONE);
31    val = (REQ_SOUTH << 4) | BH_NW;
32    xcu_set_register(0, 2, XICU_CFG_REG, 0, val);     /* configure NW */
[934]33
34    printf("router(0, 1): configuring as W\n");
[942]35    assert(xcu_get_register(0, 1, XICU_CFG_REG, 0) == BH_NONE);
36    val = (REQ_LOCAL << 4) | BH_W;
37    xcu_set_register(0, 1, XICU_CFG_REG, 0, val);     /* configure W */
[934]38
39    printf("router(0, 0): configuring as SW\n");
[942]40    assert(xcu_get_register(0, 0, XICU_CFG_REG, 0) == BH_NONE);
41    val = (REQ_NORTH << 4) | BH_SW;
42    xcu_set_register(0, 0, XICU_CFG_REG, 0, val);     /* configure SW */
[934]43
44    printf("router(1, 2): configuring as N\n");
[942]45    assert(xcu_get_register(1, 2, XICU_CFG_REG, 0) == BH_NONE);
46    val = (REQ_WEST << 4) | BH_N;
47    xcu_set_register(1, 2, XICU_CFG_REG, 0, val);     /* configure N */
[934]48
49    printf("router(2, 2): configuring as NE\n");
[942]50    assert(xcu_get_register(2, 2, XICU_CFG_REG, 0) == BH_NONE);
51    val = (REQ_WEST << 4) | BH_NE;
52    xcu_set_register(2, 2, XICU_CFG_REG, 0, val);     /* configure NE */
[934]53
54    printf("router(2, 1): configuring as E\n");
[942]55    assert(xcu_get_register(2, 1, XICU_CFG_REG, 0) == BH_NONE);
56    val = (REQ_SOUTH << 4) | BH_E;
57    xcu_set_register(2, 1, XICU_CFG_REG, 0, val);     /* configure E */
[934]58
59    printf("router(2, 0): configuring as SE\n");
[942]60    assert(xcu_get_register(2, 0, XICU_CFG_REG, 0) == BH_NONE);
61    val = (REQ_WEST << 4) | BH_SE;
62    xcu_set_register(2, 0, XICU_CFG_REG, 0, val);     /* configure SE */
[934]63
64    printf("router(1, 0): configuring as S\n");
[942]65    assert(xcu_get_register(1, 0, XICU_CFG_REG, 0) == BH_NONE);
66    val = (REQ_WEST << 4) | BH_S;
67    xcu_set_register(1, 0, XICU_CFG_REG, 0, val);     /* configure S */
[934]68
[942]69    assert((xcu_get_register(0, 2, XICU_CFG_REG, 0) & 0xF) == BH_NW);
70    assert((xcu_get_register(0, 1, XICU_CFG_REG, 0) & 0xF) == BH_W);
71    assert((xcu_get_register(0, 0, XICU_CFG_REG, 0) & 0xF) == BH_SW);
72    assert((xcu_get_register(1, 2, XICU_CFG_REG, 0) & 0xF) == BH_N);
73    assert((xcu_get_register(2, 2, XICU_CFG_REG, 0) & 0xF) == BH_NE);
74    assert((xcu_get_register(2, 1, XICU_CFG_REG, 0) & 0xF) == BH_E);
75    assert((xcu_get_register(2, 0, XICU_CFG_REG, 0) & 0xF) == BH_SE);
76    assert((xcu_get_register(1, 0, XICU_CFG_REG, 0) & 0xF) == BH_S);
[934]77
78    /* Test the recovered segment that has been migrated to the EAST cluster */
79    ioread32(CLUSTER_BASE(1, 1) | SEG_RAM_BASE);
80
81    printf("main(): success\n");
82    simh_stop_simulation();
83}
84
85/*
86 * vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
87 */
Note: See TracBrowser for help on using the repository browser.