1. 문제 및 설명
- 두 가지 상태를 가지는 아래 FSM을 설계하시오
- 동기식 리셋을 가진다.
- reset 상태는 B이다.

2. 모듈 정의
module top_module(clk, reset, in, out);
input clk;
input reset; // Synchronous reset to state B
input in;
output out;
3. 답
// Note the Verilog-1995 module declaration syntax here:
module top_module(clk, reset, in, out);
input clk;
input reset; // Synchronous reset to state B
input in;
output out;//
reg out;
// Fill in state name declarations
reg present_state, next_state;
parameter A = 1'b0, B= 1'b1;
always @(posedge clk) begin
if (reset) begin
// Fill in reset logic
present_state = B;
out = 1'b1;
end else begin
case (present_state)
// Fill in state transition logic
A: next_state = in?A:B;
B: next_state = in?B:A;
endcase
// State flip-flops
present_state = next_state;
case (present_state)
// Fill in output logic
A: out = 1'b0;
B: out = 1'b1;
endcase
end
end
endmodule
'Verilog > HDLbits' 카테고리의 다른 글
| [HDLBits] Fsm2s (0) | 2026.02.01 |
|---|---|
| [HDLBits] Fsm2 (0) | 2026.02.01 |
| [HDLBits] Fsm1 (0) | 2026.02.01 |
| [HDLBits] Rule110 (0) | 2026.01.25 |
| [HDLBits] Rule90 (0) | 2026.01.25 |