sp3ctrm5tr

16-bits upcounter

Mar 18th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*===================================================
  2. 16-bits upcounter
  3. This counter is positive edge triggered
  4. and will count up to 2^16
  5. its count reset at on negative edge active low clear
  6. ====================================================*/
  7. module counter16bitup (
  8.         input clock, clear,
  9.         output reg [15:0] count);
  10.  
  11. initial
  12.     count=4;    // start count from 4
  13.  
  14. always @ (posedge clock or negedge clear)   // trigger at positive-edge clock or negative-edge clear
  15.     if (!clear)
  16.         count=1;            // count reset when clear is LOW
  17.     else count=count + 1;
  18.        
  19. endmodule
Advertisement
Add Comment
Please, Sign In to add comment