Advertisement
Guest User

Untitled

a guest
Oct 1st, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. always @(posedge clk or posedge reset) begin
  2.    if (rst) state <= clear;
  3.    begin
  4.       case(state)
  5.          clear: state <= zero;
  6.          
  7.          zero: state <= startstop ? start : zero;
  8.  
  9.          start: state <= startstop ? start : counting;
  10.  
  11.          counting: state <= startstop ? stop : counting;
  12.          
  13.          stop: state <= startstop ? stop : stopped;
  14.  
  15.          stopped: state <= startstop ? start : stopped;
  16.  
  17.          default : state <= clear;
  18.          
  19.       endcase
  20.    end
  21. end
  22.  
  23. end
  24.  
  25. assign rst = (state == clear) ? 1'b1 : 1'b0;
  26. assign clken = (state == counting) ? 1'b1 : 1'b0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement