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 | |
---|
11 | void exception_handler() |
---|
12 | { |
---|
13 | printf("exception_handler(): failure / pid %d\n", cpu_procid()); |
---|
14 | simh_stop_simulation(); |
---|
15 | } |
---|
16 | |
---|
17 | void 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 | const int RECOVERY = 1; |
---|
28 | uint32_t val; |
---|
29 | |
---|
30 | printf("router(0, 2): configuring as NW\n"); |
---|
31 | val = (REQ_SOUTH << 5) | (RECOVERY << 4) | NW_OF_X; |
---|
32 | xcu_set_register(0, 2, XICU_CFG_REG, 0, val); /* configure NW */ |
---|
33 | |
---|
34 | printf("router(0, 1): configuring as W\n"); |
---|
35 | val = (REQ_LOCAL << 5) | (RECOVERY << 4) | W_OF_X; |
---|
36 | xcu_set_register(0, 1, XICU_CFG_REG, 0, val); /* configure W */ |
---|
37 | |
---|
38 | printf("router(0, 0): configuring as SW\n"); |
---|
39 | val = (REQ_NORTH << 5) | (RECOVERY << 4) | SW_OF_X; |
---|
40 | xcu_set_register(0, 0, XICU_CFG_REG, 0, val); /* configure SW */ |
---|
41 | |
---|
42 | printf("router(1, 2): configuring as N\n"); |
---|
43 | val = (REQ_WEST << 5) | (RECOVERY << 4) | N_OF_X; |
---|
44 | xcu_set_register(1, 2, XICU_CFG_REG, 0, val); /* configure N */ |
---|
45 | |
---|
46 | printf("router(2, 2): configuring as NE\n"); |
---|
47 | val = (REQ_WEST << 5) | (RECOVERY << 4) | NE_OF_X; |
---|
48 | xcu_set_register(2, 2, XICU_CFG_REG, 0, val); /* configure NE */ |
---|
49 | |
---|
50 | printf("router(2, 1): configuring as E\n"); |
---|
51 | val = (REQ_SOUTH << 5) | (RECOVERY << 4) | E_OF_X; |
---|
52 | xcu_set_register(2, 1, XICU_CFG_REG, 0, val); /* configure E */ |
---|
53 | |
---|
54 | printf("router(2, 0): configuring as SE\n"); |
---|
55 | val = (REQ_WEST << 5) | (RECOVERY << 4) | SE_OF_X; |
---|
56 | xcu_set_register(2, 0, XICU_CFG_REG, 0, val); /* configure SE */ |
---|
57 | |
---|
58 | printf("router(1, 0): configuring as S\n"); |
---|
59 | val = (REQ_WEST << 5) | (RECOVERY << 4) | S_OF_X; |
---|
60 | xcu_set_register(1, 0, XICU_CFG_REG, 0, val); /* configure S */ |
---|
61 | |
---|
62 | assert((xcu_get_register(0, 2, XICU_CFG_REG, 0) & 0xF) == NW_OF_X); |
---|
63 | assert((xcu_get_register(0, 1, XICU_CFG_REG, 0) & 0xF) == W_OF_X); |
---|
64 | assert((xcu_get_register(0, 0, XICU_CFG_REG, 0) & 0xF) == SW_OF_X); |
---|
65 | assert((xcu_get_register(1, 2, XICU_CFG_REG, 0) & 0xF) == N_OF_X); |
---|
66 | assert((xcu_get_register(2, 2, XICU_CFG_REG, 0) & 0xF) == NE_OF_X); |
---|
67 | assert((xcu_get_register(2, 1, XICU_CFG_REG, 0) & 0xF) == E_OF_X); |
---|
68 | assert((xcu_get_register(2, 0, XICU_CFG_REG, 0) & 0xF) == SE_OF_X); |
---|
69 | assert((xcu_get_register(1, 0, XICU_CFG_REG, 0) & 0xF) == S_OF_X); |
---|
70 | |
---|
71 | /* Test the recovered segment that has been migrated to the EAST cluster */ |
---|
72 | ioread32(CLUSTER_BASE(1, 1) | SEG_RAM_BASE); |
---|
73 | |
---|
74 | printf("main(): success\n"); |
---|
75 | simh_stop_simulation(); |
---|
76 | } |
---|
77 | |
---|
78 | /* |
---|
79 | * vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab |
---|
80 | */ |
---|