Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Dijkstra2 (input clk);
- reg [11:0] cost [0:36][0:36];
- reg [0:5] key;
- parameter inf = 999;
- integer min;
- parameter n=37;
- integer src;
- integer u;
- reg [5:0] i,j;
- // always @(posedge clk)
- function [0:49] getMin;
- input [0:6] key;
- input [0:6] i;
- input [0:5] dist;
- input [0:1] visited;
- begin
- for(i=0; i<n; i=i+1)
- begin
- if(!visited[i] && dist [i] < min)
- begin
- min = dist[i];
- key = i;
- end
- end
- end
- endfunction
- // end
- // end
- /*reg [0:49] par;
- reg [0:49] dist;
- reg [0:49] visited;
- reg [0:49] g;
- reg [0:9] k;
- reg [0:9] v;*/
- //always @(posedge clk)
- // begin
- function dijkstra ;
- input [0:49] par;
- input [0:49] dist;
- input [0:49] visited;
- input [0:49] g;
- input [0:9] k;
- input [0:9] v;
- begin
- dist[src] = 0;
- par[src] = 1 ;
- // assign u = getMin(dist,visited);
- for (k=0; k <=n-1; k=k+1)
- begin u = getMin(key, i, dist, visited);
- for (v=0; v < n; v = v+1)
- begin
- if(visited[v] != 1 && dist[u] + cost[u][v] < dist[v] && cost[u][v] != inf )
- begin
- par[v] = u;
- dist[v] = dist[u] + cost[u][v];
- end
- end
- end
- end
- endfunction
- initial
- begin
- for (i=0;i<37;i=i+1)
- begin
- for(j=0;j<37;j=j+1)
- begin
- if(i==j) cost[i][j] = 0;
- else cost[i][j] = inf;
- $display("%d ", cost[i][j]);
- end
- end
- end
- // end
- //end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement