sp3ctrm5tr

D-Type Flip Flop

Mar 18th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*---------------------------------------
  2. D-Type Flip Flop
  3. Positive edge trigger
  4. Active LOW CLR and PR
  5.  
  6. Pin Assignment for Altera DE2 Dev Board
  7. clk     27MHz
  8. d   SW[0]
  9. pr  SW[2]
  10. clr SW[1]
  11. q   LEDR[0]
  12. ---------------------------------------*/
  13. module dflipflop (
  14.     input clk, d, pr, clr,
  15.     output reg q );
  16.    
  17. always@(posedge clk)    // triggered on positive edge
  18. begin
  19.     if(pr==0) q<= 1;    // active low preset
  20.     else if(clr==0) q <= 0; // active low clr
  21.     else q <= d;
  22. end
  23.  
  24. endmodule
Advertisement
Add Comment
Please, Sign In to add comment