Advertisement
Sidsh

Electromagnet enabled LSA

Mar 1st, 2022
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VeriLog 15.53 KB | None | 0 0
  1. module LSA(
  2.     output [7:0]m1,  //motor1                                            PIN_D3
  3.      output [7:0]m1b,
  4.     output [7:0]m2,  //motor2                                            PIN_C3
  5.      output [7:0]m2b,
  6.     input s1,  //12-bit output of ch. 5 (parallel)
  7.     input s2,  //12-bit output of ch. 6 (parallel)
  8.     input s3,  //12-bit output of ch. 7 (parallel)
  9.     input clk_1,    //50 MHz clock
  10.     input reset,
  11.      input [2:0]Clr,
  12.      output Led1,    //Led used to indicate position of bot i.e. node or line
  13.      output Led2,
  14.      output Led3,
  15.      output HL1,        // to control uart
  16.      output [2:0] id,
  17.      output EM,
  18.      output Clr_en
  19.     );
  20.  
  21. reg signed[7:0]error = 0;
  22. reg signed[7:0]difference = 0;
  23. reg signed[7:0]correction = 0;
  24. reg signed[7:0]cumulative_error = 0;
  25. reg signed[7:0]preverror = 0;
  26. reg [4:0]nodecount = -5'd1;     //No. of nodes bot has traversed, initially set to -1
  27. reg flag = 0;  
  28.  
  29. reg led1=0;
  30. reg led2=0;
  31. reg led3=0;
  32.  
  33. reg [7:0]odc =58;     //optimum duty cycle
  34. reg [7:0]mo1 = 50;    // pwm to motor1, initially set to 50
  35. reg [7:0]mo1r= 0;
  36. reg [7:0]mo2 = 50;    // pwm to motor2, initially set to 50
  37. reg [7:0]mo2r= 0;
  38. reg [7:0]ml1 = 50;    // pwm to motor1 when it is on line
  39. reg [7:0]ml1r=0;
  40. reg [7:0]ml2 = 50;    // pwm to motor2 when it is on line
  41. reg [7:0]ml2r=0;
  42. reg [7:0]mn1 = 50;    // pwm to motor1 when it is on node
  43. reg [7:0]mn1r= 0;
  44. reg [7:0]mn2 = 50;    // pwm to motor2 when it is on node
  45. reg [7:0]mn2r= 0;
  46.  
  47. reg [2:0] id1 =0;        //to control uart
  48. reg hl=0;
  49. reg n=0;
  50.  
  51. reg en=0;
  52. reg [1:0]state = 0; //0: arena, 1: pick, 2:place
  53. reg [1:0]path_no = 0;  //no. of path
  54. reg [1:0]path[3:0][11:0];
  55. reg [4:0]path_len[3:0]; //length of each path
  56. reg [1:0]clrPath[8:0][9:0];   //enter 9 S paths in sequence RGB
  57. reg [4:0]clrPathlen[8:0]; //enter 9 S paths length in sequence RGB
  58. reg [1:0]DepPath[8:0][12:0];
  59. reg [4:0]DepPath_len[8:0];
  60.  
  61. reg clr_en = 1;  //disable clr detection
  62. reg clr_en1 = 1;  //disable clr detection
  63. reg [1:0]clrsN=0;
  64. reg [2:0]clrs[0:2];
  65. reg [4:0]dest[2:0];
  66. reg [1:0]rcount=0;     //count no. of red color patches
  67. reg [1:0]gcount=0;     //count no. of green color patches
  68. reg [1:0]bcount=0;     //count no. of blue color patches
  69.  
  70. reg flag2=0;
  71.  
  72. reg done = 0;
  73. reg [20:0]delay=0;
  74.     //Arena
  75.  
  76. function automatic pwm;
  77.     input [1:0]n;
  78.     begin
  79.         case(n)
  80.         0:begin
  81.             mn1 = 56;
  82.             mn1r=0;
  83.             mn2 = 56;
  84.             mn2r=0;
  85.           end
  86.         1:begin
  87.             mn1 = 0;
  88.             mn1r=40;
  89.             mn2 = 54;
  90.             mn2r=0;
  91.           end
  92.         2:begin
  93.             mn1 = 54;
  94.             mn1r=0;
  95.             mn2 = 0;
  96.             mn2r=38;
  97.           end
  98.         3:begin
  99.             mn1=0;
  100.             mn1r=odc;
  101.             mn2=odc;
  102.             mn2r=0;
  103.           end
  104.         endcase
  105.         pwm = 1;
  106.      end
  107.     endfunction
  108.  
  109. always @(posedge clk_1) begin
  110. if(clr_en1==0)
  111. begin
  112.     delay<=delay+1;
  113.     if(delay==500000)
  114.     begin
  115.         clr_en<=0;
  116.     end
  117. end else
  118. begin
  119.     delay<=0;
  120. end
  121. if(done == 0)
  122. begin
  123.     state <=0;
  124.     path[0][0] <= 0;
  125.    path[0][1] <= 0;
  126.    path[0][2] <= 0;
  127.    path[0][3] <= 0;
  128.    path[0][4] <= 2;
  129.    path[0][5] <= 0;
  130.    path[0][6] <= 1;
  131.    path[0][7] <= 0;
  132.    path[0][8] <= 1;
  133.    path[0][9] <= 0;
  134.    path[0][10] <= 0;
  135.    
  136.    path[1][0] <= 2;
  137.    path[1][1] <= 0;
  138.    path[1][2] <= 0;
  139.    path[1][3] <= 0;
  140.    path[1][4] <= 1;
  141.    path[1][5] <= 0;
  142.    path[1][6] <= 0;
  143.    path[1][7] <= 1;
  144.    path[1][8] <= 0;
  145.    path[1][9] <= 2;
  146.    path[1][10] <= 2;
  147.  
  148.    path[2][0] <= 1;
  149.    path[2][1] <= 0;
  150.    path[2][2] <= 1;
  151.    path[2][3] <= 1;
  152.     path[2][4] <= 0;
  153.    path[2][5] <= 1;
  154.    path[2][6] <= 0;
  155.    path[2][7] <= 2;
  156.    
  157.    path[3][0] <= 1;
  158.    path[3][1] <= 0;
  159.    path[3][2] <= 1;
  160.    path[3][3] <= 0;
  161.     path[3][4] <= 1;
  162.    path[3][5] <= 0;
  163.    path[3][6] <= 1;
  164.    path[3][7] <= 0;
  165.    path[3][8] <= 2;
  166.    path[3][9] <= 2;
  167.    path[3][10] <= 0;
  168.    path[3][11] <= 0;  
  169.    
  170.    path_len[0] <= 10;
  171.    path_len[1] <= 10;
  172.    path_len[2] <= 7;
  173.    path_len[3] <= 11;
  174.    
  175.     clrPath[0][0] <= 0;
  176.     clrPath[0][1] <= 1;
  177.     clrPath[0][2] <= 3;
  178.     clrPath[0][3] <= 2;
  179.     clrPath[0][4] <= 0;
  180.  
  181.     clrPath[1][0] <= 0;
  182.     clrPath[1][1] <= 0;
  183.     clrPath[1][2] <= 1;
  184.     clrPath[1][3] <= 3;
  185.     clrPath[1][4] <= 2;
  186.     clrPath[1][5] <= 0;
  187.     clrPath[1][6] <= 0;
  188.  
  189.     clrPath[2][0] <= 0;
  190.     clrPath[2][1] <= 0;
  191.     clrPath[2][2] <= 0;
  192.     clrPath[2][3] <= 1;
  193.     clrPath[2][4] <= 3;
  194.     clrPath[2][5] <= 2;
  195.     clrPath[2][6] <= 0;
  196.     clrPath[2][7] <= 0;
  197.     clrPath[2][8] <= 0;
  198.  
  199.     clrPath[3][0] <= 0;
  200.     clrPath[3][1] <= 0;
  201.     clrPath[3][2] <= 0;
  202.     clrPath[3][3] <= 2;
  203.     clrPath[3][4] <= 3;
  204.     clrPath[3][5] <= 1;
  205.     clrPath[3][6] <= 0;
  206.     clrPath[3][7] <= 0;
  207.     clrPath[3][8] <= 0;
  208.  
  209.     clrPath[4][0] <= 0;
  210.     clrPath[4][1] <= 0;
  211.     clrPath[4][2] <= 2;
  212.     clrPath[4][3] <= 3;
  213.     clrPath[4][4] <= 1;
  214.     clrPath[4][5] <= 0;
  215.     clrPath[4][6] <= 0;
  216.  
  217.     clrPath[5][0] <= 0;
  218.     clrPath[5][1] <= 2;
  219.     clrPath[5][2] <= 3;
  220.     clrPath[5][3] <= 1;
  221.     clrPath[5][4] <= 0;
  222.  
  223.     clrPath[6][1] <= 2;
  224.     clrPath[6][2] <= 3;
  225.     clrPath[6][3] <= 1;
  226.  
  227.     clrPathlen[0] <= 4;
  228.     clrPathlen[1] <= 6;
  229.     clrPathlen[2] <= 8;
  230.     clrPathlen[3] <= 8;
  231.     clrPathlen[4] <= 6;
  232.     clrPathlen[5] <= 4;
  233.     clrPathlen[6] <= 3;
  234.     clrPathlen[7] <= 0;
  235.     clrPathlen[8] <= 0;
  236.  
  237.      DepPath [0][0] <= 2;
  238.     DepPath [0][1] <= 0;
  239.     DepPath [0][2] <= 1;
  240.     DepPath [0][3] <= 1;
  241.     DepPath [0][4] <= 3;
  242.     DepPath [0][5] <= 2;
  243.     DepPath [0][6] <= 2;
  244.     DepPath [0][7] <= 0;
  245.     DepPath [0][8] <= 0;
  246.     //for DZP2
  247.     DepPath [1][0] <= 2;
  248.     DepPath [1][1] <= 1;
  249.     DepPath [1][2] <= 3;
  250.     DepPath [1][3] <= 2;
  251.     DepPath [1][4] <= 0;
  252.     //for DZM1
  253.     DepPath [2][0] <= 1;
  254.     DepPath [2][1] <= 1;
  255.     DepPath [2][2] <= 2;
  256.     DepPath [2][3] <= 3;
  257.     DepPath [2][4] <= 1;
  258.     DepPath [2][5] <= 2;
  259.     DepPath [2][6] <= 1;
  260.     //for DZM2
  261.     DepPath [3][0] <= 1;
  262.     DepPath [3][1] <= 1;
  263.     DepPath [3][2] <= 0;
  264.     DepPath [3][3] <= 2;
  265.     DepPath [3][4] <= 2;
  266.     DepPath [3][5] <= 3;
  267.     DepPath [3][6] <= 1;
  268.     DepPath [3][7] <= 1;
  269.     DepPath [3][8] <= 0;
  270.      DepPath [3][9] <= 2;
  271.     DepPath [3][10] <= 1;
  272.  
  273.     //for DZM3
  274.     DepPath [4][0] <= 1;
  275.     DepPath [4][1] <= 0;
  276.     DepPath [4][2] <= 0;
  277.     DepPath [4][3] <= 0;
  278.     DepPath [4][4] <= 1;
  279.     DepPath [4][5] <= 1;
  280.     DepPath [4][6] <= 3;
  281.     DepPath [4][7] <= 2;
  282.     DepPath [4][8] <= 2;
  283.     DepPath [4][9] <= 0;
  284.     DepPath [4][10] <= 0;
  285.      DepPath [4][11] <= 0;
  286.     DepPath [4][12] <= 1;
  287.     //for DZV2
  288.     DepPath [5][0] <= 1;
  289.     DepPath [5][1] <= 2;
  290.     DepPath [5][2] <= 3;
  291.     DepPath [5][3] <= 1;
  292.     DepPath [5][4] <= 1;
  293.     //for DZV1
  294.     DepPath [6][0] <= 0;
  295.     DepPath [6][1] <= 1;
  296.     DepPath [6][2] <= 3;
  297.     DepPath [6][3] <= 1;
  298.     //for DZN1
  299.     DepPath [7][0] <= 1;
  300.     DepPath [7][1] <= 0;
  301.     DepPath [7][2] <= 2;
  302.     DepPath [7][3] <= 1;
  303.     DepPath [7][4] <= 3;
  304.     DepPath [7][5] <= 2;
  305.     DepPath [7][6] <= 1;
  306.     DepPath [7][7] <= 0;
  307.     DepPath [7][8] <= 2;//end
  308.     //for DZN2
  309.     DepPath [8][0] <= 1;
  310.     DepPath [8][1] <= 0;
  311.     DepPath [8][2] <= 0;
  312.     DepPath [8][3] <= 2;
  313.     DepPath [8][4] <= 3;
  314.     DepPath [8][5] <= 1;
  315.     DepPath [8][6] <= 0;
  316.     DepPath [8][7] <= 0;
  317.     DepPath [8][8] <= 2;//end
  318.  
  319.     DepPath_len [0] <= 8;
  320.     DepPath_len [1] <= 4;
  321.     DepPath_len [2] <= 6;
  322.     DepPath_len [3] <= 10;
  323.     DepPath_len [4] <= 12;
  324.     DepPath_len [5] <= 4;
  325.     DepPath_len [6] <= 3;
  326.     DepPath_len [7] <= 8;
  327.     DepPath_len [8] <= 8;
  328.      
  329.     done <= 1;
  330. end
  331.    
  332.      led1 <= (s1);              //Led lights up when s1 has a greater value than 2000
  333.      led2 <= (s2);                  //Led lights up when s2 has a greater value than 2000
  334.      led3 <= (s3);                  //Led lights up when s3 has a greater value than 2000
  335.  
  336.     error <= (s1) - (s3);      //Relative error between sensors s1 and s3: values range from -1 to 1  P
  337.  
  338.     cumulative_error <= cumulative_error + error;  //Adds up the error to give a cumulative error  I
  339.      
  340.     if (cumulative_error > 10)     //Condition to reset the value of cumulative error to 10 if it crosses 10  
  341.     begin
  342.         cumulative_error <= 10;
  343.     end
  344.     if (cumulative_error < -10)    //Condition to reset the value of cumulative error to -10 if it crosses -10  
  345.     begin
  346.         cumulative_error <= -10;
  347.     end
  348.      
  349.      if ((s1==0) && s2 && (s3==0)) //Cumulative error resets to zero when the bot is on line i.e WBW
  350.      begin
  351.             cumulative_error <= 0;  
  352.             hl <=0;
  353.             id1 <= 0;
  354.      end
  355.      
  356.      difference <= error-preverror;                                  //forms the differential part D
  357.      correction <= ((10*error) + cumulative_error + (2*difference)); // kp = 10, ki = 1, kd =2
  358.       preverror <= error;  // Stores value of current error to previous error so that it can be used in next loop cycle
  359.      
  360.      
  361.      ml1 <= odc - correction;  // PID tuning for motor 1
  362.      ml2 <= odc + correction;  // PID tuning for motor 2
  363.  
  364.      if (ml1>70)      //Resetting value of ml1 to 70 if it crosses 70
  365.      begin
  366.          ml1 <= 70;
  367.      end
  368.      if (ml2>70)      //Resetting value of ml2 to 70 if it crosses 70
  369.      begin
  370.          ml2 <= 70;
  371.      end
  372.      if (ml1<30)       //Resetting value of ml1 to 30 if it becomes less than 30
  373.      begin
  374.          ml1 <= 30;
  375.      end
  376.      if (ml2<30)       //Resetting value of ml2 to 30 if it becomes less than 30
  377.      begin
  378.          ml2 <= 30;
  379.      end
  380.    
  381.     if ((s1==0) && s2 && (s3==0)) //ready for next node, flag resets to zero on line : WBW
  382.     begin
  383.         flag <= 0;
  384.           ml1r <= 0;
  385.           ml2r <= 0;
  386.     end
  387.  
  388.     if (s1 && s2 && s3 && flag == 0)  //detect node
  389.     begin
  390.             id1 <= 4;
  391.             hl <= 1;
  392.             nodecount <= nodecount + 1;
  393.          flag <= 1;   //node
  394.             flag2 <= 1;  //clr lock
  395.             clr_en <= 1; //color enable 1 disable
  396.     end
  397.    
  398.     if(flag == 1)                                  //if node
  399.     begin
  400.    
  401.         if(state==0)                                //is arena?
  402.         begin
  403.             n<=pwm(path[path_no][nodecount]);         //follow arena
  404.         end else
  405.         if((state==1)&&(nodecount<10))                                //is pick?
  406.         begin
  407.             if((clrs[clrsN][0]==1)&&(clrs[clrsN][1]==0))
  408.             begin
  409.                 n<=pwm(clrPath[0+rcount][nodecount]);
  410.             end else if((clrs[clrsN][0]==0)&&(clrs[clrsN][1]==1))
  411.             begin
  412.                 n<=pwm(clrPath[3+gcount][nodecount]);
  413.             end else if((clrs[clrsN][0]==1)&&(clrs[clrsN][1]==1))
  414.             begin
  415.                 n<=pwm(clrPath[6+bcount][nodecount]);
  416.             end
  417.         end else if((state==2)&&(nodecount<13))
  418.         begin
  419.             n<=pwm(DepPath[dest[clrsN]][nodecount]);
  420.         end
  421.        
  422.         if (state==1)
  423.         begin
  424.             if ((rcount==0) && (nodecount== 2 ))
  425.                 begin
  426.                     en<=1;
  427.                 end else if((rcount==1) && (nodecount ==3 ))
  428.                 begin
  429.                     en<=1;
  430.                 end else if((rcount==2) && (nodecount ==4 ))
  431.                 begin
  432.                     en<=1;
  433.                 end else if((gcount==0) && (nodecount ==4 ))
  434.                 begin
  435.                     en<=1;
  436.                 end else if((gcount==1) && (nodecount ==3 ))
  437.                 begin
  438.                     en<=1;
  439.                 end else if((gcount==2) && (nodecount ==2 ))
  440.                 begin
  441.                     en<=1;
  442.                 end else if((bcount==0) && (nodecount ==2 ))
  443.                 begin
  444.                     en<=1;
  445.                 end else
  446.                 begin
  447.                 en<=0;
  448.                 end
  449.                
  450.         end
  451.         if (state==2)
  452.         begin
  453.             if(dest[clrsN]==0 && nodecount == 4 )
  454.                 begin
  455.                     en<=1;
  456.                 end else if(dest[clrsN]==1 && nodecount ==2 )
  457.                 begin
  458.                     en<=1;
  459.                 end else if(dest[clrsN]==2 && nodecount ==3 )
  460.                 begin
  461.                     en<=1;
  462.  
  463.                 end else if(dest[clrsN]==3 && nodecount ==5 )
  464.                 begin
  465.                     en<=1;
  466.                 end else if(dest[clrsN]==4 && nodecount ==6 )
  467.                 begin
  468.                     en<=1;
  469.                 end else if(dest[clrsN]==5 && nodecount ==2 )
  470.                 begin
  471.                     en<=1;
  472.                 end else if(dest[clrsN]==6 && nodecount ==2 )
  473.                 begin
  474.                     en<=1;
  475.                 end else if(dest[clrsN]==7 && nodecount ==4 )
  476.                 begin
  477.                     en<=1;
  478.                 end else if(dest[clrsN]==8 && nodecount ==4 )
  479.                 begin
  480.                     en<=1;
  481.                 end else
  482.                 begin
  483.                 en<=0;
  484.                 end
  485.                
  486.            
  487.         end
  488.     end
  489.     if(flag == 0)    //assigning values of ml1 and ml2 (line condition) to mo1 and mo2 respectively
  490.     begin
  491.         if(path_no ==0 && nodecount ==5 )        //enable clr module at patch1
  492.             begin
  493.                 clr_en1 <= 0;
  494.                 if((Clr != 0)&&(flag2==1))
  495.                 begin
  496.                     clrsN <= clrsN +1;
  497.                     clrs[clrsN+1] <= Clr;
  498.                     dest[clrsN+1] <= 1;
  499.                     flag2 <= 0;
  500.                 end
  501.             end else if(path_no ==0 && nodecount ==7 )      //enable clr module only at patches
  502.         begin
  503.             clr_en1 <= 0;
  504.             if((Clr != 0)&&(flag2==1))
  505.             begin
  506.                 clrsN <= clrsN +1;
  507.                 clrs[clrsN+1] <= Clr;
  508.                 dest[clrsN+1] <= 0;
  509.                 flag2 <= 0;
  510.             end
  511.         end else if(path_no ==1 && nodecount ==5 )      //enable clr module only at patches
  512.         begin
  513.             clr_en1 <= 0;
  514.             if((Clr != 0)&&(flag2==1))
  515.             begin
  516.                 clrsN <= clrsN +1;
  517.                 clrs[clrsN+1] <= Clr;
  518.                 dest[clrsN+1] <= 2;
  519.                 flag2 <= 0;
  520.             end
  521.         end else if(path_no ==1 && nodecount ==6 )      //enable clr module only at patches
  522.         begin
  523.             clr_en1 <= 0;
  524.             if((Clr != 0)&&(flag2==1))
  525.             begin
  526.                 clrsN <= clrsN +1;
  527.                 clrs[clrsN+1] <= Clr;
  528.                 dest[clrsN+1] <= 3;
  529.                 flag2 <= 0;
  530.             end
  531.         end else if(path_no ==1 && nodecount ==7 )      //enable clr module only at patches
  532.         begin
  533.             clr_en1 <= 0;
  534.             if((Clr != 0)&&(flag2==1))
  535.             begin
  536.                 clrsN <= clrsN +1;
  537.                 clrs[clrsN+1] <= Clr;
  538.                 dest[clrsN+1] <= 4;
  539.                 flag2 <= 0;
  540.             end
  541.         end else if(path_no ==2 && nodecount ==1 )      //enable clr module only at patches
  542.         begin
  543.             clr_en1 <= 0;
  544.             if((Clr != 0)&&(flag2==1))
  545.             begin
  546.                 clrsN <= clrsN +1;
  547.                 clrs[clrsN+1] <= Clr;
  548.                 dest[clrsN+1] <= 5;
  549.                 flag2 <= 0;
  550.             end
  551.         end else if(path_no ==2 && nodecount ==6 )      //enable clr module only at patches
  552.         begin
  553.             clr_en1 <= 0;
  554.             if((Clr != 0)&&(flag2==1))
  555.             begin
  556.                 clrsN <= clrsN +1;
  557.                 clrs[clrsN+1] <= Clr;
  558.                 dest[clrsN+1] <= 6;
  559.                 flag2 <= 0;
  560.             end
  561.         end else if(path_no ==3 && nodecount ==5 )      //enable clr module only at patches
  562.         begin
  563.             clr_en1 <= 0;
  564.             if((Clr != 0)&&(flag2==1))
  565.             begin
  566.                 clrsN <= clrsN +1;
  567.                 clrs[clrsN+1] <= Clr;
  568.                 dest[clrsN+1] <= 7;
  569.                 flag2 <= 0;
  570.             end
  571.         end else if(path_no ==3 && nodecount ==7 )      //enable clr module only at patches
  572.         begin
  573.             clr_en1 <= 0;
  574.             if((Clr != 0)&&(flag2==1))
  575.             begin
  576.                 clrsN <= clrsN +1;
  577.                 clrs[clrsN+1] <= Clr;
  578.                 dest[clrsN+1] <= 8;
  579.                 flag2 <= 0;
  580.             end
  581.         end else
  582.         begin
  583.             clr_en <= 1;
  584.         end
  585.         if((state==0)&&(nodecount == (path_len[path_no]-1)))       //if about to reach end of path
  586.         begin
  587.             if(clrsN != 0)                           //detected color?
  588.             begin
  589.                 state <= 1;                             //go to pick
  590.             end else if(clrsN == 0)
  591.             begin
  592.                 nodecount <= -5'd1;                      //reset nodecount
  593.                 path_no <= path_no + 1;                  //change path
  594.             end    
  595.            
  596.         end
  597.         if(state==1)
  598.         begin
  599.             if(nodecount == path_len[path_no])
  600.             begin
  601.             nodecount <= -5'd1;
  602.             end
  603.             if((clrs[clrsN][0]==1)&&(clrs[clrsN][1]==0))
  604.             begin
  605.                 if(nodecount == clrPathlen[0+rcount])
  606.                 begin
  607.                 nodecount <= -5'd1;
  608.                 state <= 2;
  609.                 end
  610.             end else if((clrs[clrsN][0]==0)&&(clrs[clrsN][1]==1))
  611.             begin
  612.                 if(nodecount == clrPathlen[3+gcount])
  613.                 begin
  614.                 nodecount <= -5'd1;
  615.                 state <= 2;
  616.                 end
  617.             end else if((clrs[clrsN][0]==1)&&(clrs[clrsN][1]==1))
  618.             begin
  619.                 if(nodecount == clrPathlen[3+gcount])
  620.                 begin
  621.                 nodecount <= -5'd1;
  622.                 state <= 2;
  623.                 end
  624.             end
  625.         end else if(state==2)
  626.         begin
  627.             if(nodecount==DepPath_len[clrsN])
  628.             begin
  629.                 nodecount<=0;
  630.                 state<=0;
  631.                 path_no<=path_no+1;
  632.                 clrsN<= clrsN-1;
  633.             end
  634.         end
  635.         mo1 <= ml1;
  636.         mo1r<= ml1r;
  637.         mo2 <= ml2;
  638.         mo2r<= ml2r;
  639.     end else
  640.     begin            //assigning values of mn1 and mn2 (node condition) to mo1 and mo2 respectively
  641.         mo1 <= mn1;
  642.         mo1r<= mn1r;
  643.         mo2 <= mn2;
  644.         mo2r<= mn2r;
  645.     end
  646. end
  647.        
  648. assign Led1 = led1;
  649. assign Led2 = led2;
  650. assign Led3 = led3;
  651.  
  652. assign id = id1;
  653. assign HL1 = hl;
  654. assign m1 = mo1;
  655. assign m1b= mo1r;
  656. assign m2 = mo2;
  657. assign m2b= mo2r;
  658.  
  659. assign EM = en;
  660. assign Clr_en = clr_en;
  661. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement