module D_flip_flop(output reg Q, input D, clk, rst_n); always @(posedge clk or negedge rst_n) begin if(!rst_n) Q <= 0; else Q <= D; end endmodule