Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module mealy_fsm(
- output reg parity,
- input clk,
- input reset,
- input x);
- reg state, next_state;
- parameter S0=0;
- parameter S1=1;
- // Partea secvențială
- always @(posedge clk or negedge reset)
- if (!reset)
- state <= S0;
- else
- state <= next_state;
- // Partea combinațională
- always @(*) begin
- parity = 1'b0;
- case(state)
- S0:
- if(x)
- next_state = S1;
- else
- next_state = S0;
- S1:
- if(x) begin
- parity = 1;
- next_state = S0;
- end
- else begin
- parity = 1;
- next_state = S1;
- end
- default:
- next_state = S0;
- endcase
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement