Posted By

woofeR on 01/16/10


Tagged

design digital tail lights thunderbird verilog vhdl fpga spartan


Versions (?)

Thunderbird Tail Lights


 / Published in: VHDL
 

  1. module thunderbird(RT, LT, Haz, BR, CLK, LL, RL);
  2. input RT, LT, Haz, BR, CLK;
  3. output [2:0] LL, RL;
  4.  
  5. reg [2:0] RTO, LTO;
  6. reg HB;
  7. reg [25:0] iClk;
  8.  
  9. turn right(RT, iClk, RTO);
  10. turn left(LT, iClk, LTO);
  11.  
  12. initial
  13. begin
  14. HB = 0;
  15. end
  16.  
  17. always @(posedge CLK)
  18. begin
  19. iClk = iClk + 1;
  20. if( iClk == 0)
  21. begin
  22. case(RT)
  23. 0:
  24. begin
  25. case(BR)
  26. 0:
  27. begin
  28. case(Haz)
  29. 0:
  30. begin
  31. RL = 3'b0;
  32. end
  33. 1:
  34. begin
  35. case(HB)
  36. 0:
  37. begin
  38. RL = 3'b0;
  39. end
  40. 1:
  41. begin
  42. RL = 3'b111;
  43. end
  44. endcase
  45. end
  46. endcase
  47. end
  48. 1:
  49. begin
  50. RL = 3'b111;
  51. end
  52. endcase
  53. end
  54. 1:
  55. begin
  56. RL = RTO;
  57. end
  58. endcase
  59. case(LT)
  60. 0:
  61. begin
  62. case(BR)
  63. 0:
  64. begin
  65. case(Haz)
  66. 0:
  67. begin
  68. LL = 3'b0;
  69. end
  70. 1:
  71. begin
  72. case(HB)
  73. 0:
  74. begin
  75. LL = 3'b0;
  76. end
  77. 1:
  78. begin
  79. LL = 3'b111;
  80. end
  81. endcase
  82. end
  83. endcase
  84. end
  85. 1:
  86. begin
  87. LL = 3'b111;
  88. end
  89. endcase
  90. end
  91. 1:
  92. begin
  93. LL = LTO;
  94. end
  95. endcase
  96. if ( HB == 1 )
  97. begin
  98. HB = ~HB;
  99. end
  100. end
  101. end
  102.  
  103.  
  104.  
  105.  
  106.  
  107. endmodule
  108.  
  109. module turn(S, Clk, O);
  110. input S, Clk;
  111. output [2:0] O;
  112.  
  113. reg [2:0] O;
  114.  
  115. always @(Clk)
  116. begin
  117. case(S)
  118. 0:
  119. begin
  120. O = 3'b0;
  121. end
  122. 1:
  123. begin
  124. case(O)
  125. 3'b000:
  126. begin
  127. O = 3'b001;
  128. end
  129. 3'b001:
  130. begin
  131. O = 3'b011;
  132. end
  133. 3'b011:
  134. begin
  135. O = 3'b111;
  136. end
  137. 3'b111:
  138. begin
  139. O = 3'b000;
  140. end
  141. endcase
  142. end
  143. endcase
  144. end
  145.  
  146. endmodule

Report this snippet  

You need to login to post a comment.