SystemVerilog例子---traffic light
生活随笔
收集整理的這篇文章主要介紹了
SystemVerilog例子---traffic light
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
SystemVerilog例子---traffic light module traffic_light(output logic green_light,yellow_light,red_light,input sensor,input [15:0] green_downcnt,input [15:0] yellow_downcnt,input clock,input resetN);
parameter R_BIT = 0,G_BIT = 1,Y_BIT = 2;enum logic [2:0] {RED = 3'd001<<R_BIT,GREEN = 3'b001<<G_BIT,YELLOW = 3'b001<<Y_BIT} State, Next;@(posedge clock, negedge resetN)if(!resetN) State <= RED;else State <= Next;always_comb begin: set_next_stateNext = State;unique case(1'b1)State[R_BIT]: if(sensor) Next = GREEN;State[G_BIT]: if(green_downcnt == 0) Next = YELLOW;State[Y_BIT]: if(yellow_downcnt == 0) Next = RED;endcase
end: set_next_statealways_comb begin: set_output{green_light, yellow_light, red_light} = 3'b000;unique case(1'b1)State[R_BIT]: red_light = 1'b1; State[G_BIT]: green_light = 1'b1;State[Y_BIT]: yellow_light = 1'b1;endcase
end: set_outputendmodule
posted on 2012-06-11 17:01?Neddy11 閱讀(...) 評論(...) 編輯 收藏
轉載于:https://www.cnblogs.com/Neddy/archive/2012/06/11/2545314.html
總結
以上是生活随笔為你收集整理的SystemVerilog例子---traffic light的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Office安装源损坏
- 下一篇: OpenDDS自学