PGenRstGenerator.v 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //`timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 10:02:35 04/20/2020
  7. // Design Name:
  8. // Module Name: PulseGen
  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. module PGenRstGenerator
  22. #(
  23. parameter PgenNum = 7
  24. )
  25. (
  26. input Rst_i,
  27. input Clk_i,
  28. input [PgenNum-1:0] PGenRst_i,
  29. output reg [PgenNum-1:0] PGenRst_o,
  30. output reg RstDone_o
  31. );
  32. //================================================================================
  33. // LOCALPARAM
  34. //================================================================================
  35. localparam IDLE = 2'h0;
  36. localparam RST = 2'h1;
  37. localparam DEL = 2'h2;
  38. //================================================================================
  39. // REG/WIRE
  40. //================================================================================
  41. reg [1:0] currState;
  42. reg [PgenNum-1:0] pGenRstReg;
  43. wire orPGenRstReg = |pGenRstReg;
  44. //================================================================================
  45. // ASSIGNMENTS
  46. //================================================================================
  47. //================================================================================
  48. // CODING
  49. //================================================================================
  50. always @(posedge Clk_i) begin
  51. if (!Rst_i) begin
  52. pGenRstReg <= PGenRst_i;
  53. end else begin
  54. pGenRstReg <= 0;
  55. end
  56. end
  57. always @(posedge Clk_i) begin
  58. if (!Rst_i) begin
  59. case(currState)
  60. IDLE : begin
  61. if (orPGenRstReg) begin
  62. currState <= RST;
  63. PGenRst_o <= pGenRstReg;
  64. RstDone_o <= 1'b1;
  65. end else begin
  66. currState <= IDLE;
  67. PGenRst_o <= 0;
  68. RstDone_o <= 0;
  69. end
  70. end
  71. RST : begin
  72. if (RstDone_o) begin
  73. PGenRst_o <= 0;
  74. RstDone_o <= 0;
  75. currState <= DEL;
  76. end else begin
  77. currState <= RST;
  78. PGenRst_o <= 0;
  79. RstDone_o <= 0;
  80. end
  81. end
  82. DEL : begin
  83. PGenRst_o <= 0;
  84. RstDone_o <= 0;
  85. currState <= IDLE;
  86. end
  87. endcase
  88. end else begin
  89. currState <= IDLE;
  90. PGenRst_o <= 0;
  91. RstDone_o <= 0;
  92. end
  93. end
  94. endmodule