Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 03/26/2020 10:11:07 PM
  7. // Design Name:
  8. // Module Name: HazardUnit
  9. // Project Name:
  10. // Target Devices:
  11. // Tool Versions:
  12. // Description:
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. //////////////////////////////////////////////////////////////////////////////////
  21.  
  22.  
  23. module HazardUnit
  24. (
  25. input [4:0] RsD, RtD, RsE, RtE, RFAE, RFAM, RFAW,
  26. output stall,
  27. output reg flush,
  28. output reg ForwardAD, ForwardBD,
  29. output reg [1:0] ForwardAE, ForwardBE,
  30. input RFWEe, Branchd, MtoRFSele, RFWEm, RFWEw, MtoRFSelm, Jump
  31. );
  32. reg LWstall, BStall;
  33.  
  34. always @(*) begin
  35. ForwardAE <= 2'b00;
  36. ForwardBE <= 2'b00;
  37. //first 3 to 1 mux with ForwardAE
  38. if ((RsE != 0) && (RsE == RFAM) && (RFWEm)) begin
  39. ForwardAE <= 2'b10;
  40. end
  41. else if ((RsE != 0) && (RFWEw) && (RsE == RFAW)) begin
  42. ForwardAE <= 2'b01;
  43. end
  44. else begin
  45. ForwardAE <= 2'b00;
  46. end
  47. //second 3 to 1 mux with ForwardBE
  48. if ((RtE != 0) && (RtE == RFAM) && (RFWEm)) begin
  49. ForwardBE <= 2'b10;
  50. end
  51. else if ((RtE != 0) && (RFWEw) && (RtE == RFAW)) begin
  52. ForwardBE <= 2'b01;
  53. end
  54. else begin
  55. ForwardBE <= 2'b00;
  56. end
  57. //ForwardAD mux
  58. if ((RsD != 0) && (RsD == RFAM) && (RFWEm)) begin
  59. ForwardAD <= 1'b1;
  60. end
  61. else begin
  62. ForwardAD <= 1'b0;
  63. end
  64. //ForwardBD mux
  65. if ((RtD != 0) && (RtD == RFAM) && (RFWEm)) begin
  66. ForwardBD <= 1'b1;
  67. end
  68. else begin
  69. ForwardBD <= 1'b0;
  70. end
  71. //LW STALL
  72. if ((MtoRFSele && ((RtE == RsD) || (RtE == RtD)))) begin
  73. LWstall <= 1'b1;
  74. flush <= 1'b1;
  75. end
  76. else begin
  77. LWstall <= 1'b0;
  78. flush <= 1'b0;
  79. end
  80.  
  81. //Branch STall
  82. if (((RsD == RFAE) || (RtD == RFAE)) && (Branchd) && (RFWEe) || ((RsD == RFAM) || (RtD == RFAM)) && (Branchd) && (MtoRFSelm)) begin
  83. BStall <= 1'b1;
  84. end
  85. else begin
  86. BStall <= 1'b0;
  87. end
  88.  
  89. //flush <= stall;
  90. end
  91. assign stall = LWstall | BStall;
  92.  
  93. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement