Manufaturação industrial
Internet das coisas industrial | Materiais industriais | Manutenção e reparo de equipamentos | Programação industrial |
home  MfgRobots >> Manufaturação industrial >  >> Industrial programming >> Verilog

Projetando um Flip-Flop D com Reset Assíncrono Ativo-Baixo

Um flip-flop D é um elemento sequencial que segue o pino de entrada d na borda determinada de um clock.

Projeto #1: Com reset assíncrono ativo-baixo

module dff (
    input d,
    input rstn,
    input clk,
    output reg q
);
always @ (posedge clk or negedge rstn)
    if (!rstn) q <= 0;
    else q <= d;
endmodule

Esquemático de Hardware

Testbench

module tb_dff;
reg clk;
reg d;
reg rstn;
reg [2:0] delay;
dff dff0 (
    .d(d),
    .rstn(rstn),
    .clk(clk),
    .q(q)
);
// Gera clock
always #10 clk = ~clk;
// Caso de teste
initial begin
    clk <= 0;
    d <= 0;
    rstn <= 0;
    #15 d <= 1;
    #10 rstn <= 1;
    for (int i = 0; i < 5; i = i + 1) begin
        delay = $random;
        #(delay) d <= i;
    end
end
endmodule

Projeto #2: Com reset síncrono ativo-baixo

module dff (
    input d,
    input rstn,
    input clk,
    output reg q
);
always @ (posedge clk)
    if (!rstn) q <= 0;
    else q <= d;
endmodule

Esquemático de Hardware

Testbench

module tb_dff;
reg clk;
reg d;
reg rstn;
reg [2:0] delay;
dff dff0 (
    .d(d),
    .rstn(rstn),
    .clk(clk),
    .q(q)
);
// Gera clock
always #10 clk = ~clk;
// Caso de teste
initial begin
    clk <= 0;
    d <= 0;
    rstn <= 0;
    #15 d <= 1;
    #10 rstn <= 1;
    for (int i = 0; i < 5; i = i + 1) begin
        delay = $random;
        #(delay) d <= i;
    end
end
endmodule

Verilog

  1. Verilog Básico: Projetando sua Primeira Porta AND
  2. Recarregando, reiniciando e reconfigurando sua estratégia de TI para sucesso no verão
  3. Convergência IT/OT: Uma Reinicialização Cultural para Transformação Digital Sustentável
  4. Domine o Verilog: Tutorial Completo para Projeto de Circuitos Digitais
  5. Contador de 4 Bits: Contagem Binária Eficiente de 0 a 15
  6. Projeto de Contador Mod-N em Verilog: Módulo Parametrizado e Testbench
  7. Módulo Contador Gray em Verilog – Gerador de Código Gray de 4 Bits
  8. Prevenindo Reset Windup em PID: Estratégias para Controle de Processo Confiável
  9. O 74LS74 Dual Flip-Flop: Referência Completa e Pinagem
  10. Entendendo o Botão Reset no Painel do Operador CNC: Função e Uso