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

D Redefinição assíncrona de flip-flop


Um D flip-flop é um elemento sequencial que segue o pino de entrada d na borda dada de um relógio.

Design nº 1:com reset ativo-baixo assíncrono

  
  
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

  

Esquema de hardware

Banco de teste

  
  
module tb_dff;
	reg clk;
	reg d;
	reg rstn;
	reg [2:0] delay;
	
    dff  dff0 ( .d(d),
                .rsnt (rstn),
                .clk (clk),
                .q (q));
    
    // Generate clock
    always #10 clk = ~clk;
                   
    // Testcase
    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

  

Design nº 1:com sincronização ativa-baixa redefinida

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

  

Esquema de hardware

Banco de teste

  
  
module tb_dff;
	reg clk;
	reg d;
	reg rstn;
	reg [2:0] delay;
	
    dff  dff0 ( .d(d),
                .rsnt (rstn),
                .clk (clk),
                .q (q));
    
    // Generate clock
    always #10 clk = ~clk;
                   
    // Testcase
    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. Introdução ao Verilog
  2. Recarregue, reinicie, reconfigure
  3. Convergência de TI / OT:uma oportunidade para uma redefinição cultural
  4. Tutorial Verilog
  5. contador de 4 bits
  6. Contador Verilog Mod-N
  7. Contador Verilog Cinza
  8. Erros PID:redefinir Windup
  9. 74LS74:um guia completo do flip-flop duplo
  10. O que é o botão RESET no painel do operador CNC