Skip to content

Flip-Flop

1. Códigos

1.1. D Flip-Flop básico

d_ff.v
module d_ff (
  input      clk_i,  
  input      d_i,     
  output reg q_o      
);

  always @(posedge clk_i) begin
    q_o <= d_i;     
  end

endmodule

1.2. D Flip-Flop con reset

d_ff_rst.v
module d_ff_rst (
  input      clk_i,  
  input      rst_i, 
  input      d_i,     
  output reg q_o      
);

  always @(posedge clk_i, posedge rst_i) begin   
    if (rst_i)   
      q_o <= 1'b0;    
    else 
      q_o <= d_i;     
  end

endmodule
d_ff_rst_sync.v
module d_ff_rst_sync (
  input      clk_i,  
  input      rst_i, 
  input      d_i,     
  output reg q_o      
);

  always @(posedge clk_i) begin   
    if (rst_i)   
      q_o <= 1'b0;    
    else 
      q_o <= d_i;     
  end

endmodule

1.3. D Flip-Flop con reset y habilitación

d_ff_rst_en.v
module d_ff_rst_en (
  input      clk_i,  
  input      rst_i, 
  input      en_i,
  input      d_i,     
  output reg q_o      
);

  always @(posedge clk_i, posedge rst_i) begin   
    if (rst_i)   
      q_o <= 1'b0;    
    else if (en_i)
      q_o <= d_i;     
  end

endmodule
d_ff_rst_en_sync.v
module d_ff_rst_en_sync (
  input      clk_i,  
  input      rst_i, 
  input      en_i,
  input      d_i,     
  output reg q_o      
);

  always @(posedge clk_i) begin   
    if (rst_i)   
      q_o <= 1'b0;    
    else if (en_i)
      q_o <= d_i;     
  end

endmodule

2. Verificación

Proximamente ..