Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module prc3 (Clock, Resetn, w1, w2, z);
- input Clock, Resetn, w1, w2;
- output reg z;
- reg [2:1] y, Y;
- parameter [3:1] A = 3'b000, B = 3'b001, C = 3'b010, D = 3'b011, E = 3'b100;
- // Define the next state and output combinational circuits
- always @(w1, w2, y)
- case (y)
- A: if (w1==w2)
- begin
- z = 0;
- Y = B;
- end
- else
- begin
- z = 0;
- Y = C;
- end
- B: if (w1==w2)
- begin
- z = 0;
- Y = D;
- end
- else
- begin
- z = 0;
- Y = C;
- end
- C: if (w1==w2)
- begin
- z = 0;
- Y = B;
- end
- else
- begin
- z = 0;
- Y = E;
- end
- D: if (w1==w2)
- begin
- z = 1;
- Y = D;
- end
- else
- begin
- z = 0;
- Y = C;
- end
- E: if (w1==w2)
- begin
- z = 0;
- Y = B;
- end
- else
- begin
- z = 1;
- Y = E;
- end
- endcase
- // Define the sequential block
- always @(negedge Resetn, posedge Clock)
- if (Resetn == 0) y <= A;
- else y <= Y;
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement