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