Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. logic [11:0] count;
  2. logic [9:0] state;
  3. logic [10:0] counter;
  4. logic [9:0] current_state;
  5. logic [9:0] state_out;
  6. logic mslong;
  7. logic sslong;
  8. logic [9:0] S0 = 10'b0011010001, S1=10'b0101010010, S2=10'b1001001010,
  9. S3=10'b1000100110, S4=10'b1000100110, S5=10'b1001001010, S6=10'b0101010010;
  10. /////////////////////////////////////////////////////////////////////
  11.  
  12. always_ff @ (posedge clk or negedge rst_n) //laskuri ylös
  13. begin
  14. if (rst_n == '0)
  15. begin
  16. count <= '0;
  17. counter <= '0;
  18. current_state = S0;
  19. end
  20.  
  21. else if (count == 3000)
  22. begin
  23. counter <= counter + 1;
  24. count = '0;
  25.  
  26. end
  27.  
  28. else
  29. begin
  30. count <= count + 1;
  31. end
  32. end
  33. /////////////////////////////////////////////////////
  34.  
  35.  
  36.  
  37. ////////////////////////////////////////////////////
  38.  
  39. always_comb
  40. begin : valologiikka
  41.  
  42. case(current_state)
  43. S0:
  44. begin
  45. if(day == '0)
  46. begin
  47. if(counter == 30)
  48. begin
  49. if (ss_car == '1)
  50. begin
  51. current_state = S1;
  52. mslong = 0;
  53. counter = 0;
  54. end
  55. else
  56. begin
  57. mslong = 1;
  58. current_state = S0;
  59. end
  60. end
  61. else
  62. current_state = S0;
  63. end
  64.  
  65.  
  66. else
  67. begin
  68. if(counter == 30)
  69. begin
  70. current_state = S1;
  71. counter = 0;
  72. end
  73. else
  74. current_state = S0;
  75. end
  76.  
  77. end
  78.  
  79. S1:
  80. begin
  81. if (counter == 0)
  82. current_state = S1;
  83. else
  84. begin
  85. counter = 0;
  86. current_state = S2;
  87. end
  88. end
  89.  
  90. S2:
  91. begin
  92. if (counter == 0)
  93. current_state = S2;
  94. else
  95. begin
  96. current_state = S3;
  97. counter = 0;
  98. end
  99. end
  100.  
  101. S3:
  102. begin
  103. if (counter == 27)
  104. current_state = S4;
  105. else
  106. begin
  107. current_state = S4;
  108. counter = 0;
  109. end
  110. end
  111.  
  112. S4:
  113. begin
  114. if(day == '0)
  115. begin
  116. if (counter == 1)
  117. begin
  118. if ( ms_car == '0)
  119. begin
  120.  
  121. end
  122. end
  123.  
  124. end
  125. end
  126. end
  127. S5:
  128. begin
  129.  
  130. end
  131.  
  132. S6:
  133. begin
  134. if (counter == 1)
  135. current_state = S0;
  136. else
  137. current_state = S6;
  138.  
  139.  
  140.  
  141. end
  142. end: valologiikka
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement