Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. module prc3 (Clock, Resetn, w1, w2, z);
  2.  
  3. input Clock, Resetn, w1, w2;
  4. output reg z;
  5. reg [2:1] y, Y;
  6. parameter [3:1] A = 3'b000, B = 3'b001, C = 3'b010, D = 3'b011, E = 3'b100;
  7. // Define the next state and output combinational circuits
  8. always @(w1, w2, y)
  9. case (y)
  10. A: if (w1==w2)
  11. begin
  12. z = 0;
  13. Y = B;
  14. end
  15. else
  16. begin
  17. z = 0;
  18. Y = C;
  19. end
  20. B: if (w1==w2)
  21. begin
  22. z = 0;
  23. Y = D;
  24. end
  25. else
  26. begin
  27. z = 0;
  28. Y = C;
  29. end
  30. C: if (w1==w2)
  31. begin
  32. z = 0;
  33. Y = B;
  34. end
  35. else
  36. begin
  37. z = 0;
  38. Y = E;
  39. end
  40. D: if (w1==w2)
  41. begin
  42. z = 1;
  43. Y = D;
  44. end
  45. else
  46. begin
  47. z = 0;
  48. Y = C;
  49. end
  50. E: if (w1==w2)
  51. begin
  52. z = 0;
  53. Y = B;
  54. end
  55. else
  56. begin
  57. z = 1;
  58. Y = E;
  59. end
  60. endcase
  61.  
  62. // Define the sequential block
  63. always @(negedge Resetn, posedge Clock)
  64. if (Resetn == 0) y <= A;
  65. else y <= Y;
  66. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement