



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




* Solve Probelm 5.19 (a) using state diagram directly */ module p_5_19 ( input clock, reset, x, output reg y );
reg [2:0] state;
always @ ( posedge clock, negedge reset) if (~reset) state <= 3’b000; else case (state) 3’b000: if (x) state <= 3’b100; else state <= 3’b011; 3’b001: if (x) state <= 3’b100; else state <= 3’b001; 3’b010: if (x) state <= 3’b000; else state <= 3’b010; 3’b011: if (x) state <= 3’b010; else state <= 3’b001; 3’b100: if (x) state <= 3’b011; else state <= 3’b010; 3’b101: state <= 3’bxxx; 3’b110: state <= 3’bxxx; 3’b111: state <= 3’bxxx; endcase
always @ (state, x) case (state) 3’b000: y = x; 3’b001: y = x; 3’b010: y = x; 3’b011: y = x; 3’b100: y = 1’b0; 3’b101: y = 1’bx; 3’b110: y = 1’bx; 3’b111: y = 1’bx; endcase
endmodule
_* Solve Probelm 5.19 (a) using combinatinal logic to generate next state
reg A,B,C;
always @ ( posedge clock, negedge reset) if (~reset) {A,B,C} <= 3’b000; else begin A <= ~A & ~B & x; B <= A | (~C & ~x) | (B & C & x); C <= (A & x) | (C & ~x) | (~A & ~B & ~x); end
assign y = ~A & x;
endmodule
Oct 28, 08 11:46 hw09_soln.v Page 3/