Advertisement
amitdutta121

Untitled

Feb 10th, 2020
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module prob8 10 (Clock, Resetn, w1, w2, z);
  2. input Clock, Resetn, w1, w2;
  3. output z;
  4. reg z;
  5. reg [2:1] y, Y;
  6. wire k;
  7. parameter [2:1] A = 2’b00, B = 2’b01, C = 2’b10, D = 2’b11;
  8. // Define the next state and output combinational circuits
  9. assign k = w1 ∧ w2;
  10. always @(k or y)
  11. case (y)
  12. A: if (k) begin
  13. Y = A; z = 0;
  14. end
  15. else begin
  16. Y = B; z = 0;
  17. end
  18. B: if (k) begin
  19. Y = A; z = 0;
  20. end
  21. else begin
  22. Y = C; z = 0;
  23. end
  24. C: if (k) begin
  25. Y = A; z = 0;
  26. end
  27. else begin
  28. Y = D; z = 0;
  29. end
  30. D: if (k) begin
  31. Y = A; z = 0;
  32. end
  33. else begin
  34. Y = D; z = 1;
  35. end
  36. endcase
  37. // Define the sequential block
  38. always @(negedge Resetn or posedge Clock)
  39. if (Resetn == 0) y <= A;
  40. else y <= Y;
  41. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement