HBLbits_Verilog Basic_Fsm2s
This is a Moore state machine with two states, two inputs, and one output. Implement this state machine.
This exercise is the same as fsm2, but using synchronous reset.
module top_module(
input clk,
input reset, // Synchronous reset to OFF
input j,
input k,
output out); //
input reset, // Synchronous reset to OFF
input j,
input k,
output out); //
parameter OFF=0, ON=1;
reg state, next_state;
always @(posedge clk) begin
// State flip-flops with synchronous reset
if (reset) begin
// Fill in reset logic
state <= OFF;
out = 0;
end else begin
case (state)
// Fill in state transition logic
ON: next_state = (k)? OFF : ON;
OFF: next_state = (j)? ON : OFF;
endcase
// State flip-flops
state = next_state;
case (state)
// Fill in output logic
OFF: out = 0;
ON: out = 1;
endcase
end
end
endmodule
沒有留言:
張貼留言