Advertisement
rufusnufus

first_draft

Oct 27th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module testik(input clock,input A,input B, output segment, output [7:0]bits);
  2.  
  3. integer cnt,last_cnt;
  4. reg state = 0;
  5. reg last_state = 0;
  6. reg [7:0] b = 8'b00000000;
  7. assign segment = 1'b0;
  8.  
  9. initial
  10. begin
  11.  cnt = 0;
  12.  last_cnt =0;
  13. end
  14.  
  15. always@(posedge clock)
  16. begin
  17.  
  18.  
  19.  state = A;
  20.         if (state != last_state)
  21.             begin
  22.                 if (state != B)
  23.                     cnt = cnt + 1;
  24.                 else
  25.                     cnt = cnt - 1;
  26.             end
  27.         last_state = state;
  28.         if(cnt!=last_cnt)
  29.         b = 8'b11111111;
  30.         else
  31.         b = 8'b00000000;
  32.        
  33.         last_cnt = cnt;
  34.  
  35. end
  36.  
  37. assign bits = b;
  38.  
  39. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement