본문 바로가기

Verilog/HDLbits

[HDLBits] Edgedetect

1. 문제 및 설명

  • 8비트 벡터의 각 비트에 대해, 입력 신호가 한 클록 사이클에서는 0이고, 다음 사이클에서는 1로 변하는 경우를 검출하시오.
    • 출력 비트는 0->1 전이가 발생한 다음 사이클에 1로 설정되어야 한다.
    • 다음은 예시이다.

 

2. 모듈 정의

module top_module (
    input clk,
    input [7:0] in,
    output [7:0] pedge
);

 

 

 

3. 답

module top_module (
    input clk,
    input [7:0] in,
    output [7:0] pedge
);
    integer i;
    reg [7:0] temp;
    always@(posedge clk)
        begin
            temp <= in;
            for(i = 0; i < $bits(in); i = i + 1)
                begin
                    if((temp[i] != in[i]) && (in[i] == 1))
                        pedge[i] <= 1'b1;
                    else
                        pedge[i] <= 1'b0;
                end
        end

endmodule
 

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

[HDLBits] Edgecapture  (0) 2026.01.03
[HDLBits] Edgedetect2  (0) 2026.01.01
[HDLBits] Exams/ece241 2013 q7  (0) 2026.01.01
[HDLBits] Exams/ece241 2014 q4  (0) 2025.12.31
[HDLBits] Exams/2014 q4a  (0) 2025.12.31