Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. `timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 10/07/2019 03:46:23 PM
  7. // Design Name:
  8. // Module Name: fsm
  9. // Project Name:
  10. // Target Devices:
  11. // Tool Versions:
  12. // Description:
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. //////////////////////////////////////////////////////////////////////////////////
  21.  
  22.  
  23. module fsm(input clk, rst, start, output sin);
  24. localparam idle = 2'b01, A=1'b01, B=2'b10, C=2'b11;
  25. reg[1:0] stan, next;
  26.  
  27. always @(posedge clk, posedge rst)
  28. if(rst)
  29. stan <=idle;
  30.  
  31. else
  32. stan <=next;
  33.  
  34. always @* begin
  35. next=idle;
  36. case(stan)
  37. idle: next = start?A:idle;
  38. A: next = B;
  39. B: next = C;
  40. C: next = idle;
  41. endcase
  42. end
  43. assign sin = (stan!=idle);
  44.  
  45. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement