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 | /* |
---|
22 | * set the watchdog timer threshold to detect an error during |
---|
23 | * the reconfiguration of the NoC |
---|
24 | */ |
---|
25 | cpu_set_wdt_max(1000); |
---|
26 | |
---|
27 | /* |
---|
28 | * configure the routers around the blackhole (1, 1) to define a cycle-free |
---|
29 | * contour |
---|
30 | */ |
---|
31 | printf("router(0, 2): configuring as NW\n"); |
---|
32 | assert(xcu_get_register(0, 2, XICU_CFG_REG, 0) == BH_NONE); |
---|
33 | xcu_set_register(0, 2, XICU_CFG_REG, 0, BH_NW); /* configure NW */ |
---|
34 | |
---|
35 | printf("router(0, 1): configuring as W\n"); |
---|
36 | assert(xcu_get_register(0, 1, XICU_CFG_REG, 0) == BH_NONE); |
---|
37 | xcu_set_register(0, 1, XICU_CFG_REG, 0, BH_W); /* configure W */ |
---|
38 | |
---|
39 | printf("router(0, 0): configuring as SW\n"); |
---|
40 | assert(xcu_get_register(0, 0, XICU_CFG_REG, 0) == BH_NONE); |
---|
41 | xcu_set_register(0, 0, XICU_CFG_REG, 0, BH_SW); /* configure SW */ |
---|
42 | |
---|
43 | printf("router(1, 2): configuring as N\n"); |
---|
44 | assert(xcu_get_register(1, 2, XICU_CFG_REG, 0) == BH_NONE); |
---|
45 | xcu_set_register(1, 2, XICU_CFG_REG, 0, BH_N); /* configure N */ |
---|
46 | |
---|
47 | printf("router(2, 2): configuring as NE\n"); |
---|
48 | assert(xcu_get_register(2, 2, XICU_CFG_REG, 0) == BH_NONE); |
---|
49 | xcu_set_register(2, 2, XICU_CFG_REG, 0, BH_NE); /* configure NE */ |
---|
50 | |
---|
51 | printf("router(2, 1): configuring as E\n"); |
---|
52 | assert(xcu_get_register(2, 1, XICU_CFG_REG, 0) == BH_NONE); |
---|
53 | xcu_set_register(2, 1, XICU_CFG_REG, 0, BH_E); /* configure E */ |
---|
54 | |
---|
55 | printf("router(2, 0): configuring as SE\n"); |
---|
56 | assert(xcu_get_register(2, 0, XICU_CFG_REG, 0) == BH_NONE); |
---|
57 | xcu_set_register(2, 0, XICU_CFG_REG, 0, BH_SE); /* configure SE */ |
---|
58 | |
---|
59 | printf("router(1, 0): configuring as S\n"); |
---|
60 | assert(xcu_get_register(1, 0, XICU_CFG_REG, 0) == BH_NONE); |
---|
61 | xcu_set_register(1, 0, XICU_CFG_REG, 0, BH_S); /* configure S */ |
---|
62 | |
---|
63 | assert(xcu_get_register(0, 2, XICU_CFG_REG, 0) == BH_NW); |
---|
64 | assert(xcu_get_register(0, 1, XICU_CFG_REG, 0) == BH_W); |
---|
65 | assert(xcu_get_register(0, 0, XICU_CFG_REG, 0) == BH_SW); |
---|
66 | assert(xcu_get_register(1, 2, XICU_CFG_REG, 0) == BH_N); |
---|
67 | assert(xcu_get_register(2, 2, XICU_CFG_REG, 0) == BH_NE); |
---|
68 | assert(xcu_get_register(2, 1, XICU_CFG_REG, 0) == BH_E); |
---|
69 | assert(xcu_get_register(2, 0, XICU_CFG_REG, 0) == BH_SE); |
---|
70 | assert(xcu_get_register(1, 0, XICU_CFG_REG, 0) == BH_S); |
---|
71 | |
---|
72 | #if 0 |
---|
73 | /* |
---|
74 | * this should cause a livelock (sending a packet to the blackhole once the |
---|
75 | * cycle-free contour has been defined) |
---|
76 | * |
---|
77 | * why?: the router (0, 0) and the router (0, 1) keep sending the packet |
---|
78 | * between them. |
---|
79 | */ |
---|
80 | assert(xcu_get_register(1, 1, XICU_CFG_REG, 0) == BH_NONE); |
---|
81 | #endif |
---|
82 | |
---|
83 | printf("main(): success\n"); |
---|
84 | |
---|
85 | simh_stop_simulation(); |
---|
86 | } |
---|
87 | |
---|
88 | /* |
---|
89 | * vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab |
---|
90 | */ |
---|