Advertisement
aidanozo

Untitled

Oct 27th, 2024
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module fsm(output reg out, input in, clk, reset_n);
  2. reg [2:0] state, next_state;
  3.  
  4. // partea secvențială
  5. always @(posedge clk) begin
  6.     if (reset_n == 0) state <= 0;
  7.     else state <= next_state;
  8. end
  9.  
  10. // partea combinationala
  11. always @(*) begin
  12.     out = 0;
  13.     case (state)
  14.         0:   if (in == 0) begin
  15.                  next_state = 1;
  16.                  out = 1;
  17.              end
  18.              else next_state = 2;
  19.         1:   if (in == 0) begin
  20.                  next_state = 3;
  21.                  out = 1;
  22.              end
  23.              else next_state = 4;        
  24.     ...
  25.     endcase
  26. end
  27. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement