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

沒有留言:

張貼留言

MQTT WS HMI 與 Wokwi ESP32 連線的資訊透過HiveMQ

MQTT WS HMI 與 Wokwi ESP32 連線的資訊透過HiveMQ     https://console.hivemq.cloud/clusters 當您進入 HiveMQ Cloud Console 的 Clusters 頁面時,您的目標是取得能讓 MQTT W...