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