Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module FSM_moore(input A, B, clk, reset, output reg Q, output [1:0] state);
- reg [1:0] state, next_state;
- parameter S0 = 2'b00, S1 = 2'b01, S2 = 2'b10;
- // Nube combinacional para calcular el estado futuro
- always @ (A or B or state) begin
- case (state)
- S0:
- if (A == 1)
- next_state <= S1; // No incluimos 'begin' y 'end' porque sólo es 1 instrucción dentro del 'case'
- else
- next_state <= S0;
- S1:
- if (B == 1)
- next_state <= S2;
- else
- next_state <= S0;
- S2:
- next_state <= S0;
- default: next_state <= S0; // Incluímos el 'default' para que la sintetización sea lógica combinacional y no secuencial
- endcase
- end
- // Banco de flip flops
- always @ (posedge clk or posedge reset) begin
- if (reset == 1)
- state <= S0;
- else
- state <= next_state;
- end
- // Nube combinacional para calcular la salida
- always @ (state) begin
- case (state)
- S0: Q <= 0;
- S1: Q <= 0;
- S2: Q <= 1;
- default: Q <= 0;
- endcase
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement