2012年10月11日 星期四

D Flip-Flop


源自
http://www.asic-world.com/examples/verilog/d_ff.html

D Flip-Flop
space.gif
space.gif
../../images/main/bulllet_4dots_orange.gifAsynchronous reset D- FF
space.gif

  1 //-----------------------------------------------------
  2 // Design Name : dff_async_reset
  3 // File Name   : dff_async_reset.v
  4 // Function    : D flip-flop async reset
  5 // Coder       : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 module dff_async_reset (
  8 data  , // Data Input
  9 clk    , // Clock Input
 10 reset , // Reset input 
 11 q         // Q output
 12 );
 13 //-----------Input Ports---------------
 14 input data, clk, reset ; 
 15 
 16 //-----------Output Ports---------------
 17 output q;
 18 
 19 //------------Internal Variables--------
 20 reg q;
 21 
 22 //-------------Code Starts Here---------
 23 always @ ( posedge clk or negedge reset)
 24 if (~reset) begin
 25   q <= 1'b0;
 26 end  else begin
 27   q <= data;
 28 end
 29 
 30 endmodule //End Of Module dff_async_reset
You could download file dff_async_reset.v here
space.gif
../../images/main/bulllet_4dots_orange.gifSynchronous reset D- FF
space.gif

  1 //-----------------------------------------------------
  2 // Design Name : dff_sync_reset
  3 // File Name   : dff_sync_reset.v
  4 // Function    : D flip-flop sync reset
  5 // Coder       : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 module dff_sync_reset (
  8 data   , // Data Input
  9 clk    , // Clock Input
 10 reset  , // Reset input
 11 q        // Q output
 12 );
 13 //-----------Input Ports---------------
 14 input data, clk, reset ; 
 15 
 16 //-----------Output Ports---------------
 17 output q;
 18 
 19 //------------Internal Variables--------
 20 reg q;
 21 
 22 //-------------Code Starts Here---------
 23 always @ ( posedge clk)
 24 if (~reset) begin
 25   q <= 1'b0;
 26 end  else begin
 27   q <= data;
 28 end
 29 
 30 endmodule //End Of Module dff_sync_reset

沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...