sp3ctrm5tr

D-Type Flip Flop using task

Mar 18th, 2013
42
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 dflipfloptask (
  14.     input clk, d,  pr, clr,
  15.     output reg q );
  16.    
  17. always@(posedge clk)        // triggered on positive edge
  18.     dff(clk, d, pr, clr, q);
  19.    
  20.    
  21. task dff;
  22.     input clock, data_in, preset, clear;
  23.     output reg data_out;
  24.    
  25.     begin
  26.         if(pr==0) q<= 1;    // active low preset
  27.         else if(clr==0) q <= 0; // active low clr
  28.         else q <= d;
  29.     end
  30. endtask
  31.  
  32. endmodule
Advertisement
Add Comment
Please, Sign In to add comment