Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Mealy_style_3(
  2.     input clk,reset,
  3.     input [2:0] x,
  4.     output reg [2:0] y);
  5.    
  6.     reg [2:0] state, next;
  7.    
  8.     localparam [2:0]
  9.         s0=3'b000,
  10.         s1=3'b001,
  11.         s2=3'b010,
  12.         s3=3'b011,
  13.         s4=3'b100,
  14.         s5=3'b101;
  15.  
  16. always @(posedge clk, negedge reset)
  17.     if (~reset) state <= s0;
  18.     else           
  19.     case (state)
  20.     s0: begin state = s1; y = 3'b011; end
  21.     s1: if (~x[0])          begin state = s2; y = 3'b101; end
  22.         else if (~x[1] && x[0])     begin state = s3; y = 3'b001; end
  23.         else if (~x[2] && x[1] && x[0]) begin state = s0; y = 3'b100; end
  24.         else                begin state = s0; y = 3'b010; end
  25.     s2: if (~x[2])          begin state = s0; y = 3'b100; end
  26.         else                begin state = s0; y = 3'b010; end
  27.     s3:                 begin state = s0; y = 3'b100; end
  28.     endcase
  29. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement