본문 바로가기

Verilog/HDLbits

[HDLBits] Exams/review2015 shiftcount

1. 문제 및 설명

  • 이 문제는 복잡한 카운터를 만들기 위한 5단계 중 두번째 단계입니다.

 

2.    요구사항

     A.  입력 비트 스트림에서 '1101'을 이라는 쉬퀀스를 찾는 유한 상태 머신을 설계하시오.

  • 시퀀스가 발견되면 start_shifting신호를 1로 설정하며, 리셋 되기 전까지 이 상태를 유지해야 합니다.

 

 

3. 모듈 정의

module top_module (
    input clk,
    input reset,      // Synchronous reset
    input data,
    output start_shifting);

 

 

 

4. 답

module top_module (
    input clk,
    input reset,      // Synchronous reset
    input data,
    output start_shifting);
    
    parameter state_0000 = 3'b000, state_0001 = 3'b001, state_0011 = 3'b010, state_0110 = 3'b011, state_1101 = 3'b100;
    reg [3:0] state, next_state;
    
    assign start_shifting = (state_1101==state);
    
    always@(*)
        begin
            case(state)
                state_0000: next_state = data?state_0001:state_0000;
                state_0001: next_state = data?state_0011:state_0000;
                state_0011: next_state = data?state_0011:state_0110;
                state_0110: next_state = data?state_1101:state_0000;
                state_1101: next_state = state;
                default: next_state = state_0000;
            endcase
        end
    
    always@(posedge clk)
        begin
            if(reset)
                state <= state_0000;
            else
                state <= next_state;
        end

endmodule
 



'Verilog > HDLbits' 카테고리의 다른 글

[HDLBits] Exams/review2015 fsm  (0) 2026.05.31
[HDLBits] Exams/review2015 shiftcount  (0) 2026.05.31
[HDLBits] Exams/review2015 shiftcount  (0) 2026.05.31
[HDLBits] Exams/review2015 count1k  (0) 2026.05.31
[HDLBits] Exams/2013 q2bfsm  (0) 2026.05.17