diff --git a/hls_2018/README.md b/hls_2018/README.md index f11e0eff8440e2eb403991c267609980da74e7e0..063636aa3acc070e23c3ec01f073734be1827987 100644 --- a/hls_2018/README.md +++ b/hls_2018/README.md @@ -10,6 +10,7 @@ PYNQ-router for Vivado-HLS (2018 ver.) |02|TBD|*Line-number-free* router for "PYNQ-Z1". Priority queue is implemented with circular array(parallel)| |03|TBD|*Line-number-free* router for "PYNQ-Z1". Priority queue is implemented with heap(size:$`2^{15}`$)| |04|TBD|*Line-number-free* router for "AVNET-Ultra96". Priority queue is implemented with heap(size:$`2^{16}`$)| +|05|TBD|*Low-memory-usage* router. No BRAMs are used for storing route information of each line.| ## Memo diff --git a/hls_2018/router_05/solver.c b/hls_2018/router_05/solver.c new file mode 100644 index 0000000000000000000000000000000000000000..ba77daa34bb0df7b5f97419b431463dbfb1fd3ff --- /dev/null +++ b/hls_2018/router_05/solver.c @@ -0,0 +1,317 @@ +/* solver.c */ +/* Last Change: 2018/08/26 (Sun) 23:31:34. */ + +#define MAX_ATTEMPS 100000 + +#include +#include +#include +/* #include */ +/* #include */ +#include + +int board[8][72][72]={}; +int avail[8][72][72]={}; //start=3,path=2,avail=1,nonavail=0,goal=-1 +int connected[8*72*72/2+1]={}; //connected[0]=(number of connected lines) +int depth,height,width; +int goalx,goaly,goalz; +int lines; +//z,y,x + +void read(void){ //read problem + int x,y,z,i; + char c,str[8]; + scanf(" %s",str); //SIZE + scanf(" %d",&width); + if(width>72||width<=0) + printf("Error: width\n"); + scanf(" %c",&c); //X + scanf(" %d",&height); + if(height>72||height<=0) + printf("Error: height\n"); + scanf(" %c",&c); //X + scanf(" %d",&depth); + if(depth>8||depth<=0) + printf("Error: depth\n"); + scanf(" %s",str); //LINE_NUM + scanf(" %d",&lines); + if(lines<=0) + printf("Error: lines\n"); + for(i=1;i<=lines;i++){ + scanf(" %s",str); //LINE#X + scanf(" %c",&c); //( + scanf(" %d",&x); + if(x>=72||x<0) + printf("Error: x\n"); + scanf(" %c",&c); //, + scanf(" %d",&y); + if(y>=72||y<0) + printf("Error: y\n"); + scanf(" %c",&c); //, + scanf(" %d",&z); + if(z>=72||z<0) + printf("Error: z\n"); + scanf(" %c",&c); //) + board[z-1][y][x]=-i; + scanf("%c",&c); //) + /* scanf(" %[ -]",&c); //space or - */ + scanf(" %c",&c); //( + scanf(" %d",&x); + if(x>=72||x<0) + printf("Error: x\n"); + scanf(" %c",&c); //, + scanf(" %d",&y); + if(y>=72||y<0) + printf("Error: y\n"); + scanf(" %c",&c); //, + scanf(" %d",&z); + if(z>=72||z<0) + printf("Error: z\n"); + scanf(" %c",&c); //) + board[z-1][y][x]=-i; + } + return; +} + +int randline(void){ //return random line number + return rand()%lines+1; +} + +void shuffle(int array[],int start,int end){ + int i,j,t; + if(end==start) + return; + for(i=start;i0&&avail[nowz][nowy][nowx-1]>=2) + isbranch++; + if(nowy>0&&avail[nowz][nowy-1][nowx]>=2) + isbranch++; + if(nowz>0&&avail[nowz-1][nowy][nowx]>=2) + isbranch++; + if(nowx=2) + isbranch++; + if(nowy=2) + isbranch++; + if(nowz=2) + isbranch++; + if(isbranch>0){ + avail[nowz][nowy][nowx]=1; + return 0; + } + if(avail[nowz][nowy][nowx]==1) + avail[nowz][nowy][nowx]=2; + int i,src=0; + int searchorder[6]; //x+-,y+-,z+- + /* for(i=0;i<6;i++) */ + /* searchorder[i]=-1; */ + if(nowx>goalx){ + searchorder[src]=0; + src++; + }else + searchorder[5+src]=0; + if(nowy>goaly){ + searchorder[src]=1; + src++; + }else + searchorder[4+src]=1; + if(nowz>goalz){ + searchorder[src]=2; + src++; + }else + searchorder[3+src]=2; + if(nowx0&&available(nowx-1,nowy,nowz,0)) + return 1; + break; + case 1: + if(nowy>0&&available(nowx,nowy-1,nowz,0)) + return 1; + break; + case 2: + if(nowz>0&&available(nowx,nowy,nowz-1,0)) + return 1; + break; + case 3: + if(nowx