Snippet: Flip Flop

Description

An basic memory element which can store a bit of information

Code

Verilog


// This here is a simple 1 bit flipflop
module flip_flop(
    input wire set,
    input wire reset,
    input wire data,
    output reg out
);

    always @(posedge set or posedge reset) begin
        if (reset)
            out <= 1'b0;
        else
            out <= data;
    end
endmodule