Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. module cam(
  2. input [7:0] DIVISOR,
  3. input DIR,
  4. input SPINDLE,
  5. output reg STEPPER
  6. );
  7.  
  8. parameter FORWARD = 1'b1;
  9. parameter REVERSE = !FORWARD;
  10.  
  11. reg[7:0] counter = 0;
  12.  
  13. always @(posedge SPINDLE) begin
  14. // STEPPER = 0;
  15. if (DIR == FORWARD) begin
  16. counter = counter + 1;
  17. if (counter == DIVISOR) counter = 0;
  18. end
  19. else begin
  20. // counter <= counter - 1;
  21. // if (counter == (-1)) counter <= DIVISOR;
  22. end
  23. end
  24.  
  25. always @(negedge SPINDLE) begin
  26. STEPPER = (counter == 0) ? 1 : 0;
  27. end
  28.  
  29. endmodule
  30.  
  31. Counter MyCount (.clk(clk),
  32. .rst(rst_count),
  33. .inc(inc_count),
  34. .data_out(count_out));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement