Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Mealy_style_3(
- input clk,reset,
- input [2:0] x,
- output reg [2:0] y);
- reg [2:0] state, next;
- localparam [2:0]
- s0=3'b000,
- s1=3'b001,
- s2=3'b010,
- s3=3'b011,
- s4=3'b100,
- s5=3'b101;
- always @(posedge clk, negedge reset)
- if (~reset) state <= s0;
- else
- case (state)
- s0: begin state = s1; y = 3'b011; end
- s1: if (~x[0]) begin state = s2; y = 3'b101; end
- else if (~x[1] && x[0]) begin state = s3; y = 3'b001; end
- else if (~x[2] && x[1] && x[0]) begin state = s0; y = 3'b100; end
- else begin state = s0; y = 3'b010; end
- s2: if (~x[2]) begin state = s0; y = 3'b100; end
- else begin state = s0; y = 3'b010; end
- s3: begin state = s0; y = 3'b100; end
- endcase
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement