Prev Problem
Next Problem

80. DFF with Async Reset and Preset

Back To All Submissions
Previous Submission
Next Submission

Code

module dff_async_reset_preset (
    input  CLK,
    input  RST,
    input  PRE,
    input  D,
    output reg Q
);
    always @(posedge CLK or posedge RST or posedge PRE) begin
        if(RST == 1) begin
            Q <= 0;
        end
        else if(PRE == 1) begin
            Q <= 1;
        end
        else begin
            Q <= D;
        end
    end
endmodule
Was this helpful?
Upvote
Downvote