[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 */ |
---|
[1016] | 27 | const int RECOVERY = 1; |
---|
[942] | 28 | uint32_t val; |
---|
| 29 | |
---|
[934] | 30 | printf("router(0, 2): configuring as NW\n"); |
---|
[1016] | 31 | val = (REQ_SOUTH << 5) | (RECOVERY << 4) | NW_OF_X; |
---|
[942] | 32 | xcu_set_register(0, 2, XICU_CFG_REG, 0, val); /* configure NW */ |
---|
[934] | 33 | |
---|
| 34 | printf("router(0, 1): configuring as W\n"); |
---|
[1016] | 35 | val = (REQ_LOCAL << 5) | (RECOVERY << 4) | W_OF_X; |
---|
[942] | 36 | xcu_set_register(0, 1, XICU_CFG_REG, 0, val); /* configure W */ |
---|
[934] | 37 | |
---|
| 38 | printf("router(0, 0): configuring as SW\n"); |
---|
[1016] | 39 | val = (REQ_NORTH << 5) | (RECOVERY << 4) | SW_OF_X; |
---|
[942] | 40 | xcu_set_register(0, 0, XICU_CFG_REG, 0, val); /* configure SW */ |
---|
[934] | 41 | |
---|
| 42 | printf("router(1, 2): configuring as N\n"); |
---|
[1016] | 43 | val = (REQ_WEST << 5) | (RECOVERY << 4) | N_OF_X; |
---|
[942] | 44 | xcu_set_register(1, 2, XICU_CFG_REG, 0, val); /* configure N */ |
---|
[934] | 45 | |
---|
| 46 | printf("router(2, 2): configuring as NE\n"); |
---|
[1016] | 47 | val = (REQ_WEST << 5) | (RECOVERY << 4) | NE_OF_X; |
---|
[942] | 48 | xcu_set_register(2, 2, XICU_CFG_REG, 0, val); /* configure NE */ |
---|
[934] | 49 | |
---|
| 50 | printf("router(2, 1): configuring as E\n"); |
---|
[1016] | 51 | val = (REQ_SOUTH << 5) | (RECOVERY << 4) | E_OF_X; |
---|
[942] | 52 | xcu_set_register(2, 1, XICU_CFG_REG, 0, val); /* configure E */ |
---|
[934] | 53 | |
---|
| 54 | printf("router(2, 0): configuring as SE\n"); |
---|
[1016] | 55 | val = (REQ_WEST << 5) | (RECOVERY << 4) | SE_OF_X; |
---|
[942] | 56 | xcu_set_register(2, 0, XICU_CFG_REG, 0, val); /* configure SE */ |
---|
[934] | 57 | |
---|
| 58 | printf("router(1, 0): configuring as S\n"); |
---|
[1016] | 59 | val = (REQ_WEST << 5) | (RECOVERY << 4) | S_OF_X; |
---|
[942] | 60 | xcu_set_register(1, 0, XICU_CFG_REG, 0, val); /* configure S */ |
---|
[934] | 61 | |
---|
[1016] | 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); |
---|
[934] | 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 | */ |
---|