Advertisement
Sidsh

Untitled

Feb 4th, 2022
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module algo();
  2. input clk_50;
  3. reg [100:0] cost [0:49][0:49];
  4. parameter INF = 999;
  5. reg [5:0] n;
  6.  
  7. function getMin;
  8. integer key 0 ;
  9. integer i 0;
  10. begin
  11.   for (i 0;i<n;i i+1)
  12.     if(!visited[i] && dist [i] < min)
  13.     begin
  14.       min <= dist[i];
  15.       key <= i;
  16.     end
  17. end
  18. endfunction
  19.  
  20. /*function display;
  21. integer k 0;
  22. integer par;
  23. */
  24.  
  25. function dijsktra;
  26. reg [49:0] par [0:49];
  27. reg [49:0] dist [0:49];
  28. reg visited [0:99] = 0;
  29. dist[src] = 0;
  30. par[src] = -1;
  31. integer k 0;
  32. integer v 0;
  33. begin
  34.   for (k 0; k < n- 1; k k+1)
  35.   assign u = getMin(dist,visited);
  36.     for (v 0; v < n; v v+1)
  37.         if(!visited[v] && (dist[u] + cost[u][v] < dist[v] && cost[u][v]! = 999 )
  38.         begin
  39.           par[v] = u;
  40.           dist[v] = dist[u] + cost[u][v];
  41.         end
  42.    
  43. end
  44. endfunction
  45.  
  46. endmodule
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement