2013年11月30日 星期六

Odd counter design using FSM.v

// File        : Odd counter design using FSM.v


module Odd_counter_fsm ( clk ,dout );

output [2:0] dout ;
reg [2:0] dout ;

input clk ;
wire clk ;

parameter [1:0]st1 = 0;
parameter [1:0]st2 = 0;
parameter [1:0]st3 = 0;
parameter [1:0]st4 = 0;

reg [1:0]p_state;
reg [1:0]n_state;

initial p_state = st1;

always @ (posedge (clk)) begin
p_state <= n_state;
end

always @ (p_state) begin
case (p_state)
st1 : n_state = st2;
st2 : n_state = st3;
st3 : n_state = st4;
st4 : n_state = st1;  
endcase
end

always @ (p_state) begin
case (p_state)
st1 : dout = 1;
st2 : dout = 3;
st3 : dout = 5;
st4 : dout = 7;
endcase  
end

endmodule

沒有留言:

張貼留言

邊緣快篩與生成式 AI 智慧環境哨兵(Edge-Cloud AI EnvSentinel)

邊緣快篩與生成式 AI 智慧環境哨兵(Edge-Cloud AI EnvSentinel) 這套系統結合了 Wokwi ESP32 遙測 、 MQTT 傳輸 、 本地 LightGBM 異常快篩 、 SQLite 歷史存檔 、 Gemini 生成式 AI 診斷 與 Telegr...