VPR-6.0
|
Go to the source code of this file.
Defines | |
#define | SETUPGRID_H |
Functions | |
void | alloc_and_load_grid (INOUTP int *num_instances_type) |
void | freeGrid () |
#define SETUPGRID_H |
Definition at line 2 of file SetupGrid.h.
void alloc_and_load_grid | ( | INOUTP int * | num_instances_type | ) |
[0..num_types-1]
Create and fill FPGA architecture grid.
Definition at line 24 of file SetupGrid.c.
{ int i, j; t_type_ptr type; #ifdef SHOW_ARCH FILE *dump; #endif /* To remove this limitation, change ylow etc. in t_rr_node to * * * be ints instead. Used shorts to save memory. */ if((nx > 32766) || (ny > 32766)) { printf("Error: nx and ny must be less than 32767, since the \n"); printf("router uses shorts (16-bit) to store coordinates.\n"); printf("nx: %d. ny: %d.\n", nx, ny); exit(1); } assert(nx >= 1 && ny >= 1); grid = (struct s_grid_tile **)alloc_matrix(0, (nx + 1), 0, (ny + 1), sizeof(struct s_grid_tile)); /* Clear the full grid to have no type (NULL), no capacity, etc */ for(i = 0; i <= (nx + 1); ++i) { for(j = 0; j <= (ny + 1); ++j) { memset(&grid[i][j], 0, (sizeof(struct s_grid_tile))); } } for(i = 0; i < num_types; i++) { num_instances_type[i] = 0; } /* Nothing goes in the corners. */ grid[0][0].type = grid[nx + 1][0].type = EMPTY_TYPE; grid[0][ny + 1].type = grid[nx + 1][ny + 1].type = EMPTY_TYPE; num_instances_type[EMPTY_TYPE->index] = 4; for(i = 1; i <= nx; i++) { grid[i][0].blocks = (int *)my_malloc(sizeof(int) * IO_TYPE->capacity); grid[i][0].type = IO_TYPE; grid[i][ny + 1].blocks = (int *)my_malloc(sizeof(int) * IO_TYPE->capacity); grid[i][ny + 1].type = IO_TYPE; for(j = 0; j < IO_TYPE->capacity; j++) { grid[i][0].blocks[j] = EMPTY; grid[i][ny + 1].blocks[j] = EMPTY; } } for(i = 1; i <= ny; i++) { grid[0][i].blocks = (int *)my_malloc(sizeof(int) * IO_TYPE->capacity); grid[0][i].type = IO_TYPE; grid[nx + 1][i].blocks = (int *)my_malloc(sizeof(int) * IO_TYPE->capacity); grid[nx + 1][i].type = IO_TYPE; for(j = 0; j < IO_TYPE->capacity; j++) { grid[0][i].blocks[j] = EMPTY; grid[nx + 1][i].blocks[j] = EMPTY; } } num_instances_type[IO_TYPE->index] = 2 * IO_TYPE->capacity * (nx + ny); for(i = 1; i <= nx; i++) { /* Interior (LUT) cells */ type = find_type_col(i); for(j = 1; j <= ny; j++) { grid[i][j].type = type; grid[i][j].offset = (j - 1) % type->height; if(j + grid[i][j].type->height - 1 - grid[i][j].offset > ny) { grid[i][j].type = EMPTY_TYPE; grid[i][j].offset = 0; } if(type->capacity > 1) { printf(ERRTAG "In FillArch() expected core blocks to have capacity <= 1 but " "(%d, %d) has type '%s' and capacity %d\n", i, j, grid[i][j].type->name, grid[i][j].type->capacity); exit(1); } grid[i][j].blocks = (int *)my_malloc(sizeof(int)); grid[i][j].blocks[0] = EMPTY; if(grid[i][j].offset == 0) { num_instances_type[grid[i][j].type->index]++; } } } CheckGrid(); #ifdef SHOW_ARCH /* DEBUG code */ dump = my_fopen("grid_type_dump.txt", "w", 0); for(j = (ny + 1); j >= 0; --j) { for(i = 0; i <= (nx + 1); ++i) { fprintf(dump, "%c", grid[i][j].type->name[1]); } fprintf(dump, "\n"); } fclose(dump); #endif }
void freeGrid | ( | ) |
Definition at line 156 of file SetupGrid.c.
{ int i, j; for(i = 0; i <= (nx + 1); ++i) { for(j = 0; j <= (ny + 1); ++j) { free(grid[i][j].blocks); } } free_matrix(grid, 0, nx + 1, 0, sizeof(struct s_grid_tile)); }